Ejemplo n.º 1
0
        private void insert()
        {
            string where = "Year = '" + Year.Text + "'";
            Classes.DeleteRows(where, "Setup_Fiscal_Period");

            int n = 12;

            if (MonthType_cbx.SelectedIndex == 1)
            {
                n = 13;
            }

            for (int i = 0; i < n; i++)
            {
                DatePicker From   = FindName("from" + (i + 1)) as DatePicker;
                DatePicker To     = FindName("to" + (i + 1)) as DatePicker;
                string     values = "'" + Year.Text + "','" + (i + 1).ToString() + "','" + MonthType_cbx.Text + "','";
                values += Convert.ToDateTime(From.Text) + "','" + Convert.ToDateTime(To.Text).AddHours(23.9999) + "','" + "0'";
                Classes.InsertRow("Setup_Fiscal_Period", values);
            }
            if (!CBCreatedYears.Items.Contains(Year.Text))
            {
                CBCreatedYears.Items.Add(Year.Text);
            }

            MessageBox.Show("Saved");
        }
Ejemplo n.º 2
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");
            }
        }
Ejemplo n.º 3
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;
         }
     }
 }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
        public static void CloseMonth(DataRow DRCurrentMonth)
        {
            try
            {
                cols = "Year varchar(50),Month varchar(50),FromDate datetime,ToDate datetime,Restaurant_ID int,Kitchen_ID int,Item_ID varchar(50),Qty bigint,Cost float";

                Classes.CreateTable("BeginningEndingMonth", cols);

                where = "Month = '" + DRCurrentMonth["Month"].ToString() + "' AND Year = '" + DRCurrentMonth["Year"].ToString() + "'";
                Classes.DeleteRows(where, "BeginningEndingMonth");

                DataTable Items = Classes.RetrieveData("Code", "Setup_Items");

                DataTable DTTop = new DataTable();

                DataTable Kitchens = Classes.RetrieveData("*", "Setup_Kitchens");

                string Dvalues = "('" + DRCurrentMonth["Year"] + "','" + DRCurrentMonth["Month"].ToString() + "','" + Convert.ToDateTime(DRCurrentMonth["From"]).ToString(Classes.sysDateTimeFormat) + "','" + Convert.ToDateTime(DRCurrentMonth["To"]).ToString(Classes.sysDateTimeFormat) + "'";

                foreach (DataRow KitName in Kitchens.Rows)
                {
                    values = "";
                    string Dkitchen = ",'" + KitName["Name"].ToString() + "'";
                    for (int i = 0; i < Items.Rows.Count; i++)
                    {
                        where = " _Date <= '" + Convert.ToDateTime(DRCurrentMonth["To"]).ToString(Classes.sysDateTimeFormat) + "' AND Item_ID = '" + Items.Rows[i][0].ToString() + "' AND KitchenName = '" + KitName["Name"].ToString() + "' order by  _DATE DESC";
                        DTTop = Classes.RetrieveData("top 1 * ", where, "TransActions");

                        if (DTTop.Rows.Count != 0)
                        {
                            Qty  = double.Parse(DTTop.Rows[0]["Current_Qty"].ToString());
                            Cost = double.Parse(DTTop.Rows[0]["CurrentCost"].ToString());
                        }
                        else
                        {
                            Qty  = 0;
                            Cost = 0;
                        }
                        string DQtyCost    = ",'" + Items.Rows[i][0].ToString() + "','" + Qty.ToString() + "','" + Cost.ToString() + "'";
                        string RestKitchen = ",'" + KitName["RestaurantID"].ToString() + "','" + KitName["Code"].ToString() + "'";
                        values += Dvalues + RestKitchen + DQtyCost + "),";
                        if (i % 999 == 0 || i == Items.Rows.Count - 1)
                        {
                            Classes.InsertRow("BeginningEndingMonth", values.Substring(1, values.Length - 3));
                            values = "";
                        }
                    }
                }
                //MessageBox.Show("Month Closed Successfully");
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.ToString());
            }
        }
