Exemple #1
0
 private void UpdateBtn_Click(object sender, RoutedEventArgs e)
 {
     if (Authenticated.IndexOf("UpdateUsers") == -1 && Authenticated.IndexOf("CheckAllUsers") == -1)
     {
         LogIn logIn = new LogIn();    logIn.ShowDialog();
     }
     else
     {
         try
         {
             string FiledSelection = "Name,UserName,Password,UserClass_ID,Mobile,Adress,Email,Active,ModifiedDate";
             string Values         = string.Format("N'{0}','{1}','{2}',(select UserClass_ID FROM UserClass_tbl Where Name='{3}'),'{4}',N'{5}','{6}','{7}',GETDATE()", Nametxt.Text, UserNametxt.Text, passwordtxt.Password, jobTitle.Text, phone.Text, Addresstxt.Text, Mailtxt.Text, Active_chbx.IsChecked.ToString());
             string Where          = "ID = " + userIDtxt.Text;
             Classes.UpdateRow(FiledSelection, Values, Where, "Users");
         }
         catch (Exception ex)
         { MessageBox.Show(ex.ToString()); }
         finally
         {
             MainUiFormat();
             Classes.LogTable(Classes.MyComm.CommandText.ToString(), userIDtxt.Text, "Users", "Update");
             UsersDGV.DataContext = null;
             FillDGV();
         }
         MessageBox.Show("Updated Successfully");
     }
 }
Exemple #2
0
 private void UpdateBtn_Click(object sender, RoutedEventArgs e)
 {
     if (Authenticated.IndexOf("UpdateUnits") == -1 && Authenticated.IndexOf("CheckAllUnits") == -1)
     {
         LogIn logIn = new LogIn();   logIn.ShowDialog();
     }
     else
     {
         try
         {
             string FiledSelection = "Name,IsActive,Last_modifiled_Date";
             string Values         = string.Format("N'{0}','{1}',GETDATE()", Name_txt.Text, Active_chbx.IsChecked);
             string Where          = "Code = " + Code_txt.Text;
             Classes.UpdateRow(FiledSelection, Values, Where, "Units");
         }
         catch (Exception ex)
         { MessageBox.Show(ex.ToString()); }
         finally
         {
             Classes.LogTable(Classes.MyComm.CommandText.ToString(), Code_txt.Text, "Units", "Update");
             MainUiFormat();
             Unit_DGV.DataContext = null;
             FillDGV();
         }
         MessageBox.Show("Updated Successfully");
     }
 }
Exemple #3
0
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("SaveUnits") == -1 && Authenticated.IndexOf("CheckAllUnits") == -1)
            {
                LogIn logIn = new LogIn();   logIn.ShowDialog();
            }
            else
            {
                if (Code_txt.Text == "")
                {
                    MessageBox.Show("Code Field Can't Be Empty");
                    return;
                }

                try
                {
                    string FiledSelection = "Code,Name,IsActive,Create_Date,User_ID,WS";
                    string Values         = string.Format("'{0}',N'{1}','{2}',GETDATE(),'{3}','{4}'", Code_txt.Text, Name_txt.Text, Active_chbx.IsChecked.ToString(), MainWindow.UserID, Classes.WS);
                    Classes.InsertRow("Units", FiledSelection, Values);
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
                finally
                {
                    Classes.LogTable(Classes.MyComm.CommandText.ToString(), Code_txt.Text, "Units", "New");
                    MainUiFormat();
                    Unit_DGV.DataContext = null;
                    FillDGV();
                }
                MessageBox.Show("Saved Successfully");
            }
        }
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("SaveUsersAuthentication") == -1 && Authenticated.IndexOf("CheckAllUsersAuthentication") == -1)
            {
                LogIn logIn = new LogIn();     logIn.ShowDialog();
            }
            else
            {
                if (UserClassIDtxt.Text == "")
                {
                    MessageBox.Show("Please enter ID Field");
                    return;
                }
                if (Nametxt.Text == "")
                {
                    MessageBox.Show("Please enter Name Field");
                    return;
                }

                try
                {
                    string FiledSelection = "UserClass_ID,Name,Active,CreateDate,User_ID,WS";
                    string Values         = string.Format("'{0}',N'{1}','{2}',GETDATE(),'{3}','{4}'", UserClassIDtxt.Text, Nametxt.Text, Active_chbx.IsChecked.ToString(), MainWindow.UserID, Classes.WS);
                    Classes.InsertRow("UserClass_tbl", FiledSelection, Values);
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
                Classes.LogTable(Classes.MyComm.CommandText.ToString(), UserClassIDtxt.Text, "UserClass_tbl", "New");
                MainUIFormat();
                MessageBox.Show("Saved Successfully");
                LoadUserClasses();
            }
        }
