private void btnPNewOK_Click(object sender, EventArgs e) { frmSDAlarm sda = new frmSDAlarm(); try { if (Convert.ToString(txtPName.Text).Trim() == "") { MessageBox.Show("Name can not be Blank..", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } string sFsdAl = txtPName.Text.ToString().TrimEnd(' '); sFsdAl = sFsdAl.TrimStart(' '); if (!string.IsNullOrEmpty(sFsdAl)) { if (Convert.ToInt32(txtPValue.Text) > 100) { MessageBox.Show("Percentage alarm should be less than 100", "Name error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtPValue.Text = ""; return; } bool IsSpecial = sda.CheckForSpecialCharacter(sFsdAl); if (!IsSpecial) { if (sFsdAl.Length > 8) { MessageBox.Show("Max limit for alarm name is 8 characters", "Name error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { this.PPercentName = sFsdAl; if ((float)Convert.ToDouble(txtPValue.Text) >= 0) { this.PPercentValue = (float)Convert.ToDouble(txtPValue.Text); this.Close(); } else { MessageBox.Show("Negative values not accepted"); } } } else { MessageBox.Show("Name Field Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show("Not Accepted", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); System.Diagnostics.Debug.WriteLine(ex.Message, ex.StackTrace); } }
private void btnOk_Click(object sender, EventArgs e) { objSD = new frmSDAlarm(); try { bool sLogin = false; sUName = txtUsrName.Text.Trim().ToString(); suPassword = txtPassword.Text.Trim().ToString(); string uID = ""; checkPassword = PublicClass.CheckForSpecialCharacter(suPassword); if (sUName == "" || suPassword == "") { MessageBox.Show("User Name & Password can not be blank", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (checkPassword == false) { MessageBox.Show("Special character is mondetory"); return; } else if (suPassword.Length < 6) { MessageBox.Show("Password must be of minimum 6 character"); return; } else { if (sLogin == true) { LoginStatus = 1; } else { LoginStatus = 0; } DataTable dtu = new DataTable(); dtu = DbClass.getdata(CommandType.Text, "Select distinct ID, UserName,Password,Password,Login from userdetail where UserName= '******' "); foreach (DataRow dr in dtu.Rows) { uID = Convert.ToString(dr["ID"]); } if (ADD_Edit == "Insert") { if (Convert.ToString(uID).Trim() != "") { MessageBox.Show(this, "This name is already exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { DbClass.executequery(CommandType.Text, "insert into userdetail(UserName,Password,Login,LastloginDate,DatabaseName) values('" + sUName.Trim() + "' , '" + suPassword.Trim() + "' , " + LoginStatus + ", '" + PublicClass.GetDatetime() + "' , '" + PublicClass.databasename + "')"); DbClass.executequery(CommandType.Text, "Insert into login_data(User_ID,uPassword,Upload,Download) values('" + sUName.Trim() + "' , '" + suPassword.Trim() + "' ," + 0 + ", " + 0 + " )"); } } else if (ADD_Edit == "Edit") { if (PublicClass.uName.Trim() != sUName || PublicClass.uPassword.Trim() != suPassword) { DbClass.executequery(CommandType.Text, "Update userdetail set UserName = '******' , Password = '******' , Login = '******' where ID = '" + PublicClass.uID.Trim() + "' "); DbClass.executequery(CommandType.Text, "Update usersettings set UserName = '******' where UserDetailID = '" + PublicClass.uID.Trim() + "' "); DbClass.executequery(CommandType.Text, "Update login_data set User_ID = '" + sUName + "' , uPassword = '******' where User_ID = '" + PublicClass.uName.Trim() + "' and uPassword = '******'"); MessageBox.Show("Update Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } this.Close(); } } catch { } }