Ejemplo n.º 6
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
Ejemplo n.º 7
0
        }   //Done

        //

        private void Save_PO_Details(SqlConnection con)
        {
            try
            {
                con.Open();
                string FiledSelection = "PO_Serial,PO_No,Ship_ToRestaurant,Ship_ToKitchen,Vendor_ID,Create_Date,Delivery_Date,WS,Comment,Total_Price,Restaurant_ID,Kitchen_ID,UserID,Status";
                string values         = string.Format("'{0}','{1}',{2},{3},(select Code from Vendors where Name = N'{4}'),GETDATE(),'{5}','{6}',N'{7}','{8}',{9},'{10}','{11}','{12}'", Serial_PO_NO.Text, PO_NO.Text, RestaurantCode, KitchenCode, Vendor.Text, Convert.ToDateTime(Delivery_dt.Text).ToString("MM-dd-yyyy"), Classes.WS, commenttxt.Text, Total_Price_With_Tax.Text, RestaurantCode, KitchenCode, MainWindow.UserID, Statustxt.Text);
                Classes.InsertRow("PO", FiledSelection, values);
            }
            catch (Exception ex)    { MessageBox.Show(ex.ToString()); }
            finally { con.Close(); }
        }   //Done
Ejemplo n.º 8
0
        }                   // Done Finall Function

        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            string Where = string.Format("Parent_Item='{0}'", CodeOfparent);

            Classes.DeleteRows(Where, "Setup_ParentItems");
            for (int i = 0; i < ParentItemsDGV.Items.Count; i++)
            {
                string Values = string.Format("'{0}','{1}'", ((DataRowView)ParentItemsDGV.Items[i]).Row.ItemArray[0], CodeOfparent);
                Classes.InsertRow("Setup_ParentItems", Values);
            }
            MessageBox.Show("Saved Sucsseful");
        }
Ejemplo n.º 9
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
Ejemplo n.º 10
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
Ejemplo n.º 11
0
        }   //Done

        private void Save_PO_Items(SqlConnection con)
        {
            try
            {
                con.Open();
                DataTable Dat = ItemsDGV.DataContext as DataTable;
                for (int i = 0; i < ItemsDGV.Items.Count; i++)
                {
                    string FiledSelection = "Item_ID,PO_Serial,Qty,Unit,Serial,Price_Without_Tax,Tax,Price_With_Tax,Net_Price,Tax_Included";
                    string Values         = "'" + Dat.Rows[i]["Code"] + "','" + Serial_PO_NO.Text + "'," + Dat.Rows[i]["Qty"] + ",N'" + Dat.Rows[i]["Unit"] + "'," + i + "," + Dat.Rows[i]["Unit Price Without Tax"] + "," + Dat.Rows[i]["Tax"].ToString().Substring(0, Dat.Rows[i]["Tax"].ToString().Length - 1) + "," + Dat.Rows[i]["Unit Price With Tax"] + "," + Dat.Rows[i]["Total Price With Tax"] + ",'" + Dat.Rows[i]["Tax Included"].ToString() + "'";
                    Classes.InsertRow("PO_Items", FiledSelection, Values);
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
            finally { con.Close(); }
        }  //Done
Ejemplo n.º 12
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");
            }
        }
Ejemplo n.º 13
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
Ejemplo n.º 14
0
        }           //Done

        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            //Michael's UPdate
            string Where = ""; string Values = "";

            if (CheckToSave() == true)
            {
                Where = string.Format("Item_Code='{0}'", ItemCode);
                Classes.DeleteRows(Where, "Setup_BulkItems");

                for (int i = 0; i < BulkItemsDGV.Items.Count; i++)
                {
                    DataRowView Items = BulkItemsDGV.Items[i] as DataRowView;
                    Values = string.Format("'{0}',{1},{2},'{3}'", Items.Row.ItemArray[0], Items.Row.ItemArray[3], Items.Row.ItemArray[4], ItemCode);
                    Classes.InsertRow("Setup_BulkItems", Values);
                }
                FillDGV(ItemCode);
                MessageBox.Show("Saved Sucssfully");
            }
        }           //Done
Ejemplo n.º 15
0
        private static void Insert(int k)
        {
            values = "";
            cols   = "_DATE,Restaurant_ID,Kitchen_ID,KitchenName,Trantype,ID,Item_ID,Qty,Current_Qty,Cost,CurrentCost";
            string s = "";

            for (int i = 0; i < BETable.Columns.Count; i++)
            {
                if (i == 0)
                {
                    values += s + "'" + Convert.ToDateTime(BETable.Rows[k][i].ToString()).ToString(Classes.sysDateTimeFormat) + "'";
                    s       = ",";
                }
                else
                {
                    values += s + "'" + BETable.Rows[k][i].ToString() + "'";
                    s       = ",";
                }
            }
            Classes.InsertRow("TransActions", cols, values);
        }
