/// <summary> /// get bill nubmer /// </summary> public static void LBN() { try { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bills").Order("ID", true); MySqlReader r = new MySqlReader(cmd); BillNO = r.Read() ? r.ReadUInt32("ID") : 0; r.Close(); } catch (Exception e) { Kernel.Core.SaveException(e); } }
/// <summary> /// login check code for user and password /// then return true value if it's correct /// show the right control panel and save logs /// </summary> public static bool UserLogin() { try { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT); cmd.Select("accounts").Where("Username", UserName).And("Password", UserPassword); MySqlReader r = new MySqlReader(cmd); if (r.Read()) { State = (States.AccountState)r.ReadByte("State"); switch (State) { case States.AccountState.Manager: { SaveLogin(); Console.WriteLine(UserName + " login as admin ha, i should go back to work then"); return(true); } case States.AccountState.Employee: { SaveLogin(); Console.WriteLine(UserName + " what's up fellow worker"); return(true); } default: MessageBox.Show("من انت؟ هل تعمل فى هذه الصيدليه؟"); Console.WriteLine("User states is unknown"); return(false); } } else { MessageBox.Show("أسم المستخدم و/او كلمه المرور خطأ"); return(false); } } catch (Exception ll) { Console.WriteLine("Error while logging in"); Core.SaveException(ll); return(false); } finally { UserPassword = null; } }
/// <summary> /// load a bill for user /// </summary> private static void LoadBill() { try { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("bills").Where("ClientName", bClient).And("ID", BillNO); MySqlReader r = new MySqlReader(cmd); if (r.Read()) { bMList = r.ReadString("Medics"); } r.Close(); } catch (Exception ee) { Kernel.Core.SaveException(ee); } }