private void btlogin_Click(object sender, EventArgs e) { try { string[] lines = null; try { string licpath = Path.GetDirectoryName(Application.ExecutablePath) + "\\app.lic"; lines = File.ReadAllLines(licpath); } catch (Exception ex) { MessageBox.Show("LIC File Missing. Contact Admin."); } string sysid = getSystemId(); string encry = CryptorEngine.Encrypt(sysid, true); string ssysdate = CryptorEngine.Encrypt(DateTime.Now.ToString("dd/MM/yyyy"), true); DateTime sysdate = DateTime.Now; DateTime fromdate = Convert.ToDateTime(CryptorEngine.Decrypt(lines[22], true)); DateTime todate = Convert.ToDateTime(CryptorEngine.Decrypt(lines[45], true)); bool isExpried = false; if (sysdate >= fromdate && sysdate <= todate) { isExpried = false; } else { isExpried = true; } if (encry.Equals(lines[15]) && !isExpried) // if ( !isExpried) //if ( !isExpried) { string connstring = System.Configuration.ConfigurationManager.ConnectionStrings["BUS"].ConnectionString.ToString(); SqlConnection conn = new SqlConnection(connstring); conn.Open(); string qry = "select * FROM LoginMaster Where UserName='******'"; SqlDataAdapter da = new SqlDataAdapter(qry, conn); DataSet ds = new DataSet(); da.Fill(ds); conn.Close(); int rowcount = ds.Tables[0].Rows.Count; if (rowcount == 1) { string comparepass = Convert.ToString(ds.Tables[0].Rows[0]["Password"]).Trim(); string UserRole = Convert.ToString(ds.Tables[0].Rows[0]["UserRole"]).Trim(); if (comparepass == tbpassword.Text) { if (UserRole == "client") { General.Is_Edit = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["IS_EDIT"]); General.Is_Delete = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["IS_DELETE"]); } this.Hide(); MainForm mf = new MainForm(); mf.Show(); } else { MessageBox.Show("Invalid Password"); } } else { MessageBox.Show("Invalid UserName"); } } else { frmLICForm frm = new frmLICForm(); frm.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void send_Sms() { string Message = string.Empty; SqlConnection conn = new SqlConnection(connstring); conn.Open(); string qry = ""; qry = "SELECT LastDate,ReminderDate,ScheduleType+'-'+Name+'-'+RegNo AS Name,Color FROM ScheduleMaster S INNER JOIN BusMaster B ON S.BusMaster_ID = B.ID INNER JOIN ScheduleType ST On ST.ID = S.Type_ID Where S.ReminderDate='" + todayDate + "'"; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(qry, conn); da.Fill(ds); conn.Close(); int rowcount = ds.Tables[0].Rows.Count; if (rowcount > 0) { for (int i = 0; i < (ds.Tables[0].Rows.Count); i++) { Message = Message + Convert.ToString(ds.Tables[0].Rows[i]["Name"]).Trim() + "\r\n"; } Message = Message + OilAlert(); } else { Message = Message + OilAlert(); } string responseString = string.Empty; string smsNumberPath = Path.GetDirectoryName(Application.ExecutablePath).ToString() + General.smsContact; string[] num = File.ReadAllLines(smsNumberPath); string _contactNumber = string.Empty; if (num.Length > 0) { _contactNumber = num[0]; } string[] lines = null; try { string licpath = Path.GetDirectoryName(Application.ExecutablePath) + "\\app.lic"; lines = File.ReadAllLines(licpath); } catch (Exception ex) { MessageBox.Show("LIC File Missing. Contact Admin."); } string url = CryptorEngine.Decrypt(lines[46], true); string isEnable = CryptorEngine.Decrypt(lines[47], true); if (isEnable != "true") { smsNumberToolStripMenuItem.Visible = false; } using (var client = new WebClient()) { var values = new NameValueCollection(); if (isEnable == "true") { url = url.Replace("[MobileNumber]", _contactNumber); url = url.Replace("[Message]", "Customer, " + Message); var response = client.UploadValues(url, values); responseString = Encoding.Default.GetString(response); } } string filepath = Path.GetDirectoryName(Application.ExecutablePath).ToString() + General.smsCount; File.WriteAllText(filepath, todayDate); }