void btn_Click(object sender, EventArgs e) { Button tbtn = (Button)sender; string name = tbtn.Name.ToString(); if (name == "send") { permission = funs.GetPermissionKey("SMS Setup"); UsersFeature ob = permission.Where(w => w.FeatureName == "Send SMS").FirstOrDefault(); if (ob != null && ob.SelectedValue == "No") { return; } else if (ob != null && ob.SelectedValue == "Ask") { if (MessageBox.Show("Are you want to send SMS?", "SMS", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (bool.Parse(dataGridView1.Rows[i].Cells["check"].Value.ToString()) == true && (dataGridView1.Rows[i].Cells["phone"].Value.ToString() != "0" && dataGridView1.Rows[i].Cells["phone"].Value.ToString() != "")) { DataTable dtSmsInfo = new DataTable(); Database.GetSqlData("select * from smssetup", dtSmsInfo); string AuthKey = ""; string SenderID = ""; string Footer = ""; if (dtSmsInfo.Rows.Count > 0) { AuthKey = dtSmsInfo.Rows[0]["uid"].ToString(); SenderID = dtSmsInfo.Rows[0]["sender"].ToString(); Footer = dtSmsInfo.Rows[0]["pin"].ToString(); Footer = Footer.Replace(" ", "%20"); Footer = Footer.Replace("(", "%28"); Footer = Footer.Replace("(", "%29"); Footer = Footer.Replace(",", "%2C"); Footer = Footer.Replace(":", "%3a"); } else { return; } string gmatter = textBox1.Text; gmatter = gmatter.Replace("{Amount}", funs.IndianCurr(double.Parse(dataGridView1.Rows[i].Cells["balance"].Value.ToString()))); gmatter = gmatter.Replace("\r", ""); gmatter = gmatter.Replace(" ", "%20"); gmatter = gmatter.Replace("(", "%28"); gmatter = gmatter.Replace("(", "%29"); gmatter = gmatter.Replace(",", "%2C"); gmatter = gmatter.Replace("\n", "%0A"); gmatter = gmatter.Replace(":", "%3a"); if (funs.isDouble(dataGridView1.Rows[i].Cells["phone"].Value.ToString()) == true) { if (dataGridView1.Rows[i].Cells["phone"].Value.ToString() != "0") { sms objsms = new sms(); objsms.send(gmatter, dataGridView1.Rows[i].Cells["phone"].Value.ToString(), dataGridView1.Rows[i].Cells["Cname"].Value.ToString()); } } } } } else if (name == "quit") { this.Close(); this.Dispose(); } }
private void Sendsms(string vid) { permission = funs.GetPermissionKey("SMS Setup"); UsersFeature ob = permission.Where(w => w.FeatureName == "Send SMS").FirstOrDefault(); if (ob != null && ob.SelectedValue == "No") { return; } else if (ob != null && ob.SelectedValue == "Ask") { if (MessageBox.Show("Are you want to send SMS?", "SMS", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } string vt_id = Database.GetScalarText("Select vt_id from Voucherinfo where vi_id='" + vid + "'"); string gtype = Database.GetScalarText("Select type from Vouchertype where vt_id='" + vt_id + "'"); DataTable dtcompany = new DataTable(); Database.GetSqlData("Select name , Address1,address2 from Company", dtcompany); if (gtype == "Sale" || gtype == "Return") { string ac_id = Database.GetScalarText("Select Ac_id from Voucherinfo where Vi_id='" + vid + "'"); if (funs.Select_AccTypeids(ac_id) != "SER3") { if (funs.Select_Mobile(funs.Select_ac_nm(ac_id)) != "0") { DataTable dtcontent = new DataTable(); Database.GetSqlData("SELECT VOUCHERTYPE.Name, VOUCHERINFO.Invoiceno, VOUCHERINFO.Vdate, VOUCHERINFO.Totalamount as amount FROM VOUCHERINFO LEFT OUTER JOIN VOUCHERTYPE ON VOUCHERINFO.Vt_id = VOUCHERTYPE.Vt_id WHERE ( VOUCHERINFO.Vi_id = '" + vid + "')", dtcontent); if (dtcontent.Rows.Count > 0) { double bal = Database.GetScalarDecimal("SELECT SUM(Balance) AS Balance FROM (SELECT Balance+Balance2 as Balance FROM dbo.ACCOUNT WHERE (Ac_id = '" + ac_id + "') UNION ALL SELECT SUM(dbo.Journal.Amount) AS SumOfAmount FROM dbo.VOUCHERINFO LEFT OUTER JOIN dbo.Journal ON dbo.VOUCHERINFO.Vi_id = dbo.Journal.Vi_id WHERE (dbo.Journal.Ac_id = '" + ac_id + "') AND (dbo.Journal.Vdate <= " + access_sql.Hash + DateTime.Parse(dtcontent.Rows[0]["vdate"].ToString()).ToString(Database.dformat) + access_sql.Hash + ") AND (dbo.Journal.AB = 'true')) AS res"); string balan = ""; if (bal == 0) { balan = "0"; } else if (bal > 0) { balan = bal.ToString() + " Dr."; } else { balan = (-1 * bal).ToString() + " Cr."; } string msg = "Dear Sir, " + dtcontent.Rows[0]["Name"].ToString() + " No: " + dtcontent.Rows[0]["Invoiceno"].ToString() + " Dated: " + DateTime.Parse(dtcontent.Rows[0]["Vdate"].ToString()).ToString(Database.dformat) + ", Amt: " + funs.IndianCurr(double.Parse(dtcontent.Rows[0]["Amount"].ToString())) + ", Current Bal is: " + balan + ", from " + dtcompany.Rows[0]["Name"].ToString() + " " + dtcompany.Rows[0]["Address2"].ToString(); msg = msg.Replace("\r", ""); if (funs.isDouble(funs.Select_Mobile(funs.Select_ac_nm(ac_id))) == true) { sms objsms = new sms(); //MessageBox.Show(msg); objsms.send(msg, funs.Select_Mobile(funs.Select_ac_nm(ac_id)), funs.Select_ac_nm(ac_id)); } } } } } else if (gtype == "Receipt" || gtype == "Cnote") { DataTable dtcontent = new DataTable(); Database.GetSqlData("SELECT VOUCHERTYPE.Name, VOUCHERINFO.Invoiceno, VOUCHERINFO.Vdate, VOUCHERACTOTAL.Accid, VOUCHERACTOTAL.Amount FROM VOUCHERINFO LEFT OUTER JOIN VOUCHERTYPE ON VOUCHERINFO.Vt_id = VOUCHERTYPE.Vt_id LEFT OUTER JOIN VOUCHERACTOTAL ON VOUCHERINFO.Vi_id = VOUCHERACTOTAL.Vi_id WHERE VOUCHERINFO.Vi_id = '" + vid + "'", dtcontent); for (int k = 0; k < dtcontent.Rows.Count; k++) { string ac_id = dtcontent.Rows[k]["Accid"].ToString(); if (funs.Select_AccTypeids(ac_id) != "SER3") { if (funs.Select_Mobile(funs.Select_ac_nm(ac_id)) != "0") { double bal = Database.GetScalarDecimal("SELECT SUM(Balance) AS Balance FROM (SELECT Balance+Balance2 as Balance FROM dbo.ACCOUNT WHERE (Ac_id = '" + ac_id + "') UNION ALL SELECT SUM(dbo.Journal.Amount) AS SumOfAmount FROM dbo.VOUCHERINFO LEFT OUTER JOIN dbo.Journal ON dbo.VOUCHERINFO.Vi_id = dbo.Journal.Vi_id WHERE (dbo.Journal.Ac_id = '" + ac_id + "') AND (dbo.Journal.Vdate <= " + access_sql.Hash + DateTime.Parse(dtcontent.Rows[0]["vdate"].ToString()).ToString(Database.dformat) + access_sql.Hash + ") AND (dbo.Journal.AB = 'true')) AS res"); string balan = ""; if (bal == 0) { balan = "0"; } else if (bal > 0) { balan = bal.ToString() + " Dr."; } else { balan = (-1 * bal).ToString() + " Cr."; } // string msg = "Dear Sir, " + dtcontent.Rows[0]["Type"].ToString() + ",Invoice No:" + dtcontent.Rows[0]["Invoiceno"].ToString() + ",Invoice Date:" + DateTime.Parse(dtcontent.Rows[0]["Vdate"].ToString()).ToString(Database.dformat) + ",Invoice Amt: " + funs.IndianCurr(double.Parse(dtcontent.Rows[0]["Amount"].ToString())) + ",Now Current Bal is: " + balan + ", from " + dtcompany.Rows[0]["Name"].ToString() + " " + dtcompany.Rows[0]["Address1"].ToString() + " " + dtcompany.Rows[0]["Address2"].ToString(); string msg = "Dear Sir, " + dtcontent.Rows[0]["Name"].ToString() + " No: " + dtcontent.Rows[0]["Invoiceno"].ToString() + " Dated: " + DateTime.Parse(dtcontent.Rows[0]["Vdate"].ToString()).ToString(Database.dformat) + ", Amt: " + funs.IndianCurr(double.Parse(dtcontent.Rows[0]["Amount"].ToString())) + ", Current Bal is: " + balan + ", from " + dtcompany.Rows[0]["Name"].ToString() + " " + dtcompany.Rows[0]["Address2"].ToString(); msg = msg.Replace("\r", ""); if (funs.isDouble(funs.Select_Mobile(funs.Select_ac_nm(ac_id))) == true) { sms objsms = new sms(); // MessageBox.Show(msg); objsms.send(msg, funs.Select_Mobile(funs.Select_ac_nm(ac_id)), funs.Select_ac_nm(ac_id)); } } } } } }
public void Loaddata() { sms smsno = new sms(); label1.Text = smsno.GetBal(); }