Exemple #5
0
 private void DeleteBtn_Click(object sender, RoutedEventArgs e)
 {
     if (Authenticated.IndexOf("DeleteUnits") == -1 && Authenticated.IndexOf("CheckAllUnits") == -1)
     {
         LogIn logIn = new LogIn();   logIn.ShowDialog();
     }
     else
     {
         try
         {
             string where = "Code = " + Code_txt.Text;
             Classes.DeleteRows(where, "Units");
         }
         catch (Exception ex)
         { MessageBox.Show(ex.ToString()); }
         finally
         {
             MainUiFormat();
             Classes.LogTable(Classes.MyComm.CommandText.ToString(), Code_txt.Text, "Units", "Delete");
             Unit_DGV.DataContext = null;
             FillDGV();
         }
         MessageBox.Show("Deleted Successfully");
     }
 }
Exemple #6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (WorkStation_no.Text == "" || Restaurant_cbx.Text == "" || Kitchen_cbx.Text == "")
            {
                MessageBox.Show("Null Fields");
                return;
            }
            string ResturantCode = Classes.RetrieveRestaurantCode(Restaurant_cbx.SelectedItem.ToString());
            string KitchenCode   = Classes.RetrieveKitchenCode(Kitchen_cbx.SelectedItem.ToString(), Restaurant_cbx.SelectedItem.ToString());


            if (WorkStation_no.Text.Length == 1)
            {
                WorkStation_no.Text = "0" + WorkStation_no.Text;
            }
            if (ResturantCode.Length == 1)
            {
                ResturantCode = "0" + ResturantCode;
            }
            if (KitchenCode.Length == 1)
            {
                KitchenCode = "0" + KitchenCode;
            }

            string WorkStationInfo = WorkStation_no.Text + "," + ResturantCode + "," + KitchenCode + "," + WorkStation_Name.Text;

            File.WriteAllText("Workstation.dll", WorkStationInfo);
            Classes.LogTable(WorkStationInfo, WorkStation_Name.Text, "WS", "Update");

            MessageBox.Show("Saved");
            Classes.GetWS();
        }
Exemple #7
0
 private void SaveUNitBtn_Click(object sender, RoutedEventArgs e)
 {
     if (Authenticated.IndexOf("SaveConvUnits") == -1 && Authenticated.IndexOf("CheckAllUnits") == -1)
     {
         LogIn logIn = new LogIn();
         logIn.ShowDialog();
     }
     else
     {
         try
         {
             string FiledSelection = "Code,BaseUnit_ID,BaseUnit_Name,Value,SecondUnit_ID,SecondUnit_Name,Create_Date,User_ID,WS";
             string Values         = string.Format("'{5}',(select Code from Units where Name='{0}'),N'{0}','{1}',(select Code from Units where Name='{2}'),N'{2}',GETDATE(),'{3}','{4}'", BaseUnit.Text, ConvUnit2.Text, Secondunit.Text, MainWindow.UserID, Classes.WS, TheCode_txt.Text);
             Classes.InsertRow("Units_Conversion", FiledSelection, Values);
         }
         catch (Exception ex) { MessageBox.Show(ex.ToString()); }
         finally
         {
             MessageBox.Show("Saved Sussesfully !");
             RecipeUnit_DGV.DataContext = null;
             LoadAllCOnv();
             ClearUIFields();
             Classes.LogTable(Classes.MyComm.CommandText.ToString(), TheCode_txt.Text, "Units_Conversion", "New");
             SaveUNitBtn.IsEnabled    = false;
             BtnRecipeUnit2.IsEnabled = false;
             BtnRecipeUnit.IsEnabled  = false;
         }
     }
 }
