private void UpdateBtn_Click(object sender, RoutedEventArgs e) { if (Authenticated.IndexOf("UpdateUnits") == -1 && Authenticated.IndexOf("CheckAllUnits") == -1) { LogIn logIn = new LogIn(); logIn.ShowDialog(); } else { try { string FiledSelection = "Name,IsActive,Last_modifiled_Date"; string Values = string.Format("N'{0}','{1}',GETDATE()", Name_txt.Text, Active_chbx.IsChecked); string Where = "Code = " + Code_txt.Text; Classes.UpdateRow(FiledSelection, Values, Where, "Units"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { Classes.LogTable(Classes.MyComm.CommandText.ToString(), Code_txt.Text, "Units", "Update"); MainUiFormat(); Unit_DGV.DataContext = null; FillDGV(); } MessageBox.Show("Updated Successfully"); } }
private void UpdateUnitBtn_Click(object sender, RoutedEventArgs e) { if (Authenticated.IndexOf("UpdateConvUnits") == -1 && Authenticated.IndexOf("CheckAllUnits") == -1) { LogIn logIn = new LogIn(); logIn.ShowDialog(); } else { try { string FiledSelection = "BaseUnit_ID,BaseUnit_Name,Value,SecondUnit_ID,SecondUnit_Name,Last_modifiled_Date"; string Values = string.Format("(select Code From Units where Name='{0}'),N'{0}','{1}',(select Code From Units where Name='{2}'),'{2}',GETDATE()", BaseUnit.Text, ConvUnit2.Text, Secondunit.Text); string Where = "Code=" + TheCode_txt.Text; Classes.UpdateRow(FiledSelection, Values, Where, "Units_Conversion"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } { RecipeUnit_DGV.DataContext = null; MessageBox.Show("Saved Sussesfully !"); Classes.LogTable(Classes.MyComm.CommandText.ToString(), TheCode_txt.Text, "Units_Conversion", "Update"); SaveUNitBtn.IsEnabled = false; BtnRecipeUnit2.IsEnabled = false; BtnRecipeUnit.IsEnabled = false; UpdateUnitBtn.IsEnabled = false; LoadAllCOnv(); BaseUnit.Text = ""; Secondunit.Text = ""; ConvUnit2.Text = ""; ClearUIFields(); MainUiFormat(); } } }
private void UpdateBtn_Click(object sender, RoutedEventArgs e) { if (Authenticated.IndexOf("UpdateUsers") == -1 && Authenticated.IndexOf("CheckAllUsers") == -1) { LogIn logIn = new LogIn(); logIn.ShowDialog(); } else { try { string FiledSelection = "Name,UserName,Password,UserClass_ID,Mobile,Adress,Email,Active,ModifiedDate"; string Values = string.Format("N'{0}','{1}','{2}',(select UserClass_ID FROM UserClass_tbl Where Name='{3}'),'{4}',N'{5}','{6}','{7}',GETDATE()", Nametxt.Text, UserNametxt.Text, passwordtxt.Password, jobTitle.Text, phone.Text, Addresstxt.Text, Mailtxt.Text, Active_chbx.IsChecked.ToString()); string Where = "ID = " + userIDtxt.Text; Classes.UpdateRow(FiledSelection, Values, Where, "Users"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { MainUiFormat(); Classes.LogTable(Classes.MyComm.CommandText.ToString(), userIDtxt.Text, "Users", "Update"); UsersDGV.DataContext = null; FillDGV(); } MessageBox.Show("Updated Successfully"); } }
private static void UpdateItems(DataRow DRCurrentMonth) { string where = "Year = '" + DRCurrentMonth["Year"].ToString() + "' AND Month = '" + DRCurrentMonth["Month"].ToString() + "'"; DataTable ItemsQtyCost = Classes.RetrieveData("*", where + " AND Qty > '0' ", "BeginningEndingMonth"); foreach (DataRow Item in ItemsQtyCost.Rows) { where = " RestaurantID = '" + Item["Restaurant_ID"] + "' AND KitchenID = '" + Item["Kitchen_ID"] + "' AND ItemID = '" + Item["Item_ID"] + "'"; Classes.UpdateRow("Qty,Current_Cost", Item["Qty"] + "," + Item["Cost"], where, "Items"); } }
} //Done private void Edit_TIK() { try { string FiledSlection = "Manual_Transfer_No,Transfer_Date,Comment,From_Resturant_ID,To_Resturant_ID,From_Kitchen_ID,To_Kitchen_ID,Type,Status,Modifiled_Date,Total_Cost"; string Values = string.Format("'{0}','{1}','{2}',(select Code From Setup_Restaurant where Name='{3}'),(select Code From Setup_Restaurant where Name='{4}'),(select Code From Setup_Kitchens where Name='{5}' and RestaurantID=(select Code From Setup_Restaurant where Name='{3}')),(select Code From Setup_Kitchens where Name='{6}' and RestaurantID=(select Code From Setup_Restaurant where Name='{4}')),'{7}','{8}',GETDATE(),'{9}'", Manual_transfer_No.Text, Convert.ToDateTime(Transfer_dt.Text).ToString("MM-dd-yyyy"), commenttxt.Text, From_Resturant.Text, ToResturant.Text, From_Kitchen.Text, To_Kitchen.Text, "Transfer_Resturant", Statustxt.Text, Total_Price.Text); string Where = string.Format("Transfer_Serial={0}", transfer_No.Text); Classes.UpdateRow(FiledSlection, Values, Where, "Transfer_Kitchens"); Classes.LogTable(Classes.MyComm.CommandText.ToString(), transfer_No.Text, "Transfer_Kitchens", "Update"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } //Done
} //Done private void Edit_PO_Details(SqlConnection con) { try { con.Open(); string FiledSelection = "PO_No,Ship_ToRestaurant,Ship_ToKitchen,Vendor_ID,Delivery_Date,Last_Modified_Date,Comment,Total_Price,Status"; string Values = string.Format("'{0}',{1},{2},(select Code from Vendors where Name = N'{3}'),'{4}',GETDATE(),N'{5}','{6}','{7}'", PO_NO.Text, RestaurantCode, KitchenCode, Vendor.Text, Convert.ToDateTime(Delivery_dt.Text).ToString("MM-dd-yyyy"), commenttxt.Text, Total_Price_With_Tax.Text, Statustxt.Text); string where = string.Format("PO_Serial={0}", Serial_PO_NO.Text); Classes.UpdateRow(FiledSelection, Values, where, "PO"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { con.Close(); } } //Done
private void UpdateBtn_Click(object sender, RoutedEventArgs e) { if (Authenticated.IndexOf("UpdateKitchens") == -1 && Authenticated.IndexOf("CheckAllKitchens") == -1) { LogIn logIn = new LogIn(); logIn.ShowDialog(); } else { SqlConnection con = new SqlConnection(Classes.DataConnString); if (IsMain.IsChecked == true) { con.Open(); string s = string.Format("select Code,IsMain from Setup_Kitchens where IsMain='True' and RestaurantID='{0}'", ResturantCode); SqlCommand cmd = new SqlCommand(s, con); if (cmd.ExecuteScalar().ToString() != Code_txt.Text) { MessageBox.Show("Can't be more Than Main Kitchen !"); return; } } try { string FiledSlection = "Name,Name2,IsMain,IsOutlet,IsActive,Last_Modified_Date"; string values = string.Format("N'{0}', N'{1}', '{2}', '{3}','{4}',{5}", Name_txt.Text, Name2_txt.Text, IsMain.IsChecked, IsOutlet.IsChecked, Active_chbx.IsChecked, "GETDATE()"); string Where = string.Format("Code={0} and RestaurantID='{1}'", Code_txt.Text, ResturantCode); Classes.UpdateRow(FiledSlection, values, Where, "Setup_Kitchens"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { con.Close(); MainUiFormat(); Stores_DGV.DataContext = null; FillDGV(ResturantCode); } MessageBox.Show("Updated Successfully"); } }
} //Done private void UpdateBtn_Click(object sender, RoutedEventArgs e) { if (Authenticated.IndexOf("UpdateResturants") == -1 && Authenticated.IndexOf("CheckAllResturants") == -1) { LogIn logIn = new LogIn(); logIn.ShowDialog(); } else { SqlConnection con = new SqlConnection(Classes.DataConnString); if (IsMain.IsChecked == true) { try { DataTable IsMain = Classes.RetrieveData("IsMain", "IsMain='True'", "Setup_Restaurant"); if (IsMain.Rows.Count != 0) { MessageBox.Show("Can't be More than Main Resturant !"); return; } } catch { } } try { string FiledSlection = "Name,Name2,IsMain,IsActive,Last_Modified_Date"; string values = string.Format("N'{0}', N'{1}', '{2}', '{3}',{4}", Name_txt.Text, Name2_txt.Text, IsMain.IsChecked, Active_chbx.IsChecked, "GETDATE()"); string Where = string.Format("Code={0}", Code_txt.Text); Classes.UpdateRow(FiledSlection, values, Where, "Setup_Restaurant"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { Classes.LogTable(Classes.MyComm.CommandText.ToString(), Code_txt.Text, "Setup_Restaurant", "Update"); MainUiFormat(); Stores_DGV.DataContext = null; FillDGV(); } MessageBox.Show("Updated Successfully"); } } //Done
private 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); } } }
private void UpdateBtn_Click(object sender, RoutedEventArgs e) { if (Authenticated.IndexOf("UpdateVendors") == -1 && Authenticated.IndexOf("CheckAllVendors") == -1) { LogIn logIn = new LogIn(); logIn.ShowDialog(); } else { for (int i = 0; i < Vendors_DGV.Items.Count; i++) { if ((((DataRowView)Vendors_DGV.Items[i]).Row.ItemArray[1].ToString().Equals(Name_txt.Text)) && (((DataRowView)Vendors_DGV.Items[i]).Row.ItemArray[0].ToString()) != Code_txt.Text) { MessageBox.Show("Please Change The Name"); return; } } try { string FiledSelection = "Name,IsActive,LastModifiedDate"; string Values = string.Format("N'{0}','{1}',GETDATE()", Name_txt.Text, Active_chbx.IsChecked); string Where = "Code = " + Code_txt.Text; Classes.UpdateRow(FiledSelection, Values, Where, "Vendors"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { Classes.LogTable(Classes.MyComm.CommandText.ToString(), Code_txt.Text, "Vendors", "Update"); MainUiFormat(); Vendors_DGV.DataContext = null; FillDGV(); } MessageBox.Show("Updated Successfully"); } }
} //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 { } }
private static void CalculateCost(DataRow DRCurrentMonth, DataTable DTPreviousMonth) { LoadITEM_COST(DTPreviousMonth); where = "_DATE between '" + Convert.ToDateTime(DRCurrentMonth["From"].ToString()).ToString(Classes.sysDateTimeFormat) + "' AND '" + Convert.ToDateTime(DRCurrentMonth["To"].ToString()).ToString(Classes.sysDateTimeFormat) + "'"; string order = " order by Item_ID, _DATE "; DataTable Transactions = Classes.RetrieveData("*", where + order, "TransActions"); for (int i = 0; i < Transactions.Rows.Count; i++) { string itemCostKey = Transactions.Rows[i]["KitchenName"].ToString() + Transactions.Rows[i]["Item_ID"].ToString(); string ChangedTranKye = Transactions.Rows[i]["ID"].ToString() + Transactions.Rows[i]["Item_ID"].ToString(); where = "Trantype = '" + Transactions.Rows[i]["Trantype"].ToString(); where += "' AND Item_ID = '" + Transactions.Rows[i]["Item_ID"].ToString(); where += "' AND ID = '" + Transactions.Rows[i]["ID"].ToString() + "'"; if (Transactions.Rows[i]["Trantype"].ToString() == "Receive" || Transactions.Rows[i]["Trantype"].ToString() == "Transfer_In") { if (changed_trasfers.ContainsKey(ChangedTranKye) == true && Transactions.Rows[i]["Trantype"].ToString() == "Transfer_In") { Cost = double.Parse(changed_trasfers[ChangedTranKye]); } else { Cost = double.Parse(Transactions.Rows[i]["Cost"].ToString()); } if (Transactions.Rows[i]["Current_Qty"].Equals(Transactions.Rows[i]["Qty"])) { item_cost[itemCostKey] = Cost.ToString(); Classes.UpdateCell("CurrentCost", Cost.ToString(), where, "TransActions"); } else { double CurrentCost; double CurrentQty = double.Parse(Transactions.Rows[i]["Current_Qty"].ToString()) - double.Parse(Transactions.Rows[i]["Qty"].ToString()); if (CurrentQty < 0) { MessageBox.Show("Time error in" + Transactions.Rows[i]["Trantype"] + " " + Transactions.Rows[i]["ID"]); return; } Qty = double.Parse(Transactions.Rows[i]["Qty"].ToString()); if (item_cost.ContainsKey(itemCostKey)) { CurrentCost = double.Parse(item_cost[itemCostKey]); } else { CurrentCost = double.Parse(Transactions.Rows[i]["Cost"].ToString()); } double Current_Qty = double.Parse(Transactions.Rows[i]["Current_Qty"].ToString()); string NewCost; if (Current_Qty == 0) { NewCost = "0"; } else { NewCost = ((CurrentCost * CurrentQty + Cost * Qty) / Current_Qty).ToString(); } item_cost[itemCostKey] = NewCost; Classes.UpdateCell("CurrentCost", NewCost.ToString(), where, "TransActions"); } } else if (Transactions.Rows[i]["Trantype"].ToString() == "Adjactment") { item_cost[itemCostKey] = Transactions.Rows[i]["Cost"].ToString(); Classes.UpdateCell("CurrentCost", Transactions.Rows[i]["Cost"].ToString(), where, "TransActions"); } else if (Transactions.Rows[i]["Trantype"].ToString() == "Transfer_Out") { if (item_cost.ContainsKey(itemCostKey)) { if (!item_cost[itemCostKey].Equals(Transactions.Rows[i]["Cost"].ToString())) { changed_trasfers[ChangedTranKye] = item_cost[itemCostKey]; Classes.UpdateRow("CurrentCost,Cost", item_cost[itemCostKey] + "," + item_cost[itemCostKey], where, "TransActions"); //where = "Item_ID = '" + Transactions.Rows[i]["Item_ID"].ToString() + "' AND Transfer_ID = '" + Transactions.Rows[i]["ID"].ToString() + "'"; //Classes.UpdateCell("Cost", item_cost[itemCostKey], where, "Transfer_Kitchens_Items"); string tempwhere = "Item_ID = '" + Transactions.Rows[i]["Item_ID"].ToString() + "' AND Request_ID = '" + Transactions.Rows[i]["ID"].ToString() + "'"; Classes.UpdateCell("Cost", item_cost[itemCostKey], tempwhere, "Requests_Items"); Classes.UpdateCell("Net_Cost", "Cost * Qty", "Requests_Items"); DataTable drRoSerial = Classes.RetrieveData("SELECT RO_Serial from RO where Transactions_No = '" + Transactions.Rows[i]["ID"].ToString() + "' and Type = 'Transfer_Kitchen'"); if (drRoSerial.Rows.Count > 0) { tempwhere = "Item_ID = '" + Transactions.Rows[i]["Item_ID"].ToString() + "' AND RO_No = '" + drRoSerial.Rows[0][0].ToString() + "'"; Classes.UpdateRow("Price_With_Tax,Price_Without_Tax", item_cost[itemCostKey] + "," + item_cost[itemCostKey], tempwhere, "RO_Items"); Classes.UpdateCell("Net_Price", "Price_With_Tax * Qty", "RO_Items"); } } } } else if (Transactions.Rows[i]["Trantype"].ToString() == "Generate") { Classes.UpdateRow("CurrentCost,Cost", item_cost[itemCostKey] + "," + item_cost[itemCostKey], where, "TransActions"); tempwhere = "Item_ID = '" + Transactions.Rows[i]["Item_ID"].ToString() + "' AND Generate_ID = '" + Transactions.Rows[i]["ID"].ToString() + "'"; Classes.UpdateCell("Cost", item_cost[itemCostKey], tempwhere, "GenerateRecipe_Items"); Classes.UpdateCell("Net_Cost", "Cost * ItemQty", "GenerateRecipe_Items"); } } }