private void AddStatusDate() { DataTable dt = ObjDAL.GetData(clsUtility.DBName + ".dbo.RegistrationDetails", "PcName='" + Environment.MachineName + "'", "RegistrationID"); if (dt != null && dt.Rows.Count > 0) { DateTime status = Convert.ToDateTime(ObjUtil.Decrypt(dt.Rows[0]["StatusDate"].ToString(), true)); DateTime ExpDate = Convert.ToDateTime(ObjUtil.Decrypt(dt.Rows[0]["ExpiryDate"].ToString(), true)); //if (dt.Rows[0]["StatusDate"] != DBNull.Value && Convert.ToDateTime(dt.Rows[0]["StatusDate"]) <= DateTime.Now && Convert.ToDateTime(dt.Rows[0]["ExpiryDate"]) >= DateTime.Now) if (dt.Rows[0]["StatusDate"] != DBNull.Value && status <= ExpDate) { if (status <= Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd h:mm:ss tt"))) { ObjDAL.UpdateColumnData("StatusDate", SqlDbType.VarChar, ObjUtil.Encrypt(DateTime.Now.ToString(), true)); ObjDAL.UpdateData(clsUtility.DBName + ".dbo.RegistrationDetails", "PcName='" + Environment.MachineName + "'"); } } if (dt.Rows[0]["SoftKey"] == DBNull.Value) { lblStatus.Text = lblStatus.Text + " UnRegistered Version"; } else { lblStatus.Text = lblStatus.Text + " Registered Version"; } } else { lblStatus.Text = lblStatus.Text + " UnRegistered Version"; } }
private void cboAuthenticationType_SelectionChangeCommitted(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; if (cboAuthenticationType.SelectedIndex == 0) { clsDMCommon.ObjCon.ConnectionString = "Server=" + clsDMCommon.strServerName + ";Database=" + ClientDBName + ";uid=" + clsDMCommon.strUserID + ";pwd= " + clsDMCommon.strUserPassword + ";" + "Max Pool Size = 5004;Pooling=True"; clsConnection_DAL ObjDAL = new clsConnection_DAL(); ObjDAL.SetConnectionString(clsDMCommon.ObjCon.ConnectionString); if (ObjDAL.IsDatabaseExist(ClientDBName)) { if (!System.IO.Directory.Exists("AppConfig")) { System.IO.Directory.CreateDirectory("AppConfig"); File.WriteAllText("AppConfig\\ServerConfig.sc", ObjUtil.Encrypt(clsDMCommon.ObjCon.ConnectionString, true)); } clsUtility.ShowInfoMessage("Database is already exist.\n please select client", clsUtility.strProjectTitle); IsConnect = false; } else { grpDBRestore.Enabled = true; txtDabasePath.Focus(); } } else if (cboAuthenticationType.SelectedIndex == 1) { grpDBRestore.Enabled = false; ConnectToDB(clsDMCommon.strServerName, clsDMCommon.strUserID, clsDMCommon.strUserPassword, ClientDBName); String conn = "Server=" + clsDMCommon.strServerName + ";Database=" + ClientDBName + ";uid=" + clsDMCommon.strUserID + ";pwd= " + clsDMCommon.strUserPassword + ";" + "Max Pool Size = 5004;Pooling=True"; String EncrConn = ObjUtil.Encrypt(conn, true); if (!System.IO.Directory.Exists("AppConfig")) { System.IO.Directory.CreateDirectory("AppConfig"); File.WriteAllText("AppConfig\\ServerConfig.sc", EncrConn); } ObjDAL = new clsConnection_DAL(true); //DataTable dt = ObjDAL.GetDataCol(ClientDBName + ".dbo.RegistrationDetails", "RegistrationID", "PcName = '"+ Environment.MachineName+"'", null); int a = ObjDAL.CountRecords(ClientDBName + ".dbo.RegistrationDetails", "PcName = '" + Environment.MachineName + "'"); //if (dt == null || dt.Rows.Count == 0) if (a == 0) { InsertClientRegistration(); } else { clsUtility.ShowInfoMessage("Client is already Registered.", clsUtility.strProjectTitle); Application.Exit(); } } this.Cursor = Cursors.Default; }
private void btnUpdate_Click(object sender, EventArgs e) { if (Validateform()) { if (DuplicateUser(ID)) { string pass = ObjUtil.Encrypt(txtPassword.Text, true); ObjDAL.UpdateColumnData("UserName", SqlDbType.NVarChar, txtUserName.Text); ObjDAL.UpdateColumnData("Password", SqlDbType.NVarChar, pass); ObjDAL.UpdateColumnData("EmailID", SqlDbType.VarChar, txtEmail.Text); ObjDAL.UpdateColumnData("SecurityQuestion", SqlDbType.NVarChar, cmbSecurity.SelectedItem.ToString()); ObjDAL.UpdateColumnData("Answer", SqlDbType.NVarChar, ObjUtil.Encrypt(txtAsnwer.Text.Trim(), true)); ObjDAL.UpdateColumnData("IsAdmin", SqlDbType.Bit, rdAdmin.Checked == true ? 1 : 0); ObjDAL.UpdateColumnData("ActiveStatus", SqlDbType.Bit, rdActive.Checked == true ? 1 : 0); if (rdAdmin.Checked == false) { admin = false; clsUtility.IsAdmin = admin; } if (UserName != txtUserName.Text.Trim() || txtVerifyPassword.Text.Trim() != ObjUtil.Decrypt(pass, true) || rdAdmin.Checked || rdLimitedUser.Checked) { ObjDAL.UpdateColumnData("UpdatedOn", SqlDbType.DateTime, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); ObjDAL.UpdateColumnData("UpdatedBy", SqlDbType.Int, LogID); //if LogID=0 then Test Admin else user } if (ObjDAL.UpdateData(DBName + ".dbo.UserManagement", "UserID=" + ID) > 0) { ObjUtil.SetCommandButtonStatus(clsCommon.ButtonStatus.AfterUpdate, admin); LoadData(); ClearAll(); EnableDisable(false); clsUtility.ShowInfoMessage("'" + UserName + "' user is Updated", clsUtility.strProjectTitle); } else { clsUtility.ShowErrorMessage("'" + UserName + "' user is not Updated", clsUtility.strProjectTitle); } ObjDAL.ResetData(); } else { clsUtility.ShowErrorMessage("'" + txtUserName.Text + "' UserName OR EmailID is already exist..", clsUtility.strProjectTitle); txtUserName.Focus(); } } }
private void CreateNewUser(int EmployeeID) { ObjDAL.SetColumnData("UserName", SqlDbType.NVarChar, txtUsername.Text.Trim()); ObjDAL.SetColumnData("Password", SqlDbType.NVarChar, ObjUtil.Encrypt(txtPass.Text.Trim(), true)); ObjDAL.SetColumnData("EmailID", SqlDbType.NVarChar, txtEmail.Text.Trim()); ObjDAL.SetColumnData("IsAdmin", SqlDbType.Bit, false); ObjDAL.SetColumnData("IsBlock", SqlDbType.Bit, false); ObjDAL.SetColumnData("EmployeeID", SqlDbType.Int, EmployeeID); if (ObjDAL.InsertData(clsUtility.DBName + ".dbo.UserManagement", true) > 0) { ObjUtil.SetCommandButtonStatus(clsCommon.ButtonStatus.AfterSave, clsUtility.IsAdmin); clsUtility.ShowInfoMessage("User has been added Successfully.", clsUtility.strProjectTitle); ClearAll(); LoadData(); grpEmployee.Enabled = false; } else { clsUtility.ShowInfoMessage("Failed to add the User.", clsUtility.strProjectTitle); ObjDAL.ResetData(); } }
private void DataSave() { try { ObjDAL.UpdateColumnData("SoftKey", SqlDbType.VarChar, txtEncKey.Text.Trim()); ObjDAL.UpdateColumnData("ExpiryDate", SqlDbType.VarChar, Objutil.Encrypt(dtpExpiryDate.Value.ToString(), true)); ObjDAL.UpdateColumnData("IsTrail", SqlDbType.Bit, Istrial.Checked); if (clsUtility.DBName.Length > 0) { ObjDAL.UpdateData(clsUtility.DBName + ".dbo.RegistrationDetails", "PcName='" + Environment.MachineName + "'"); } else { ObjDAL.UpdateData("dbo.RegistrationDetails", "PcName='" + Environment.MachineName + "'"); } } catch (Exception ex) { clsUtility.ShowErrorMessage(ex.Message); } }
private bool ValidateLogin(string username, string password) { if (username.Equals("admin") && password.Equals("admin") && count <= 3) { count++; } if (username.Equals("admin") && password.Equals("admin") && count == 3) { clsUtility.LoginID = 0; clsUtility.IsAdmin = true; return(true); } else if (!(username.Equals("admin") && password.Equals("admin"))) { try { DataTable dt = ObjDAL.GetDataCol(clsUtility.DBName + ".dbo.UserManagement", "UserID,UserName,Password,IsAdmin", "UserName='******' AND Password='******' and ISNULL(Isblock,0)=0", "UserID DESC"); //int a = ObjDAL.ExecuteScalarInt("select Count(*) From CyberCafeManagement.dbo.login where UserName='******' and Password='******'"); if (dt != null && dt.Rows.Count > 0) { clsUtility.LoginID = Convert.ToInt32(dt.Rows[0]["UserID"]); clsUtility.IsAdmin = Convert.ToBoolean(dt.Rows[0]["IsAdmin"]); return(true); } else { return(false); } } catch { return(false); } } return(false); }
private void btnSaveData_Click(object sender, EventArgs e) { DataTable dt = ObjDAL.GetDataCol(clsUtility.DBName + ".dbo.UserManagement", "UserID,UserName,Password,IsAdmin", "Password='******' AND ISNULL(Isblock,0)=0", "UserID DESC"); //int a = ObjDAL.ExecuteScalarInt("select Count(*) From CyberCafeManagement.dbo.login where UserName='******' and Password='******'"); if (ObjUtil.ValidateTable(dt)) { if (Convert.ToBoolean(dt.Rows[0]["IsAdmin"])) { IsValidAdmin = true; this.Close(); } else { IsValidAdmin = false; clsUtility.ShowInfoMessage("User is not an Admin. Please enter admin password.", clsUtility.strProjectTitle); txtDiscountPass.Focus(); } } else { IsValidAdmin = false; clsUtility.ShowInfoMessage("Invalid password..", clsUtility.strProjectTitle); txtDiscountPass.Focus(); } }