Exemple #8
0
 private void UpdateUnitBtn_Click(object sender, RoutedEventArgs e)
 {
     if (Authenticated.IndexOf("UpdateConvUnits") == -1 && Authenticated.IndexOf("CheckAllUnits") == -1)
     {
         LogIn logIn = new LogIn();
         logIn.ShowDialog();
     }
     else
     {
         try
         {
             string FiledSelection = "BaseUnit_ID,BaseUnit_Name,Value,SecondUnit_ID,SecondUnit_Name,Last_modifiled_Date";
             string Values         = string.Format("(select Code From Units where Name='{0}'),N'{0}','{1}',(select Code From Units where Name='{2}'),'{2}',GETDATE()", BaseUnit.Text, ConvUnit2.Text, Secondunit.Text);
             string Where          = "Code=" + TheCode_txt.Text;
             Classes.UpdateRow(FiledSelection, Values, Where, "Units_Conversion");
         }
         catch (Exception ex)
         { MessageBox.Show(ex.ToString()); }
         {
             RecipeUnit_DGV.DataContext = null;
             MessageBox.Show("Saved Sussesfully !");
             Classes.LogTable(Classes.MyComm.CommandText.ToString(), TheCode_txt.Text, "Units_Conversion", "Update");
             SaveUNitBtn.IsEnabled    = false;
             BtnRecipeUnit2.IsEnabled = false;
             BtnRecipeUnit.IsEnabled  = false;
             UpdateUnitBtn.IsEnabled  = false;
             LoadAllCOnv();
             BaseUnit.Text   = "";
             Secondunit.Text = "";
             ConvUnit2.Text  = "";
             ClearUIFields();
             MainUiFormat();
         }
     }
 }
Exemple #9
0
        private void DeleteUnitBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("DeleteConvUnits") == -1 && Authenticated.IndexOf("CheckAllUnits") == -1)
            {
                LogIn logIn = new LogIn();
                logIn.ShowDialog();
            }
            else
            {
                try
                {
                    string where = "Code = " + TheCode_txt.Text;
                    Classes.DeleteRows(where, "Units_Conversion");
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
                finally
                {
                    Classes.LogTable(Classes.MyComm.CommandText.ToString(), TheCode_txt.Text, "Units_Conversion", "Delete");
                    BtnRecipeUnit2.IsEnabled = false;
                    BtnRecipeUnit.IsEnabled  = false;
                    SaveUNitBtn.IsEnabled    = false;
                    UpdateUnitBtn.IsEnabled  = false;
                    DeleteUnitBtn.IsEnabled  = false;

                    RecipeUnit_DGV.DataContext = null;
                    LoadAllCOnv();
                    ClearUIFields();
                    MainUiFormat();
                }
                MessageBox.Show("Deleted Successfully");
            }
        }
