public bool SaveUser(string Name, string UserName, string Password, string GroupID) { Password = CDB.SHA512(Password); NewCmd(); Cmd.CommandText = @"insert into TblUsers (Name, UserName, Password, UserGroupID, InsertedDate, InsertedUser) values (@Name, @UserName, @Password, @UserGroupID, @InsertedDate, @InsertedUser)"; Cmd.Parameters.AddWithValue("@Name", Name); Cmd.Parameters.AddWithValue("@UserName", UserName); Cmd.Parameters.AddWithValue("@Password", Password); Cmd.Parameters.AddWithValue("@UserGroupID", GroupID); Cmd.Parameters.AddWithValue("@InsertedDate", DateTime.Now); Cmd.Parameters.AddWithValue("@InsertedUser", Program.UserID); try { Con.Open(); Cmd.ExecuteNonQuery(); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } finally { Con.Close(); } CLog.AddLog("TblUsers", "Add New User " + Name + " Username " + UserName + " Group ID " + GroupID); return(true); }
public bool UpdateUser(string Name, string UserName, string GroupID, string ID) { NewCmd(); Cmd.CommandText = "update TblUsers set Name = @Name, LUUser = @User, LUDate = @Date, UserGroupID = @UserGroupID where ID = @ID"; Cmd.Parameters.AddWithValue("@Name", Name); Cmd.Parameters.AddWithValue("@UserName", UserName); Cmd.Parameters.AddWithValue("@UsergroupID", GroupID); Cmd.Parameters.AddWithValue("@ID", ID); Cmd.Parameters.AddWithValue("@User", Program.UserID); Cmd.Parameters.AddWithValue("@Date", DateTime.Now); try { Con.Open(); Cmd.ExecuteNonQuery(); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } finally { Con.Close(); } CLog.AddLog("TblUsers", "update User ID " + ID + " to name " + Name + " and UserName to " + UserName + " and Group ID to " + GroupID); return(true); }
private void Login() { if (TxtPassword.Text == "PrimePOSP@$$w0rd") { Program.GroupID = 0; Program.UserID = 0; Program.UserName = "******"; //Program.CashierID = "0"; //Program.CashierName = ""; Allow = true; //InstCLogin.DisableProgram(0); } else { //if (InstCLogin.CheckValidity() == false) //{ // InstCLogin.DisableProgram(1); // MessageBox.Show("يجب الاتصال بمدير البرنامج"); // Application.Exit(); //} //DataTable DTCashier = CDB.GetCashier(); //if (DTCashier.Rows.Count == 0) //{ // MessageBox.Show("الجهاز غير مسموح به على البرنامج"); // return; //} DataTable DT = InstCLogin.Login(TxtName.Text, TxtPassword.Text); if (DT.Rows.Count == 0) { MessageBox.Show("دخول غير مسموح"); } else { Program.GroupID = int.Parse(DT.Rows[0]["UserGroupID"].ToString()); Program.UserID = int.Parse(DT.Rows[0]["ID"].ToString()); Program.UserName = DT.Rows[0]["Name"].ToString(); //Program.CashierID = DTCashier.Rows[0]["ID"].ToString(); //Program.CashierName = DTCashier.Rows[0]["Name"].ToString(); Allow = true; } } if (Allow) { CLog.AddLog("Login", "UserID " + Program.UserID + " log in"); Form1 Frm1 = new Form1(); //CDB.AddLog(Program.UserID,Program.CashierID, this.Name, "تسجيل دخول الى البرنامج"); //InstCLogin.SaveLogin(Program.UserID); Frm1.Show(); this.Hide(); } }
public bool EnableUser(string ID) { NewCmd(); Cmd.CommandText = "update TblUsers set AllowLogin = 1 where ID = @ID"; Cmd.Parameters.AddWithValue("@ID", ID); try { Con.Open(); Cmd.ExecuteNonQuery(); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } finally { Con.Close(); } CLog.AddLog("TblUsers", "Enable User ID " + ID); return(true); }
public bool DeleteGroup(string ID) { NewCmd(); Cmd.CommandText = "delete from TblUserGroups where ID = @ID"; Cmd.Parameters.AddWithValue("@ID", ID); try { Con.Open(); Cmd.ExecuteNonQuery(); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } finally { Con.Close(); } CLog.AddLog("TblUserGroups", "Delete group ID " + ID); return(true); }
public bool SaveGroup(string Name) { NewCmd(); Cmd.CommandText = @"insert into TblUserGroups (Name, InsertedDate, InsertedUser) values (@Name, @InsertedDate, @InsertedUser)"; Cmd.Parameters.AddWithValue("@Name", Name); Cmd.Parameters.AddWithValue("@InsertedDate", DateTime.Now); Cmd.Parameters.AddWithValue("@InsertedUser", Program.UserID); try { Con.Open(); Cmd.ExecuteNonQuery(); } catch (Exception ex) { XtraMessageBox.Show(ex.Message); return(false); } finally { Con.Close(); } CLog.AddLog("TblUserGroups", "Add New Group " + Name); return(true); }
public bool UpdateSettings(string RHdr1, string RHdr2, string RHdr3, string LHdr1, string LHdr2, string LHdr3, byte[] PictureHdr, string Footer) { bool Result = false; NewCmd(); Cmd.CommandText = "select * from TblReportSettings"; FillDT(); if (DT.Rows.Count == 0) { Result = AddSettings(RHdr1, RHdr2, RHdr3, LHdr1, LHdr2, LHdr3, PictureHdr, Footer); } else { Result = EditSettings(RHdr1, RHdr2, RHdr3, LHdr1, LHdr2, LHdr3, PictureHdr, Footer); } if (Result) { CLog.AddLog("TblReportSettings", "update report settings"); } return(Result); }