Exemple #1
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 #2
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");
            }
        }
        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");
        }
Exemple #4
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());
            }
        }
        }                   // 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");
        }
Exemple #6
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 #7
0
        }   //Done

        private void UndoBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DataTable DT    = new DataTable();
                string    Where = string.Format("Inventory_Type='Open' and Resturant_ID={0} and KitchenID={1}", ValOfResturant, ValOfKitchen);
                DT = Classes.RetrieveData("Inventory_ID", Where, "PhysicalInventory_tbl");
                if (DT.Rows.Count == 0)
                {
                    Where = string.Format("Resturant_ID={0} and Kitchen_ID={1}", ValOfResturant, ValOfKitchen);
                    Classes.DeleteRows(Where, "PhysicalInventory_QtyOnHand");
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
            clearData();
            InventoryChose.Visibility = Visibility.Visible;
            InventoryInfo.Visibility  = Visibility.Hidden;
        }
Exemple #8
0
        }           //Done

        private void TransferBtn_Click(object sender, RoutedEventArgs e)
        {
            if (Authenticated.IndexOf("TransferTrnsferResturant") == -1 && Authenticated.IndexOf("CheckAllTransferResturant") == -1)
            {
                LogIn logIn = new LogIn();   logIn.ShowDialog();
            }
            else
            {
                if (!DoSomeChecks())
                {
                    return;
                }

                try
                {
                    string    WhereFiltering = string.Format("Transfer_Serial='{0}'", transfer_No.Text);
                    DataTable TheSerial      = Classes.RetrieveData("Transfer_Serial", WhereFiltering, "Transfer_Kitchens");
                    if (TheSerial.Rows.Count == 0)
                    {
                        Save_TIK_Items();
                        Save_TIK();
                        MessageBox.Show("Transfer saved Sucssfully");
                        MainGrid.IsEnabled    = false;
                        TransferBtn.IsEnabled = false;
                        NewBtn.IsEnabled      = true;
                    }
                    else
                    {
                        string where = "Transfer_ID = " + transfer_No.Text;
                        Classes.DeleteRows(where, "Transfer_Kitchens_Items");
                        Edit_TIK_Items();
                        Edit_TIK();
                        MessageBox.Show("Transfer Edited Sussesfully");
                        MainGrid.IsEnabled    = false;
                        TransferBtn.IsEnabled = false;
                        NewBtn.IsEnabled      = true;
                    }
                }
                catch { }
                ClearData();
                addItemBtn.IsEnabled    = false;
                addRecipesBtn.IsEnabled = false;
            }
        }               //Done
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            BtnNew.IsEnabled         = true;
            CBCreatedYears.IsEnabled = true;
            BtnExit.IsEnabled        = true;
            BtnEdit.IsEnabled        = false;
            BtnSave.IsEnabled        = false;
            BtnDelete.IsEnabled      = false;
            BtnUndo.IsEnabled        = false;
            MonthType_cbx.IsEnabled  = false;
            Year.IsEnabled           = false;

            string where = "Year = '" + CBCreatedYears.SelectedItem + "'";
            Classes.DeleteRows(where, "Setup_Fiscal_Period");
            CBCreatedYears.Items.Remove(Year.Text);
            Clear_All();
            Close_All();
            MessageBox.Show("Done");
        }
        }           //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
        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 #12
0
        private static void CalculateQty(DataRow DRCurrentMonth, DataTable DTPreviousMonth)
        {
            string TheColumns = "_DATE datetime,Restaurant_ID int,Kitchen_ID int,KitchenName varchar(50),Trantype varchar(50),ID varchar(50)";

            TheColumns += ",Item_ID varchar(50),ItemName varchar(50),Qty float,Current_Qty float,Cost float,CurrentCost float";
            Classes.CreateTable("TransActions", TheColumns);

            BETable = Classes.RetrieveStoredWithParamaeters("SPTransActions", "@StartDate,@EndDate", DRCurrentMonth["From"].ToString() + ',' + DRCurrentMonth["To"].ToString());

            where = "_DATE between '" + Convert.ToDateTime(DRCurrentMonth["From"].ToString()).ToString(Classes.sysDateTimeFormat) + "' AND '" + Convert.ToDateTime(DRCurrentMonth["To"].ToString()).ToString(Classes.sysDateTimeFormat) + "'";

            Classes.DeleteRows(where, "TransActions");

            for (int k = 0; k < BETable.Rows.Count; k++)
            {
                if (k == 0)
                {
                    GetPrevQty(k, DTPreviousMonth);
                }
                else if (BETable.Rows[k]["Trantype"].ToString() == "Adjactment")
                {
                    BETable.Rows[k]["Qty"] = (double.Parse(BETable.Rows[k]["Current_Qty"].ToString()) - double.Parse(BETable.Rows[k - 1]["Current_Qty"].ToString())).ToString();
                    string TempWhere = "Adjacment_ID = '" + BETable.Rows[k]["ID"].ToString() + "' And Item_ID = '" + BETable.Rows[k]["Item_ID"].ToString() + "'";
                    Classes.UpdateRow("Qty,Variance", BETable.Rows[k - 1]["Current_Qty"].ToString() + "," + BETable.Rows[k]["Qty"].ToString(), TempWhere, "Adjacment_Items");
                    Insert(k);
                }
                else if (BETable.Rows[k]["Item_ID"].ToString() == BETable.Rows[k - 1]["Item_ID"].ToString() && BETable.Rows[k]["KitchenName"].ToString() == BETable.Rows[k - 1]["KitchenName"].ToString())
                {
                    BETable.Rows[k]["Current_Qty"] = (double.Parse(BETable.Rows[k]["Current_Qty"].ToString()) + double.Parse(BETable.Rows[k - 1]["Current_Qty"].ToString())).ToString();
                    Insert(k);
                }
                else
                {
                    GetPrevQty(k, DTPreviousMonth);
                }
            }
        }
Exemple #13
0
        }   //Done

        private void DeleteDataAtQtyOnHand()
        {
            string Where = string.Format("Resturant_ID={0} and Kitchen_ID={1}", ValOfResturant, ValOfKitchen);

            Classes.DeleteRows(Where, "PhysicalInventory_QtyOnHand");
        }   //Done