Exemple #10
0
        }           //Done

        private void Save_TIK()
        {
            try
            {
                string FiledSelection = "Transfer_Serial,Manual_Transfer_No,Transfer_Date,Comment,From_Resturant_ID,To_Resturant_ID,From_Kitchen_ID,To_Kitchen_ID,Create_Date,Type,UserID,WS,Status,Total_Cost";
                string values         = string.Format("'{0}', '{1}', '{2}', '{3}', (select Code from Setup_Restaurant where Name = '{4}'),(select Code from Setup_Restaurant where Name = '{5}'),(select Code from Setup_Kitchens where Name = '{6}' and RestaurantID=(select Code From Setup_Restaurant where Name='{4}')),(select Code from Setup_Kitchens where Name = '{7}' and RestaurantID=(select Code From Setup_Restaurant where Name='{5}')), GETDATE(),'{8}','{9}','{10}','{11}','{12}'", transfer_No.Text, Manual_transfer_No.Text, Convert.ToDateTime(Transfer_dt.Text).ToString("MM-dd-yyyy"), commenttxt.Text, From_Resturant.Text, ToResturant.Text, From_Kitchen.Text, To_Kitchen.Text, "Transfer_Resturant", MainWindow.UserID, Classes.WS, Statustxt.Text, Total_Price.Text);
                Classes.InsertRow("Transfer_Kitchens", FiledSelection, values);
                Classes.LogTable(Classes.MyComm.CommandText.ToString(), transfer_No.Text, "Transfer_Kitchens", "New");
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }           //Done
Exemple #11
0
        }           //Done

        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("SaveResturants") == -1 && Authenticated.IndexOf("CheckAllResturants") == -1)
            {
                LogIn logIn = new LogIn();  logIn.ShowDialog();
            }
            else
            {
                if (Code_txt.Text == "")
                {
                    MessageBox.Show("Code Field Can't Be Empty");
                    return;
                }
                for (int i = 0; i < Stores_DGV.Items.Count; i++)
                {
                    if (Code_txt.Text == ((DataRowView)Stores_DGV.Items[i]).Row.ItemArray[0].ToString())
                    {
                        MessageBox.Show("This Code Is Not Avaliable");
                        return;
                    }
                }
                if (IsMain.IsChecked == true)
                {
                    try
                    {
                        DataTable IsMain = Classes.RetrieveData("IsMain", "IsMain='True'", "Setup_Restaurant");
                        if (IsMain.Rows.Count != 0)
                        {
                            MessageBox.Show("Can't be More than Main Resturant !");
                            return;
                        }
                    }
                    catch { }
                }

                try
                {
                    string FiledSelection = "Code,Name,Name2,IsMain,IsActive,Create_Date,WS,UserID";
                    string values         = string.Format("'{0}', N'{1}', N'{2}', '{3}','{4}',{5},'{6}','{7}'", Code_txt.Text, Name_txt.Text, Name2_txt.Text, IsMain.IsChecked, Active_chbx.IsChecked, "GETDATE()", Classes.WS, MainWindow.UserID);
                    Classes.InsertRow("Setup_Restaurant", FiledSelection, values);
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
                finally
                {
                    Classes.LogTable(Classes.MyComm.CommandText.ToString(), Code_txt.Text, "Setup_Restaurant", "New");
                    MainUiFormat();
                    Stores_DGV.DataContext = null;
                    FillDGV();
                }
                MessageBox.Show("Saved Successfully");
            }
        }           //Done
Exemple #12
0
        }               //Done

        private void Edit_TIK()
        {
            try
            {
                string FiledSlection = "Manual_Transfer_No,Transfer_Date,Comment,From_Resturant_ID,To_Resturant_ID,From_Kitchen_ID,To_Kitchen_ID,Type,Status,Modifiled_Date,Total_Cost";
                string Values        = string.Format("'{0}','{1}','{2}',(select Code From Setup_Restaurant where Name='{3}'),(select Code From Setup_Restaurant where Name='{4}'),(select Code From Setup_Kitchens where Name='{5}' and RestaurantID=(select Code From Setup_Restaurant where Name='{3}')),(select Code From Setup_Kitchens where Name='{6}' and RestaurantID=(select Code From Setup_Restaurant where Name='{4}')),'{7}','{8}',GETDATE(),'{9}'", Manual_transfer_No.Text, Convert.ToDateTime(Transfer_dt.Text).ToString("MM-dd-yyyy"), commenttxt.Text, From_Resturant.Text, ToResturant.Text, From_Kitchen.Text, To_Kitchen.Text, "Transfer_Resturant", Statustxt.Text, Total_Price.Text);
                string Where         = string.Format("Transfer_Serial={0}", transfer_No.Text);
                Classes.UpdateRow(FiledSlection, Values, Where, "Transfer_Kitchens");
                Classes.LogTable(Classes.MyComm.CommandText.ToString(), transfer_No.Text, "Transfer_Kitchens", "Update");
            }
            catch (Exception ex)
            { MessageBox.Show(ex.ToString()); }
        }           //Done