Ejemplo n.º 16
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");
            }
        }
        private void SaveThePhyscialAdjacment()
        {
            if (!DoSomeChecks())
            {
                return;
            }

            SqlConnection con = new SqlConnection(Classes.DataConnString);

            con.Open();
            if (Blind == false)
            {
                try
                {
                    string FiledSelection = "Adjacment_ID,Adjacment_Num,Adjacment_Reason,Adjacment_Date,Comment,Resturant_ID,KitchenID,Create_Date,Post_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(),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,Cost";
                        string Values         = string.Format("'{0}','{1}','{2}','{3}'", 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]));
                        Classes.InsertRow("Adjacment_Items", FiledSelection, Values);
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }

                try
                {
                    for (int i = 0; i < ItemsDGV.Items.Count; i++)
                    {
                        string     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[3]), (((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[0]), ValOfResturant, ValOfKitchen, Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[4]));
                        SqlCommand 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[3]), MainWindow.MonthCost, Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[4]), (((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[0]), ValOfResturant, ValOfKitchen, MainWindow.CurrentYear);
                        cmd = new SqlCommand(H, con);
                        cmd.ExecuteNonQuery();
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
                finally
                { MessageBox.Show("Edited Successfully"); }
            }
            else
            {
                try
                {
                    string FiledSelection = "Adjacment_ID,Adjacment_Num,Adjacment_Reason,Adjacment_Date,Comment,Resturant_ID,KitchenID,Create_Date,Post_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(),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";
                        string Values         = string.Format("'{0}','{1}','{2}','{3}','{4}','{5}'", Serial_Adjacment_NO.Text, (((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[0]), Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[3]), ((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[4], ((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[5], Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[6]));
                        Classes.InsertRow("Adjacment_Items", FiledSelection, Values);
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }

                try
                {
                    for (int i = 0; i < ItemsDGV.Items.Count; i++)
                    {
                        string     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]));
                        SqlCommand 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();
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }
                finally
                { MessageBox.Show("Edited Successfully"); }
            }

            try
            {
                string     s   = string.Format("update PhysicalInventory_tbl set Inventory_Type='Closed' where Inventory_ID={0}", physicalinventoryID);
                SqlCommand cmd = new SqlCommand(s, con);
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
Ejemplo n.º 18
0
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("SaveKitchens") == -1 && Authenticated.IndexOf("CheckAllKitchens") == -1)
            {
                LogIn logIn = new LogIn();
                logIn.ShowDialog();
            }
            else
            {
                SqlConnection con  = new SqlConnection(Classes.DataConnString);
                SqlConnection con2 = new SqlConnection(Classes.DataConnString);
                DataTable     DT   = new DataTable();
                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)
                {
                    con.Open();
                    string     s   = string.Format("select IsMain from Setup_Kitchens where IsMain='True' and RestaurantID='{0}'", ResturantCode);
                    SqlCommand cmd = new SqlCommand(s, con);
                    if (cmd.ExecuteScalar() != null)
                    {
                        MessageBox.Show("Can't be more Than Main Kitchen !");
                        return;
                    }
                }

                try
                {
                    string FiledSelection = "Code,Name,Name2,IsMain,IsOutlet,IsActive,RestaurantID,Create_Date,WS,UserID";
                    string values         = string.Format("'{0}', N'{1}', N'{2}', '{3}','{4}','{5}','{6}',{7},'{8}','{9}'", Code_txt.Text, Name_txt.Text, Name2_txt.Text, IsMain.IsChecked, IsOutlet.IsChecked, Active_chbx.IsChecked, ResturantCode, "GETDATE()", Classes.WS, MainWindow.UserID);
                    Classes.InsertRow("Setup_Kitchens", FiledSelection, values);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    con.Close();
                    MainUiFormat();

                    Stores_DGV.DataContext = null;
                    FillDGV(ResturantCode);
                }
                if (IsMain.IsChecked == true || IsOutlet.IsChecked == true)
                {
                    string FiledSelectionKitchenItems = "KitchenID,ItemID,RestaurantID,MinQty,MaxQty,shulfID";
                    string FiledSelectionItems = "KitchenID,ItemID,RestaurantID,Qty,Units,Last_Cost,Current_Cost,Net_Cost";
                    string FiledSelectionItemsYear = "ItemID,Restaurant_ID,Kitchen_ID,Year";
                    string valuesItems = ""; string ValuesKitchenItems = ""; string ValuesItemsYear = ""; string Comma = "";
                    try
                    {
                        DT = Classes.RetrieveData("Code", "Setup_Items");
                        int NumOfItemsPerRec = DT.Rows.Count % 1000;
                        int NumOfItems       = 0;
                        if (DT.Rows.Count > 0)
                        {
                            if (DT.Rows.Count > 1000)
                            {
                                for (int i = 0; i <= NumOfItemsPerRec; i++)
                                {
                                    for (int q = NumOfItems; q < (i + 1) * 1000; q++)
                                    {
                                        ValuesKitchenItems = Comma + string.Format("('{0}','{1}','{2}','0','0','0')", Code_txt.Text, DT.Rows[q].ItemArray[0], ResturantCode);
                                        valuesItems        = Comma + string.Format("('{0}','{1}','{2}','0','','','0','')", Code_txt.Text, DT.Rows[q].ItemArray[0], ResturantCode);
                                        ValuesItemsYear    = Comma + string.Format("('{0}','{1}','{2}','{3}')", DT.Rows[q].ItemArray[0], ResturantCode, Code_txt.Text, MainWindow.CurrentYear);
                                        Comma = ",";
                                    }
                                    NumOfItems = (i + 1) * 1000;
                                }
                                Classes.InsertRows("Setup_KitchenItems", FiledSelectionKitchenItems, ValuesKitchenItems);
                                Classes.InsertRows("ItemsYear", FiledSelectionItemsYear, ValuesItemsYear);
                                Classes.InsertRows("Items", FiledSelectionItems, valuesItems);
                            }
                            else
                            {
                                for (int i = 0; i < DT.Rows.Count; i++)
                                {
                                    ValuesKitchenItems += Comma + string.Format("('{0}','{1}','{2}','0','0','0')", Code_txt.Text, DT.Rows[i].ItemArray[0], ResturantCode);
                                    valuesItems        += Comma + string.Format("('{0}','{1}','{2}','0','','','','')", Code_txt.Text, DT.Rows[i].ItemArray[0], ResturantCode);
                                    ValuesItemsYear    += Comma + string.Format("('{0}','{1}','{2}','{3}')", DT.Rows[i].ItemArray[0], ResturantCode, Code_txt.Text, MainWindow.CurrentYear);
                                    Comma = ",";
                                }
                                Classes.InsertRows("Setup_KitchenItems", FiledSelectionKitchenItems, ValuesKitchenItems);
                                Classes.InsertRows("ItemsYear", FiledSelectionItemsYear, ValuesItemsYear);
                                Classes.InsertRows("Items", FiledSelectionItems, valuesItems);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    finally
                    {
                        con.Close();
                        con2.Close();
                    }
                }
                MessageBox.Show("Saved Successfully");
            }
        }
Ejemplo n.º 19
0
        }       //Done Finall Function

        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            RecipeItems = RecipesDGV.DataContext as DataTable;
            if (Authenticated.IndexOf("SaveRecipes") == -1 && Authenticated.IndexOf("CheckAllRecipes") == -1)
            {
                LogIn logIn = new LogIn(); logIn.ShowDialog();
            }
            else
            {
                if (codetxt.Text == "")
                {
                    MessageBox.Show("Code Field Can't Be Empty"); return;
                }
                if (Nametxt.Text == "")
                {
                    MessageBox.Show("Name Field Can't Be Empty"); return;
                }
                if (Categtxt.Text == "")
                {
                    MessageBox.Show("Should Enter the Category First"); return;
                }
                if (SUBCategtxt.Text == "")
                {
                    MessageBox.Show("Should Enter the Sub Category First"); return;
                }
                if (Unittxt.Text == "")
                {
                    MessageBox.Show("Should Enter the Unites First"); return;
                }
                if (Unitstxt.Text == "")
                {
                    MessageBox.Show("Should Select the Unites First"); return;
                }

                DataTable CheckCode = new DataTable();
                string    Where     = string.Format("Code='{0}'", codetxt.Text);
                CheckCode = Classes.RetrieveData("Code", Where, "Setup_Recipes");
                if (CheckCode.Rows.Count != 0)
                {
                    MessageBox.Show("This Code Is Not Avaliable"); return;
                }

                DataTable NameofRecipe = new DataTable();
                Where        = string.Format("Name=N'{0}'", Nametxt.Text);
                NameofRecipe = Classes.RetrieveData("Name", Where, "Setup_Recipes");
                if (NameofRecipe.Rows.Count != 0)
                {
                    MessageBox.Show("You Entered This Recipe Name Before");
                    return;
                }

                try
                {
                    string FiledSelection = "Code,CrossCode,Name,Name2,Category_ID,SubCategory_ID,IsActive,Unit,UnitQty,CreateDate,UserID,WS";
                    string Values         = string.Format("'{0}','{1}',N'{2}',N'{3}','{4}','{5}','{6}',N'{7}','{8}',GETDATE(),'{9}','{10}'", codetxt.Text, CrossCodetxt.Text, Nametxt.Text, Name2txt.Text, Categtxt.Text, SUBCategtxt.Text, ActiveChbx.IsChecked, Unitstxt.Text, Unittxt.Text, MainWindow.UserID, Classes.WS);
                    Classes.InsertRow("Setup_Recipes", FiledSelection, Values);
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }


                try
                {
                    for (int i = 0; i < RecipesDGV.Items.Count; i++)
                    {
                        string FiledSelection = "Item_Code,Recipe_ID,Qty,Recipe_Unit,Recipe_Code";
                        string Values         = string.Format("'{0}','{1}','{2}',N'{3}','{4}'", RecipeItems.Rows[i]["Item_Code"], RecipeItems.Rows[i]["Recipe_Code"], RecipeItems.Rows[i]["Qty"], RecipeItems.Rows[i]["Recipe_Unit"], codetxt.Text);
                        Classes.InsertRow("Setup_RecipeItems", FiledSelection, Values);
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }

                MainUiFormat();
                EmptyTexts();
                SaveBtn.IsEnabled    = false;
                ActiveChbx.IsChecked = false;
                loadAllRecipes();
                MessageBox.Show("Saved Successfully");
            }
        }       //Done Finall Function
Ejemplo n.º 20
0
        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();
            }
        }
