using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Data.SqlClient; using System.Data.SqlClient; using System.Net.Mail; using System.Text; using System.Net; using System.Drawing; using System.Globalization; using System.IO; public partial class BooksDetails : System.Web.UI.Page { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString20"].ToString()); String messageEmail, MobileNo = "966598591414"; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { grdtbl0.DataBind(); mainDetail.Visible = false; } } protected void grdtbl0_SelectedIndexChanged(object sender, EventArgs e) { string xadmin = Session["P_Order"].ToString(); if (xadmin == "True") { Session["OrderNo"] = grdtbl0.SelectedRow.Cells[0].Text.ToString(); Session["WayOrder"] = grdtbl0.SelectedRow.Cells[1].Text.ToString(); Session["WayName"] = grdtbl0.SelectedRow.Cells[2].Text.ToString(); Session["Waymob"] = grdtbl0.SelectedRow.Cells[3].Text.ToString(); Session["WayNo"] = grdtbl0.SelectedRow.Cells[4].Text.ToString(); HLShow.NavigateUrl = "BooksShow.aspx?Code=" + grdtbl0.SelectedRow.Cells[0].Text.ToString(); mainDetail.Visible = true; } else lblerror.Text = "ليس لك الصلاحية في هذا الاجراء"; } protected void DrpDepartment_SelectedIndexChanged(object sender, EventArgs e) { DrpUser.DataBind(); } protected void btnClose_Click(object sender, EventArgs e) { string xadmin = Session["P_Order"].ToString(); try { if (xadmin == "True") { SqlCommand CMDUpdate = new SqlCommand("Update C10492_CMS.cccc set DI_Finish=N'Finish Order' " + " where cccID=" + Session["OrderNo"].ToString(), con); if (con.State == ConnectionState.Closed) con.Open(); CMDUpdate.ExecuteNonQuery(); con.Close(); SqlCommand CMDInsert = new SqlCommand("Insert into Books_History(BooksID,Fromuser,ToUser,OrderStatus,Notes) " + "values (" + Session["OrderNo"].ToString() + ", " + Session["User"].ToString() + " ," + Session["User"].ToString() + ",N'Finish Order' ,N'"+ txtDesc.Text +"') " + " ", con); if (con.State == ConnectionState.Closed) con.Open(); CMDInsert.ExecuteNonQuery(); con.Close(); lblerror.Text = "تم اغلاق الطلب"; string message = ""; message = "تم اغلاق طلب جهة "; message += Session["WayOrder"].ToString(); DoSendSMS("966598591414", message.ToString()); grdtbl0.DataBind(); } else lblerror.Text = "ليس لك الصلاحية في هذا الاجراء"; } catch (Exception ex) { lblerror.Text = "يوجد خطا كالتالي " + ex.ToString(); throw; } } public String SendSMSIN(String UserName, String UserPassword, String Numbers, String Originator, String Messagex) { HttpWebRequest request; HttpWebResponse response = null; StreamReader reader; String url = "http://www.saudisms.net/gw/?userName=" + UserName + "&userPassword=" + UserPassword + "&numbers=" + Numbers + "&userSender=" + Originator + "&msg=" + Messagex + "&hash=37b46b8b198afe130faa1125c4ea6e60869d75e1"; try { request = (HttpWebRequest)WebRequest.Create(url);//DirectCast(WebRequest.Create(url), HttpWebRequest); response = (HttpWebResponse)request.GetResponse(); //DirectCast(request.GetResponse(), HttpWebResponse); reader = new StreamReader(response.GetResponseStream()); return reader.ReadToEnd(); } catch (Exception ex) { return null; } } public void DoSendSMS(String MobilNO, String Messagex) { String UserName = UrlEncoding("faris327"); String UserPassword = UrlEncoding("chinese1"); String Numbers = UrlEncoding(MobilNO.ToString()); //966509553380,966505102504,966550099032"966564043737";// String Originator = UrlEncoding("chinese"); String Messages = UrlEncoding(Messagex.ToString()); try { lblsend.Text = SendSMSIN(UserName, UserPassword, Numbers, Originator, Messages); int ReturnCode = Convert.ToInt16(lblsend.Text); switch (ReturnCode) { case 1: ReturnMSG.Text = "SMS Sent Successfully."; break; case 1010: ReturnMSG.Text = "Missing Data, Message content or Numbers."; break; case 1020: ReturnMSG.Text = "Wrong Login Combination."; break; case 1030: ReturnMSG.Text = "Same message with same destinations exist in queue, Wait 10 seconds befoure resending it."; break; case 1040: ReturnMSG.Text = "Unrecognized Charset."; break; case 1050: ReturnMSG.Text = "Msg Empty. Reason, message filteration remove message content."; break; case 1060: ReturnMSG.Text = "Insufficient Credits to procces sending."; break; case 1070: ReturnMSG.Text = "Your Credits is 0, Insufficient to procces sending."; break; case 1080: ReturnMSG.Text = "Message Not Sent, Error Sending Message."; break; case 1090: ReturnMSG.Text = "Repetition filter catch the message."; break; case 1100: ReturnMSG.Text = "Sorry, Message Not Sent. Try later."; break; case 1110: ReturnMSG.Text = "Sorry, Bad Originator (Sender Name) you used. Try another Originator."; break; case 1120: ReturnMSG.Text = "Sorry,The country you are trying to send to is not covered by our network."; break; case 1130: ReturnMSG.Text = "Sorry, Consult our network administrator regarding defiend netowrk for you account."; break; case 1140: ReturnMSG.Text = "Sorry, You exceeded maximum messages parts. Try sending fewer parts."; break; default: ReturnMSG.Text = "Un known Code.."; break; } } catch (Exception ex) { } } private string UrlEncoding(string p) { String strResult = ""; try { Encoding targetEncoding; byte[] encodedBytes; targetEncoding = Encoding.GetEncoding(1256); // Gets the byte representation of the specified string. encodedBytes = targetEncoding.GetBytes(p); foreach (Byte b in encodedBytes) { strResult = strResult + b.ToString() + "+"; } return strResult; } catch (Exception ex) { ReturnMSG.Text = ex.ToString(); return ""; } } protected void btnTransfer_Click(object sender, EventArgs e) { string xadmin = Session["P_Order"].ToString(); try { if (xadmin == "True") { SqlCommand CMDUpdate = new SqlCommand("Update C10492_CMS.cccc set emp=" + DrpUser.SelectedValue + " " + " where cccID=" + Session["OrderNo"].ToString(), con); if (con.State == ConnectionState.Closed) con.Open(); CMDUpdate.ExecuteNonQuery(); con.Close(); SqlCommand CMDInsert = new SqlCommand("Insert into Books_History(BooksID,Fromuser,ToUser,OrderStatus,Notes) " + "values (" + Session["OrderNo"].ToString() + ", " + Session["User"].ToString() + " ," + DrpUser.SelectedValue + ",N'New Order',N'" + txtDesc.Text + "') " + " ", con); if (con.State == ConnectionState.Closed) con.Open(); CMDInsert.ExecuteNonQuery(); con.Close(); //Select Email SqlCommand CMDSelect = new SqlCommand("Select Email,Tele from Users " + " where Code=" + DrpUser.SelectedValue, con); if (con.State == ConnectionState.Closed) con.Open(); SqlDataReader dr = CMDSelect.ExecuteReader(); dr.Read(); if (dr.HasRows) { MobileNo += "," + dr[1].ToString(); messageEmail = " "; messageEmail += " " + " " + "" + "
معلومات مقدم الطلب
 
اسم الجهة مقدمة الطلب:" + Session["WayOrder"].ToString() + "اسم مقدم الطلب:" + Session["WayName"].ToString() + "
رقم الجوال:" + Session["Waymob"].ToString() + " " + "
أعداد المستهدفين:" + Session["WayNo"].ToString() + "
لمزيد من التفاصيل اطلع على برنامج مسار
"; Send(messageEmail, dr[0].ToString()); } dr.Close(); con.Close(); lblerror.Text = "تم تحويل الطلب"; string message = ""; message = "تم تحويل طلب جهة "; message += Session["WayOrder"].ToString(); DoSendSMS(MobileNo.ToString(), message.ToString()); grdtbl0.DataBind(); } else lblerror.Text = "ليس لك الصلاحية في هذا الاجراء"; } catch (Exception ex) { lblerror.Text = "يوجد خطا كالتالي " + ex.ToString(); throw; } } private void Send(string mess, string email) { try { MailMessage objMM = new MailMessage(); objMM.To.Clear(); //objMM.To[]; //email += ",faris327@callingchinese.org"; objMM.To.Add(email.ToString()); //Response.Write(mess.ToString()); objMM.CC.Add("faris327@callingchinese.org"); objMM.Bcc.Add("mohamed_kaid@hotmail.com"); objMM.From = new MailAddress("admin@callingchinese.org"); objMM.IsBodyHtml = true; objMM.Priority = MailPriority.High; objMM.Subject = "تم تحويل طلب مطبوعات اليك"; objMM.BodyEncoding = Encoding.GetEncoding("windows-1256"); objMM.Sender = new MailAddress("admin@callingchinese.org", "مدير الموقع"); objMM.Body = mess.ToString(); SmtpClient smtpClient = new SmtpClient(); smtpClient.UseDefaultCredentials = false; smtpClient.Host = "mail.callingchinese.org"; smtpClient.Port = 25; smtpClient.Credentials = new NetworkCredential("info@callingchinese.org", "Fh0505228598"); smtpClient.EnableSsl = false; smtpClient.Send(objMM); } catch (Exception ex) { lblerror.Text = "يوجد خطأ ولكن لم يؤثر على تحويل طلبك"; // Response.Write(ex.ToString()); } } // Send SMS Message For User protected void btnSend_Click(object sender, EventArgs e) { string xadmin = Session["P_Order"].ToString(); try { if (xadmin == "True") { SqlCommand CMDUpdate = new SqlCommand("Update C10492_CMS.cccc set DI_Finish=N'تم ارسال الطلب' " + " where cccID=" + Session["OrderNo"].ToString(), con); if (con.State == ConnectionState.Closed) con.Open(); CMDUpdate.ExecuteNonQuery(); con.Close(); SqlCommand CMDInsert = new SqlCommand("Insert into Books_History(BooksID,Fromuser,ToUser,OrderStatus,Notes) " + "values (" + Session["OrderNo"].ToString() + ", " + Session["User"].ToString() + " ," + Session["User"].ToString() + ",N'تم ارسال الطلب',N'" + txtDesc.Text + "') " + " ", con); if (con.State == ConnectionState.Closed) con.Open(); CMDInsert.ExecuteNonQuery(); con.Close(); lblerror.Text = "تم ارسال رسالة الي مقدم الطلب"; string message = ""; message = "تم ارسال المطبوعات المطلوبة"; string Nomobil = Session["Waymob"].ToString() + ",966598591414"; DoSendSMS(Nomobil.ToString(), message.ToString()); grdtbl0.DataBind(); } else lblerror.Text = "ليس لك الصلاحية في هذا الاجراء"; } catch (Exception ex) { lblerror.Text = "يوجد خطا كالتالي " + ex.ToString(); throw; } } }