Exemple #13
0
        }           //DOne

        private void Save_Changes()
        {
            if (!DoSomeChecks())
            {
                return;
            }

            if (CheckIfTransactionExist() == true)
            {
                string Where = string.Format("Adjacment_ID='{0}'", Serial_Adjacment_NO.Text);
                Classes.DeleteRows(Where, "Adjacment_Items");

                try
                {
                    for (int i = 0; i < ItemsDGV.Items.Count; i++)
                    {
                        string FiledSelection = "Adjacment_ID,Item_ID,Qty,AdjacmentableQty,Variance,Cost,Recipe";
                        string Values         = string.Format("'{0}','{1}','{2}','{3}','{4}','{5}','{6}'", Serial_Adjacment_NO.Text, (((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[0]), Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[3]), Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[4]), Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[5]), Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[6]), (bool)((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[9]);
                        Classes.InsertRow("Adjacment_Items", FiledSelection, Values);
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
                Classes.LogTable(Classes.MyComm.CommandText.ToString(), Serial_Adjacment_NO.Text, "Adjacment_tbl", "Update");
            }
            else
            {
                try
                {
                    string FiledSelection = "Adjacment_ID,Adjacment_Num,Adjacment_Reason,Adjacment_Date,Comment,Resturant_ID,KitchenID,Create_Date,User_ID,WS,Total_Cost";
                    string Values         = string.Format("'{0}',{1},(select Code From Setup_AdjacmentReasons_tbl where Name='{2}'),'{3}','{4}',{5},{6},GETDATE(),'{7}','{8}','{9}'", Serial_Adjacment_NO.Text, Adjacment_NO.Text, Reasoncbx.Text, Convert.ToDateTime(Adjacment_Date.Text).ToString("MM-dd-yyyy"), commenttxt.Text, ValOfResturant, ValOfKitchen, MainWindow.UserID, Classes.WS, Total_Price.Text);
                    Classes.InsertRow("Adjacment_tbl", FiledSelection, Values);
                }
                catch (Exception ex)

                { MessageBox.Show(ex.ToString()); }

                try
                {
                    for (int i = 0; i < ItemsDGV.Items.Count; i++)
                    {
                        string FiledSelection = "Adjacment_ID,Item_ID,Qty,AdjacmentableQty,Variance,Cost,Recipe";
                        string Values         = string.Format("'{0}','{1}','{2}','{3}','{4}','{5}','{6}'", Serial_Adjacment_NO.Text, (((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[0]), Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[3]), Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[4]), Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[5]), Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[6]), (bool)((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[9]);
                        Classes.InsertRow("Adjacment_Items", FiledSelection, Values);
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
                Classes.LogTable(Classes.MyComm.CommandText.ToString(), Serial_Adjacment_NO.Text, "Adjacment_tbl", "New");
            }
        }           //Done
Exemple #14
0
        private void Save_TIK_Items()
        {
            try
            {
                DataTable dt = ItemsDGV.DataContext as DataTable;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    float NetCost = float.Parse(dt.Rows[i]["Qty"].ToString()) * float.Parse(dt.Rows[i][7].ToString());

                    string Values = "'" + dt.Rows[i]["Code"] + "','" + transfer_No.Text + "','" + dt.Rows[i]["Qty"] + "','" + dt.Rows[i]["Unit"] + "','" + i + "','" + dt.Rows[i][7] + "','" + NetCost + "','" + dt.Rows[i][ToResturant.Text + " Qty"] + "','" + dt.Rows[i][ToResturant.Text + " Unit Cost"] + "','" + dt.Rows[i][From_Resturant.Text + " Qty"] + "','" + dt.Rows[i][From_Resturant.Text + " Unit Cost"] + "'";
                    Classes.InsertRow("Transfer_Kitchens_Items", Values);
                    Classes.LogTable(Classes.MyComm.CommandText.ToString(), transfer_No.Text, "Transfer_Kitchens_Items", "New");
                }
            }
            catch
            { MessageBox.Show("Items Input Error"); }
        }           //Done
Exemple #15
0
        }       //Done

        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("SaveVendors") == -1 && Authenticated.IndexOf("CheckAllVendors") == -1)
            {
                LogIn logIn = new LogIn(); logIn.ShowDialog();
            }
            else
            {
                if (Code_txt.Text == "")
                {
                    MessageBox.Show("Code Field Can't Be Empty");
                    return;
                }

                for (int i = 0; i < Vendors_DGV.Items.Count; i++)
                {
                    if (((DataRowView)Vendors_DGV.Items[i]).Row.ItemArray[0].ToString().Equals(Code_txt.Text))
                    {
                        MessageBox.Show("This Code Is Not Avaliable");
                        return;
                    }
                    if (((DataRowView)Vendors_DGV.Items[i]).Row.ItemArray[1].ToString().Equals(Name_txt.Text))
                    {
                        MessageBox.Show("Please Change The Name"); return;
                    }
                }

                try
                {
                    string FiledSelection = "Code,Name,IsActive,CreateDate,UserID,WS";
                    string Values         = string.Format("'{0}',N'{1}','{2}',GETDATE(),'{3}','{4}'", Code_txt.Text, Name_txt.Text, Active_chbx.IsChecked.ToString(), MainWindow.UserID, Classes.WS);
                    Classes.InsertRow("Vendors", FiledSelection, Values);
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
                finally
                {
                    Classes.LogTable(Classes.MyComm.CommandText.ToString(), Code_txt.Text, "Vendors", "New");
                    MainUiFormat();

                    Vendors_DGV.DataContext = null;
                    FillDGV();
                }
                MessageBox.Show("Saved Successfully");
            }
        }
Exemple #16
0
 private void DeleteBtn_Click(object sender, RoutedEventArgs e)
 {
     if (Authenticated.IndexOf("DeleteResturants") == -1 && Authenticated.IndexOf("CheckAllResturants") == -1)
     {
         LogIn logIn = new LogIn();
         logIn.ShowDialog();
     }
     else
     {
         SqlConnection con = new SqlConnection(Classes.DataConnString);
         try
         {
             con.Open();
             string     s   = string.Format("select Code from Setup_Kitchens where RestaurantID='{0}'", Code_txt.Text);
             SqlCommand cmd = new SqlCommand(s, con);
             if (cmd.ExecuteScalar() == null)
             {
                 try
                 {
                     s   = "delete from Setup_Restaurant where Code = " + Code_txt.Text;
                     cmd = new SqlCommand(s, con);
                     cmd.ExecuteNonQuery();
                 }
                 catch (Exception ex)
                 { MessageBox.Show(ex.ToString()); }
                 finally
                 {
                     con.Close();
                     MainUiFormat();
                     Classes.LogTable(Classes.MyComm.CommandText.ToString(), Code_txt.Text, "Setup_Restaurant", "Delete");
                     Stores_DGV.DataContext = null;
                     FillDGV();
                 }
                 MessageBox.Show("Deleted Successfully");
             }
             else
             {
                 MessageBox.Show("You Can't Delete This Restaurant Because that Have Kitchens !");
             }
         }
         catch (Exception ex) { MessageBox.Show(ex.ToString()); }
     }
 }
Exemple #17
0
        }           //Done

        private void UpdateBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("UpdateResturants") == -1 && Authenticated.IndexOf("CheckAllResturants") == -1)
            {
                LogIn logIn = new LogIn();   logIn.ShowDialog();
            }
            else
            {
                SqlConnection con = new SqlConnection(Classes.DataConnString);

                if (IsMain.IsChecked == true)
                {
                    try
                    {
                        DataTable IsMain = Classes.RetrieveData("IsMain", "IsMain='True'", "Setup_Restaurant");
                        if (IsMain.Rows.Count != 0)
                        {
                            MessageBox.Show("Can't be More than Main Resturant !");
                            return;
                        }
                    }
                    catch { }
                }
                try
                {
                    string FiledSlection = "Name,Name2,IsMain,IsActive,Last_Modified_Date";
                    string values        = string.Format("N'{0}', N'{1}', '{2}', '{3}',{4}", Name_txt.Text, Name2_txt.Text, IsMain.IsChecked, Active_chbx.IsChecked, "GETDATE()");
                    string Where         = string.Format("Code={0}", Code_txt.Text);
                    Classes.UpdateRow(FiledSlection, values, Where, "Setup_Restaurant");
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
                finally
                {
                    Classes.LogTable(Classes.MyComm.CommandText.ToString(), Code_txt.Text, "Setup_Restaurant", "Update");
                    MainUiFormat();
                    Stores_DGV.DataContext = null;
                    FillDGV();
                }
                MessageBox.Show("Updated Successfully");
            }
        }       //Done
        private void DeleteBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("DeleteUsersAuthentication") == -1 && Authenticated.IndexOf("CheckAllUsersAuthentication") == -1)
            {
                LogIn logIn = new LogIn();    logIn.ShowDialog();
            }
            else
            {
                SqlConnection con = new SqlConnection(Classes.DataConnString);

                try
                {
                    string where = "UserClass_ID = " + UserClassIDtxt.Text;
                    Classes.DeleteRows(where, "UserClass_tbl");
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
                Classes.LogTable(Classes.MyComm.CommandText.ToString(), UserClassIDtxt.Text, "UserClass_tbl", "Delete");
                MessageBox.Show("Deleted Successfully");
            }
        }