Ejemplo n.º 21
0
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            RecipeItems = RecipesDGV.DataContext as DataTable;
            if (Authenticated.IndexOf("SaveRecipes") == -1 && Authenticated.IndexOf("CheckAllRecipes") == -1)
            {
                LogIn logIn = new LogIn();  logIn.ShowDialog();
            }
            else
            {
                if (codetxt.Text == "")
                {
                    MessageBox.Show("Code Field Can't Be Empty");  return;
                }
                if (Nametxt.Text == "")
                {
                    MessageBox.Show("Name Field Can't Be Empty");  return;
                }
                if (Categtxt.Text == "")
                {
                    MessageBox.Show("Should Enter the Category First");  return;
                }
                if (SUBCategtxt.Text == "")
                {
                    MessageBox.Show("Should Enter the Sub Category First");   return;
                }
                if (Unittxt.Text == "")
                {
                    MessageBox.Show("Should Enter the Unites First");  return;
                }
                if (Unitstxt.Text == "")
                {
                    MessageBox.Show("Should Select the Unites First");   return;
                }

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

                try
                {
                    string FiledSelection = "Code,CrossCode,Name,Name2,Category_ID,SubCategory_ID,IsActive,Unit,UnitQty,CreateDate,UserID,WS";
                    string Values         = string.Format("'{0}','{1}',N'{2}',N'{3}','{4}','{5}','{6}','{7}','{8}',GETDATE(),'{9}','{10}'", codetxt.Text, CrossCodetxt.Text, Nametxt.Text, Name2txt.Text, Categtxt.Text, SUBCategtxt.Text, ActiveChbx.IsChecked, Unitstxt.Text, Unittxt.Text, MainWindow.UserID, Classes.WS);
                    Classes.InsertRow("Setup_Recipes", FiledSelection, Values);
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }


                try
                {
                    for (int i = 0; i < RecipesDGV.Items.Count; i++)
                    {
                        string FiledSelection = "Item_Code,Recipe_ID,Qty,Recipe_Unit,Cost,Total_Cost,Cost_Precentage,Recipe_Code";
                        string Values         = string.Format("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}'", RecipeItems.Rows[i]["Item_Code"], RecipeItems.Rows[i]["Recipe_ID"], RecipeItems.Rows[i]["Qty"], RecipeItems.Rows[i]["Recipe_Unit"], RecipeItems.Rows[i]["Cost"], RecipeItems.Rows[i]["Total_Cost"], RecipeItems.Rows[i]["Cost_Precentage"], RecipeItems.Rows[i]["Recipe_Code"]);
                        Classes.InsertRow("Setup_RecipeItems", FiledSelection, Values);
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.ToString()); }

                MainUiFormat();
                EmptyTexts();
                SaveBtn.IsEnabled    = false;
                ActiveChbx.IsChecked = false;
                MessageBox.Show("Saved Successfully");
            }
        }
