private void SaveSubBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("SaveRecipeSubCategory") == -1 && Authenticated.IndexOf("CheckAllRecipeCategory") == -1)
            {
                LogIn logIn = new LogIn();
                logIn.ShowDialog();
            }
            else
            {
                int val = 0;
                if (CodeSub_txt.Text == "")
                {
                    MessageBox.Show("Code Field Can't Be Empty");
                    return;
                }
                if (Categorycbx.Text == "")
                {
                    MessageBox.Show("Category Field Can't Be Empty");
                    return;
                }

                for (int i = 0; i < SubCategoryDGV.Items.Count; i++)
                {
                    if (CodeSub_txt.Text == ((DataRowView)SubCategoryDGV.Items[i]).Row.ItemArray[0].ToString())
                    {
                        MessageBox.Show("This Code Is Not Avaliable");
                        return;
                    }
                }


                SqlConnection con = new SqlConnection(Classes.DataConnString);
                try
                {
                    string s = "Select Code From Setup_RecipeCategory Where Name=N'" + Categorycbx.Text + "'";
                    con.Open();
                    SqlCommand cmd = new SqlCommand(s, con);
                    val = int.Parse(cmd.ExecuteScalar().ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    con.Close();
                }

                try
                {
                    con.Open();
                    string     q   = "Insert into Setup_RecipeSubCategories (Code,Name,Name2,IsActive,Category_ID) values (" + CodeSub_txt.Text + ",N'" + NameSub_txt.Text + "',N'" + Name2Sub_txt.Text + "','" + ActiveSub_chbx.IsChecked + "','" + val + "')";
                    SqlCommand cmd = new SqlCommand(q, con);

                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    con.Close();
                    MainUiSubFormat();
                    SubCategoryDGV.DataContext = null;
                    FillSubDGV();
                }
                MessageBox.Show("Saved Successfully");
            }
        }
        private void UpdateSubBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("UpdateRecipeSubCategory") == -1 && Authenticated.IndexOf("CheckAllRecipeCategory") == -1)
            {
                LogIn logIn = new LogIn();
                logIn.ShowDialog();
            }
            else
            {
                int           val = 0;
                SqlConnection con = new SqlConnection(Classes.DataConnString);

                try
                {
                    string s = "Select Code From Setup_RecipeCategory Where Name=N'" + Categorycbx.Text + "'";
                    con.Open();
                    SqlCommand cmd = new SqlCommand(s, con);
                    val = int.Parse(cmd.ExecuteScalar().ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    con.Close();
                }

                try
                {
                    con.Open();
                    string q = "Update Setup_RecipeSubCategories SET Name=N'" + NameSub_txt.Text +
                               "',Name2=N'" + Name2Sub_txt.Text +
                               "',IsActive='" + ActiveSub_chbx.IsChecked +
                               "',Category_ID='" + val +
                               "' Where Code =" + CodeSub_txt.Text;;

                    SqlCommand cmd = new SqlCommand(q, con);
                    //SqlCommand cmd = new SqlCommand("UpdateSetup_SubCategory", con);
                    //cmd.CommandType = CommandType.StoredProcedure;
                    //cmd.Parameters.AddWithValue("@Code", CodeSub_txt.Text);
                    //cmd.Parameters.AddWithValue("@Name", NameSub_txt.Text);
                    //cmd.Parameters.AddWithValue("@Name2", Name2Sub_txt.Text);
                    //cmd.Parameters.AddWithValue("@IsActive", ActiveSub_chbx.IsChecked);
                    //cmd.Parameters.AddWithValue("@Category", val);

                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    con.Close();
                    MainUiSubFormat();

                    SubCategoryDGV.DataContext = null;
                    FillSubDGV();
                }
                MessageBox.Show("Updated Successfully");
            }
        }
        private void DeleteBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("DeleteRecipeCatgoey") == -1 && Authenticated.IndexOf("CheckAllRecipeCategory") == -1)
            {
                LogIn logIn = new LogIn();
                logIn.ShowDialog();
            }
            else
            {
                string        checkRecipe = ""; string checkSubCat = "";
                SqlConnection con = new SqlConnection(Classes.DataConnString);
                try
                {
                    con.Open();
                    string     s   = "SELECT Category_ID FROM Setup_Recipes Where Category_ID=" + Code_txt.Text;
                    SqlCommand cmd = new SqlCommand(s, con);
                    if (cmd.ExecuteScalar() != null)
                    {
                        checkRecipe = cmd.ExecuteScalar().ToString();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    con.Close();
                }

                try
                {
                    con.Open();
                    string     s   = "SELECT Category_ID FROM Setup_RecipeSubCategories Where Category_ID=" + Code_txt.Text;
                    SqlCommand cmd = new SqlCommand(s, con);
                    if (cmd.ExecuteScalar() != null)
                    {
                        checkSubCat = cmd.ExecuteScalar().ToString();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    con.Close();
                }

                if (checkRecipe != Code_txt.Text && checkSubCat != Code_txt.Text)
                {
                    try
                    {
                        con.Open();
                        string     s   = "Delete Setup_RecipeCategory Where Code =" + Code_txt.Text;
                        SqlCommand cmd = new SqlCommand(s, con);
                        cmd.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    finally
                    {
                        con.Close();
                        MainUiFormat();

                        CategoryDGV.DataContext = null;
                        FillDGV();
                    }
                    MessageBox.Show("Deleted Successfully");
                }
                else
                {
                    MessageBox.Show("Can't Delete this Category");
                    checkRecipe = "";
                    checkSubCat = "";
                }
            }
        }
示例#4
0
        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();
            }
        }
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("SaveKitchenItems") == -1 && Authenticated.IndexOf("CheckAllKitchenItems") == -1)
            {
                LogIn logIn = new LogIn();
                logIn.ShowDialog();
            }
            else
            {
                SqlConnection con = new SqlConnection(Classes.DataConnString);
                DataTable     DT  = new DataTable();
                DT = ItemsDGV.DataContext as DataTable;
                for (int i = 0; i < DT.Rows.Count; i++)
                {
                    if (DT.Rows[i].ItemArray.Contains(""))
                    {
                        MessageBox.Show(string.Format("item {0} has empty fields", DT.Rows[i].ItemArray[2]));
                        return;
                    }
                }
                con.Open();
                for (int i = 0; i < DT.Rows.Count; i++)
                {
                    string     s   = string.Format("update Setup_KitchenItems set shulfID='{0}',MinQty='{1}',MaxQty='{2}',Last_Modified_Date=GETDATE() where ItemID='{3}' and RestaurantID={4} and KitchenID={5}", DT.Rows[i]["Shelf"], DT.Rows[i]["Min Qty"], DT.Rows[i]["Max Qty"], DT.Rows[i]["Code"], ValOfResturant, ValOfKitchen);
                    SqlCommand cmd = new SqlCommand(s, con);
                    int        n   = cmd.ExecuteNonQuery();

                    if (n == 0)
                    {
                        string    WhereFiltering = string.Format("RestaurantID='{0}' and KitchenID='{1}' and ItemID='{2}'", ValOfResturant, ValOfKitchen, DT.Rows[i]["Code"]);
                        DataTable Table          = Classes.RetrieveData("ItemID", WhereFiltering, "Setup_KitchenItems");
                        if (Table.Rows.Count == 0)
                        {
                            string FiledSelection = "RestaurantID,KitchenID,ItemID,ShulfID,MinQty,MaxQty,Create_Date,WS,UserID";
                            string Values         = string.Format("'{0}','{1}','{2}','{3}','{4}','{5}',GETDATE(),'{6}','{7}'", ValOfResturant, ValOfKitchen, DT.Rows[i]["Code"], DT.Rows[i]["Shelf"], DT.Rows[i]["Min Qty"], DT.Rows[i]["Max Qty"], Classes.WS, MainWindow.UserID);
                            Classes.InsertRow("Setup_KitchenItems", FiledSelection, Values);
                        }

                        WhereFiltering = string.Format("RestaurantID='{0}' and KitchenID='{1}' and ItemID='{2}'", ValOfResturant, ValOfKitchen, DT.Rows[i]["Code"]);
                        Table          = Classes.RetrieveData("ItemID", WhereFiltering, "Items");
                        if (Table.Rows.Count == 0)
                        {
                            string FiledSelection = "KitchenID,ItemID,RestaurantID,Qty,Units,Last_Cost,Current_Cost,Net_Cost";
                            string Values         = string.Format("'{0}','{1}','{2}','0','','','0',''", ValOfKitchen, DT.Rows[i]["Code"], ValOfResturant);
                            Classes.InsertRow("Items", FiledSelection, Values);
                        }

                        WhereFiltering = string.Format("Restaurant_ID='{0}' and Kitchen_ID='{1}' and ItemID='{2}' and Year='{3}'", ValOfResturant, ValOfKitchen, DT.Rows[i]["Code"], MainWindow.CurrentYear);
                        Table          = Classes.RetrieveData("ItemID", WhereFiltering, "ItemsYear");
                        if (Table.Rows.Count == 0)
                        {
                            string FiledSelection = "ItemID,Restaurant_ID,Kitchen_ID,Year";
                            string Values         = string.Format("'{0}','{1}','{2}','{3}'", DT.Rows[i]["Code"], ValOfResturant, ValOfKitchen, MainWindow.CurrentYear);
                            Classes.InsertRow("ItemsYear", FiledSelection, Values);
                        }
                    }
                }

                con.Close();
                MessageBox.Show("Items saved successfuly");
                SaveBtn.IsEnabled = false;
                LoadDatatoGrid();
            }
        }
        private void BulkItemsBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("DoProcessBulk") == -1 && Authenticated.IndexOf("CheckAllBulk") == -1)
            {
                LogIn logIn = new LogIn(); logIn.ShowDialog();
            }
            else
            {
                string        ID = Classes.InCrementTransactionSerial("Process_BulkItems", "ProcessBulk_ID");
                string        BaseCode = ""; string BaseQty = ""; string SUBQty = ""; double BaseCost = 0; string BaseWeight = "";  double CalcQty = 0; double CalcCost = 0;
                SqlConnection con    = new SqlConnection(Classes.DataConnString);
                SqlCommand    cmd    = new SqlCommand();
                SqlConnection con2   = new SqlConnection(Classes.DataConnString);
                SqlCommand    cmd2   = new SqlCommand();
                SqlDataReader reader = null;
                for (int i = 0; i < ItemsDGV.Items.Count; i++)
                {
                    if (((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[0].ToString() == "True")
                    {
                        BaseCode   = ((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[1].ToString();
                        BaseQty    = ((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[4].ToString();
                        SUBQty     = BaseQty;
                        BaseCost   = Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[6].ToString());
                        BaseWeight = (Classes.RetrieveData("Weight", "Code=" + BaseCode, "Setup_Items")).Rows[0][0].ToString();
                        con.Open();
                        try
                        {
                            string s = string.Format("select * from Setup_BulkItems where Item_Code='{0}'", BaseCode);
                            cmd    = new SqlCommand(s, con);
                            reader = cmd.ExecuteReader();
                            while (reader.Read())
                            {
                                CalcQty  = (((Convert.ToDouble(reader["WeightPrecentage"]) / 100) * Convert.ToDouble(BaseQty)) / Convert.ToDouble(BaseWeight));
                                CalcCost = (((Convert.ToDouble(reader["CostPrecentage"]) / 100) * Convert.ToDouble(BaseCost)) / Convert.ToDouble(BaseWeight));
                                try
                                {
                                    con2.Open();
                                    string w = string.Format("UPDATE Items set Qty=Qty+{0},Last_Cost=Current_Cost,Current_Cost=(((Qty*Current_Cost)+({0}*{4}))/(Qty+{0})) where ItemID='{1}' and RestaurantID={2} and KitchenID={3}", CalcQty, reader["Code"], CodeOfResturant, CodeOfKitchens, CalcCost);
                                    cmd2 = new SqlCommand(w, con2);
                                    int n = cmd2.ExecuteNonQuery();
                                    if (n == 0)
                                    {
                                        w    = string.Format("insert into Items(RestaurantID,KitchenID,ItemID,Qty,Current_Cost,Net_Cost) values({0},{1},'{2}',{3},{4},{5})", CodeOfResturant, CodeOfKitchens, reader["Code"], CalcQty, CalcCost, CalcCost * CalcQty);
                                        cmd2 = new SqlCommand(w, con2);
                                        cmd2.ExecuteNonQuery();
                                    }

                                    w    = string.Format("Update ItemsYear set {0}={0}+{2},{1}=(({0}*{1})+({2}*{3})/({0}+{1})) where ItemID='{4}' and Restaurant_ID='{5}' and Kitchen_ID='{6}' and Year='{7}'", MainWindow.MonthQty, MainWindow.MonthCost, CalcQty, CalcCost, reader["Code"], CodeOfResturant, CodeOfKitchens, MainWindow.CurrentYear);
                                    cmd2 = new SqlCommand(w, con2);
                                    n    = cmd2.ExecuteNonQuery();
                                    if (n == 0)
                                    {
                                        w    = string.Format("insert into ItemsYear(ItemID,Restaurant_ID,Kitchen_ID,Year,{0},{1}) values('{2}','{3}','{4}','{5}',{6},{7})", MainWindow.MonthQty, MainWindow.MonthCost, reader["Code"], CodeOfResturant, CodeOfKitchens, MainWindow.CurrentYear, CalcQty, CalcCost);
                                        cmd2 = new SqlCommand(w, con2);
                                        cmd2.ExecuteNonQuery();
                                    }
                                }
                                catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                                SUBQty = (Convert.ToDouble(SUBQty) - CalcQty).ToString();

                                try
                                {
                                    string w = string.Format("insert into Process_BulkItems_Items(ProcessBulk_ID,ParentItem_ID,ParentQty,ParentCost,ChiledItem_ID,ChiledQty,ChiledCost) values('{0}','{1}',{2},{3},{4},{5},{6})", ID, BaseCode, ((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[4].ToString(), ((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[6].ToString(), reader["Code"], BaseCost, BaseCost);
                                    cmd2 = new SqlCommand(w, con2);
                                    cmd2.ExecuteNonQuery();
                                }
                                catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                                con2.Close();
                            }
                            try
                            {
                                con2.Open();
                                string w = string.Format("update Items set Qty={0} where RestaurantID={1} and KitchenID={2} and ItemID='{3}' ", SUBQty, CodeOfResturant, CodeOfKitchens, BaseCode);
                                cmd2 = new SqlCommand(w, con2);
                                cmd2.ExecuteNonQuery();
                            }
                            catch (Exception ex) { MessageBox.Show(ex.ToString()); }

                            try
                            {
                                string w = string.Format("update ItemsYear set {0}={1} Where ItemID='{2}' and Restaurant_ID='{3}' and Kitchen_ID='{4}' and Year='{5}'", MainWindow.MonthQty, SUBQty, BaseCode, CodeOfResturant, CodeOfKitchens, MainWindow.CurrentYear);
                                cmd2 = new SqlCommand(w, con2);
                                cmd2.ExecuteNonQuery();
                            }
                            catch (Exception ex) { MessageBox.Show(ex.ToString()); }

                            try
                            {
                                string w = string.Format("insert into Process_BulkItems(ProcessBulk_ID,Process_Date,User_ID,Resturant_ID,KitchenID,Post_Date) values('{0}',GETDATE(),'{1}',{2},{3},GETDATE())", ID, MainWindow.UserID, CodeOfResturant, CodeOfKitchens);
                                cmd2 = new SqlCommand(w, con2);
                                cmd2.ExecuteNonQuery();
                            }
                            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
                        }
                        catch (Exception ex)
                        { MessageBox.Show(ex.ToString()); }
                        con2.Close();
                    }
                }
                MessageBox.Show("Done");
            }
            BulkItems.IsEnabled = false;
        }
示例#7
0
        }           //Done

        private void Adjact_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("AdjacmentAdjacment") == -1 && Authenticated.IndexOf("CheckAllAddjacment") == -1)
            {
                LogIn logIn = new LogIn(); logIn.ShowDialog();
            }
            else
            {
                if (Reasoncbx.Text != "Physical Inventory")
                {
                    if (!DoSomeChecks())
                    {
                        return;
                    }

                    Save_Changes();
                    SqlConnection con = new SqlConnection(Classes.DataConnString);
                    con.Open();
                    try
                    {
                        string     H   = string.Format("Update Adjacment_tbl set Post='True' where Adjacment_ID = '{0}'", Serial_Adjacment_NO.Text);
                        SqlCommand cmd = new SqlCommand(H, con);
                        cmd.ExecuteNonQuery();

                        for (int i = 0; i < ItemsDGV.Items.Count; i++)
                        {
                            if ((bool)((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[9] == false)
                            {
                                H   = string.Format("Update Items set Qty={0}, Current_Cost={4}, Net_Cost=({4} * {0}) where ItemID = '{1}' and RestaurantID ={2} and KitchenID={3}", Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[4]), (((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[0]), ValOfResturant, ValOfKitchen, Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[6]));
                                cmd = new SqlCommand(H, con);
                                cmd.ExecuteNonQuery();

                                H   = string.Format("update ItemsYear set {0}={1},{2}={3} where ItemID='{4}' and Restaurant_ID='{5}' and Kitchen_ID='{6}' and Year='{7}'", MainWindow.MonthQty, Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[4]), MainWindow.MonthCost, Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[6]), (((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[0]), ValOfResturant, ValOfKitchen, MainWindow.CurrentYear);
                                cmd = new SqlCommand(H, con);
                                cmd.ExecuteNonQuery();
                            }
                            else
                            {
                                H   = string.Format("Update RecipeQty set Qty={0}, Price={4} where Recipe_ID = '{1}' and Resturant_ID ={2} and Kitchen_ID={3}", Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[4]), (((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[0]), ValOfResturant, ValOfKitchen, Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[6]));
                                cmd = new SqlCommand(H, con);
                                cmd.ExecuteNonQuery();
                            }
                        }
                        con.Close();
                    }
                    catch (Exception ex)
                    { MessageBox.Show(ex.ToString()); }
                    finally
                    { MessageBox.Show("Edited Successfully"); }
                }
                else
                {
                    SaveThePhyscialAdjacment();
                }
                Adjact.IsEnabled        = false;
                searchBtn.IsEnabled     = false;
                addItemBtn.IsEnabled    = false;
                RemoveItemBtn.IsEnabled = false;
                SaveBtn.IsEnabled       = false;
                addRecipeBtn.IsEnabled  = false;
            }
        }           //DOne