Exemple #19
0
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("SaveUsers") == -1 && Authenticated.IndexOf("CheckAllUsers") == -1)
            {
                LogIn logIn = new LogIn();   logIn.ShowDialog();
            }
            else
            {
                if (DoSomeChecks() == false)
                {
                    return;
                }

                for (int i = 0; i < UsersDGV.Items.Count; i++)
                {
                    if (UsersDGV.Items[i].ToString().Equals(userIDtxt.Text))
                    {
                        MessageBox.Show("This Code Is Not Avaliable");    return;
                    }
                }

                try
                {
                    string FiledSelection = "ID,Name,UserName,Password,UserClass_ID,Adress,Mobile,Email,Active,CreateDate,User_ID,WS";
                    string Values         = string.Format("'{0}',N'{1}','{2}','{3}',(select UserClass_ID FROM UserClass_tbl Where Name='{4}'),N'{5}','{6}','{7}','{8}',GETDATE(),'{9}','{10}'", userIDtxt.Text, Nametxt.Text, UserNametxt.Text, passwordtxt.Password, jobTitle.Text, Addresstxt.Text, phone.Text, Mailtxt.Text, Active_chbx.IsChecked.ToString(), MainWindow.UserID, Classes.WS);
                    Classes.InsertRow("Users", FiledSelection, Values);
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
                finally
                {
                    MainUiFormat();
                    Classes.LogTable(Classes.MyComm.CommandText.ToString(), userIDtxt.Text, "Users", "New");
                    UsersDGV.DataContext = null;
                    FillDGV();
                }
                MessageBox.Show("Saved Successfully");
            }
        }