Ejemplo n.º 22
0
        }          //Done

        private void SaveInfoANdData()
        {
            try
            {
                string    FiledSelected = ""; string Value = "";
                DataTable IfOpend = new DataTable();
                string    Where   = string.Format("Inventory_Type='Open' and  Resturant_ID={0} and KitchenID={1}", ValOfResturant, ValOfKitchen);
                IfOpend = Classes.RetrieveData("Blind", Where, "PhysicalInventory_tbl");
                if (IfOpend.Rows.Count > 0)
                {
                    if (IfOpend.Rows[0][0].ToString() == "True")
                    {
                        for (int i = 0; i < ItemsDGV.Items.Count; i++)
                        {
                            FiledSelected = "Qty,InventoryQty,Variance";
                            Value         = string.Format("{0},{1},{2}", 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]));
                            Where         = string.Format("Inventory_ID='{0}' and Item_ID='{1}'", Serial_Inventory_NO.Text, (((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[0]));
                            Classes.UpdateRow(FiledSelected, Value, Where, "PhysicalInventory_Items");
                        }
                    }
                    else
                    {
                        for (int i = 0; i < ItemsDGV.Items.Count; i++)
                        {
                            FiledSelected = "Qty";
                            Value         = string.Format("{0}", Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[3]));
                            Where         = string.Format("Inventory_ID='{0}' and Item_ID='{1}'", Serial_Inventory_NO.Text, (((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[0]));
                            Classes.UpdateRow(FiledSelected, Value, Where, "PhysicalInventory_Items");
                        }
                    }
                    FiledSelected = "Inventory_Num,Inventory_Date,Comment";
                    Value         = string.Format("'{0}','{1}','{2}'", Inventory_NO.Text, Convert.ToDateTime(InventoryDate.Text).ToString("MM-dd-yyyy"), commenttxt.Text);
                    Where         = string.Format("Inventory_ID='{0}'", Serial_Inventory_NO.Text);
                    Classes.UpdateRow(FiledSelected, Value, Where, "PhysicalInventory_tbl");
                }
                else
                {
                    if (NotBlindChx.IsChecked == true)
                    {
                        for (int i = 0; i < ItemsDGV.Items.Count; i++)
                        {
                            FiledSelected = "Inventory_ID,Item_ID,Qty,InventoryQty,Variance,Cost";
                            Value         = string.Format("'{0}','{1}',{2},'{3}','{4}',{5}", Serial_Inventory_NO.Text, (((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[0]), Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[3]), ((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[4], ((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[5], Convert.ToDouble(((DataRowView)ItemsDGV.Items[i]).Row.ItemArray[6]));
                            Classes.InsertRow("PhysicalInventory_Items", FiledSelected, Value);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < ItemsDGV.Items.Count; i++)
                        {
                            FiledSelected = "Inventory_ID,Item_ID,Qty,Cost";
                            Value         = string.Format("'{0}','{1}',{2},{3}", Serial_Inventory_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]));
                            Classes.InsertRow("PhysicalInventory_Items", FiledSelected, Value);
                        }
                    }
                    FiledSelected = "Inventory_ID,Inventory_Num,Inventory_Type,Inventory_Date,Comment,Resturant_ID,KitchenID,Post_Date,UserID,Blind,WS,Create_Date";
                    Value         = string.Format("'{0}',{1},'{2}','{3}','{4}',{5},{6},GETDATE(),'{7}','{8}','{9}',GETDATE()", Serial_Inventory_NO.Text, Inventory_NO.Text, Typecbx.Text, Convert.ToDateTime(InventoryDate.Text).ToString("MM-dd-yyyy"), commenttxt.Text, ValOfResturant, ValOfKitchen, MainWindow.UserID, NotBlindChx.IsChecked, Classes.WS);
                    Classes.InsertRow("PhysicalInventory_tbl", FiledSelected, Value);
                }
                MessageBox.Show("The inventory Saved Sucessfully !");
            }
            catch { }
        }