Exemple #20
0
        private void UpdateBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("UpdateVendors") == -1 && Authenticated.IndexOf("CheckAllVendors") == -1)
            {
                LogIn logIn = new LogIn(); logIn.ShowDialog();
            }
            else
            {
                for (int i = 0; i < Vendors_DGV.Items.Count; i++)
                {
                    if ((((DataRowView)Vendors_DGV.Items[i]).Row.ItemArray[1].ToString().Equals(Name_txt.Text)) && (((DataRowView)Vendors_DGV.Items[i]).Row.ItemArray[0].ToString()) != Code_txt.Text)
                    {
                        MessageBox.Show("Please Change The Name"); return;
                    }
                }

                try
                {
                    string FiledSelection = "Name,IsActive,LastModifiedDate";
                    string Values         = string.Format("N'{0}','{1}',GETDATE()", Name_txt.Text, Active_chbx.IsChecked);
                    string Where          = "Code = " + Code_txt.Text;
                    Classes.UpdateRow(FiledSelection, Values, Where, "Vendors");
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
                finally
                {
                    Classes.LogTable(Classes.MyComm.CommandText.ToString(), Code_txt.Text, "Vendors", "Update");
                    MainUiFormat();

                    Vendors_DGV.DataContext = null;
                    FillDGV();
                }
                MessageBox.Show("Updated Successfully");
            }
        }
        private void UpdateBtn_Click(object sender, RoutedEventArgs e)
        {
            string TheCommand = "";

            if (Authenticated.IndexOf("UpdateUsersAuthentication") == -1 && Authenticated.IndexOf("CheckAllUsersAuthentication") == -1)
            {
                LogIn logIn = new LogIn();   logIn.ShowDialog();
            }
            else
            {
                int           length    = 0;
                var           Privilage = new StringBuilder();
                SqlConnection con       = new SqlConnection(Classes.DataConnString);
                if (ListBox_UserPrivileges.IsVisible == true)
                {
                    for (int i = 1; i < ListBox_UserPrivileges.Items.Count; i++)
                    {
                        TreeViewItem TreeName = (ListBox_UserPrivileges.Items[i] as TreeViewItem);
                        if (i != 2)
                        {
                            Privilage.Append((ListBox_UserPrivileges.Items[i] as TreeViewItem).Name);
                            Privilage.Append(":");
                        }
                        for (int j = 0; j < TreeName.Items.Count; j++)
                        {
                            if (TreeName.Items[j].GetType().Name == "CheckBox")
                            {
                                CheckBox valOfCheck = (TreeName.Items[j] as CheckBox);
                                if (valOfCheck.IsChecked == true)
                                {
                                    Privilage.Append((TreeName.Items[j] as CheckBox).Name);
                                    if (j < TreeName.Items.Count - 1)
                                    {
                                        Privilage.Append(",");
                                    }
                                }
                            }
                            else if (TreeName.Items[j].GetType().Name == "ListView")
                            {
                                ListView Listview = (TreeName.Items[j] as ListView);
                                for (int k = 0; k < Listview.Items.Count; k++)
                                {
                                    TreeViewItem SubTreeName = (Listview.Items[k] as TreeViewItem);
                                    Privilage.Append((Listview.Items[k] as TreeViewItem).Name);
                                    Privilage.Append(":");
                                    for (int l = 0; l < SubTreeName.Items.Count; l++)
                                    {
                                        if (SubTreeName.Items[l].GetType().Name == "CheckBox")
                                        {
                                            CheckBox valOfCheck = (SubTreeName.Items[l] as CheckBox);
                                            if (valOfCheck.IsChecked == true)
                                            {
                                                Privilage.Append((SubTreeName.Items[l] as CheckBox).Name);
                                                if (l < SubTreeName.Items.Count - 1)
                                                {
                                                    Privilage.Append(",");
                                                }
                                            }
                                        }
                                    }
                                    length = Privilage.Length - 1;
                                    if (Privilage[length] == ',')
                                    {
                                        Privilage.Remove(length, 1);
                                    }
                                    Privilage.Append(".");
                                }
                                length = Privilage.Length - 1;
                                if (Privilage[length] == ',')
                                {
                                    Privilage.Remove(length, 1);
                                    Privilage.Append(".");
                                }
                            }
                        }
                        length = Privilage.Length - 1;
                        if (Privilage[length] == ',')
                        {
                            Privilage.Remove(length, 1);
                        }
                        if (Privilage[Privilage.Length - 1] != '.')
                        {
                            Privilage.Append(".");
                        }
                    }
                    try
                    {
                        con.Open();
                        string     s       = string.Format("update UserPrivilages_tbl set ClassPrv='{0}', ModifiedDate=GETDATE() where UserClass_ID='{1}'", Privilage, UserClassIDtxt.Text);
                        SqlCommand cmd     = new SqlCommand(s, con);
                        int        IfExist = cmd.ExecuteNonQuery();

                        if (IfExist == 0)
                        {
                            s   = string.Format("insert into UserPrivilages_tbl values ('{0}','{1}',GETDATE(),GETDATE(),'{2}')", UserClassIDtxt.Text, Privilage, MainWindow.UserID);
                            cmd = new SqlCommand(s, con);
                            cmd.ExecuteNonQuery();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    finally
                    {
                        con.Close();
                    }
                }
                try
                {
                    con.Open();

                    TheCommand = "Update UserClass_tbl SET " + "Name = '" + Nametxt.Text + "', Active = '" + Active_chbx.IsChecked + "', ModifiedDate = GETDATE() Where UserClass_ID = " + UserClassIDtxt.Text;
                    SqlCommand cmd = new SqlCommand(TheCommand, con);
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    con.Close();
                }
                Classes.LogTable(TheCommand, UserClassIDtxt.Text, "UserClass_tbl", "Update");
                MessageBox.Show("Updated Successfully");
                LoadUserClasses();
            }
        }