public ItemReportForm(Int64 fromOID, Int64 toOID, DateTime fromDate, DateTime toDate, int orderCount, bool showAll, string _dateRangeText) { InitializeComponent(); // fiscalPrinter = new FiscalPrinter(); tempPrintMethods = new CPrintMethodsEXT(); this.fromDate = fromDate; this.toDate = toDate; dateRangeText = _dateRangeText; _showAll = showAll; lblDate.Text += " " + fromDate.ToLongDateString() + " to: " + toDate.ToLongDateString(); lblOrderCount.Text += orderCount; SystemManager sysManager = new SystemManager(); dtFood = sysManager.GetItemWiseSales(fromOID, toOID, "Food", Convert.ToByte(showAll)); gridViewFood.DataSource = dtFood; dtNonFood = sysManager.GetItemWiseSales(fromOID, toOID, "NonFood", Convert.ToByte(showAll)); gridViewNonFood.DataSource = dtNonFood; if (dtFood != null && dtNonFood != null) { int query = (from order in dtFood.AsEnumerable() select order.Field<Int32>("QuantitySold")).Sum(); lblQtySoldFood.Text += " " + query; int query2 = (from order in dtNonFood.AsEnumerable() select order.Field<Int32>("QuantitySold")).Sum(); lblQtySoldNonFood.Text += " " + query2; lblQtySoldTotal.Text += " " + (query2 + query); Double P1 = 0; Double P2 = 0; foreach (DataRow row in dtFood.Rows) { P1 += Convert.ToDouble(row["TotalPrice"].ToString()); } foreach (DataRow row in dtNonFood.Rows) { P2 += Convert.ToDouble(row["TotalPrice"].ToString()); } lblPriceFood.Text += " " + P1.ToString("F02"); lblPriceNonFood.Text += " " + P2.ToString("F02"); lblPriceTotal.Text += " " + (P1 + P2).ToString("F02"); } }
private void btnSave_Click(object sender, EventArgs e) { try { double defaultTime = Convert.ToDouble("0" + txtDefaultTime.Text); SystemManager objSysManager = new SystemManager(); objSysManager.SvaeTakeawayDefaultTime(defaultTime); this.Close(); } catch (Exception exp) { MessageBox.Show(exp.Message,RMSGlobal.MessageBoxTitle,MessageBoxButtons.OK,MessageBoxIcon.Error); } }
private void functionalButton1_Click(object sender, EventArgs e) { // if (fiscalPrinter.foundPrinter()) // fiscalPrinter.ClearPrinting(); // change by mithu Int64 startDate = new DateTime(dtpStart.Value.Year, dtpStart.Value.Month, dtpStart.Value.Day, 0, 0, 0).Ticks; DateTime dtTemp = dtpEnd.Value.AddDays(1); Int64 endDate = new DateTime(dtTemp.Year, dtTemp.Month, dtTemp.Day, 0, 0, 0).Ticks; ViewReportAmount v = new ViewReportAmount(); SystemManager sysManager = new SystemManager(); v.aCSearchOrderInfos = sysManager.GetOrderInfo2(startDate, endDate); v.startDate = dtpStart.Value; v.endDate = dtTemp.Date; v.endDate = v.endDate.AddSeconds(-1); List<DatewiseTotal> aDatewiseTotals = new List<DatewiseTotal>(); try { while (v.startDate.Date <= v.endDate.Date) { DatewiseTotal aTotal = new DatewiseTotal(); aTotal.CashTotal = (double) (from search in v.aCSearchOrderInfos where search.OrderDateTime.Date == v.startDate.Date select search.CashPaid).Sum(); aTotal.Covers = (int) (from search in v.aCSearchOrderInfos where search.OrderDateTime.Date == v.startDate.Date select search.Covers).Sum(); aTotal.DiscountTotal = (double) (from search in v.aCSearchOrderInfos where search.OrderDateTime.Date == v.startDate.Date select search.Discount).Sum(); aTotal.EFTTotal = (double) (from search in v.aCSearchOrderInfos where search.OrderDateTime.Date == v.startDate.Date select search.EFTPaid).Sum(); aTotal.DueTotal = (double) (from search in v.aCSearchOrderInfos where search.OrderDateTime.Date == v.startDate.Date select search.DuePaid).Sum(); aTotal.FoodTotal = (double) (from search in v.aCSearchOrderInfos where search.OrderDateTime.Date == v.startDate.Date select search.FoodTotal).Sum(); aTotal.NoonFoodTotal = (double) (from search in v.aCSearchOrderInfos where search.OrderDateTime.Date == v.startDate.Date select search.NonfoodTotal).Sum(); aTotal.OrderTotal = (double) (from search in v.aCSearchOrderInfos where search.OrderDateTime.Date == v.startDate.Date select search.OrderTotal).Sum(); aTotal.ServiceChargeTotal = (double) (from search in v.aCSearchOrderInfos where search.OrderDateTime.Date == v.startDate.Date select search.ServiceChargeCash).Sum(); aTotal.TotalIncV = (double) (from search in v.aCSearchOrderInfos where search.OrderDateTime.Date == v.startDate.Date select search.TotalPaidIncludingVat).Sum(); aTotal.VatTotal = (double) (from search in v.aCSearchOrderInfos where search.OrderDateTime.Date == v.startDate.Date select search.VatPaid).Sum(); aTotal.Date = v.startDate.Date; aDatewiseTotals.Add(aTotal); v.startDate = v.startDate.AddDays(1); } } catch (Exception) { } v.DatewiseTotals = aDatewiseTotals; v.reportdataGridView.DataSource = aDatewiseTotals; v.Show(); }
private void showAllData(Int64 startDate, Int64 endDate) { SystemManager sysManager = new SystemManager(); oItemList = new List<CSearchOrderInfo>(); oItemList = sysManager.GetOrderInfo2(startDate, endDate); oItemList = CheckBeetweenTime(oItemList); // New added // Change by Mithu if (radioButtonCheat.Checked) { if (ManualCheatReport()) { txtBoxCheatPercent.Visible = false; oItemList = getManulCheatOrderList(oItemList); } else { oItemList = getAutoCheatOrderList(oItemList); } } if (chkTerminalName.Checked) { var filter = from searchItem in oItemList where searchItem.TerminalID == pcInfoList[cmbTerminalName.SelectedIndex].PcID.ToString() select searchItem; oItemList = filter.ToList(); } if (rbtnTable.Checked) { var filter = from searchItem in oItemList where searchItem.OrderType == "Table" || searchItem.OrderType == "Token" select searchItem; oItemList = filter.ToList(); } if (rbtnTakeAway.Checked) { var filter = from searchItem in oItemList where searchItem.OrderType == "TakeAway" select searchItem; oItemList = filter.ToList(); } if (dueTotalradioButton1.Checked) { var filter = from searchItem in oItemList where searchItem.DuePaid >0 select searchItem; oItemList = filter.ToList(); } if (txtBoxSerialNumber.Text != string.Empty) { var filter = from searchItem in oItemList where searchItem.SerialNumber == txtBoxSerialNumber.Text select searchItem; oItemList = filter.ToList(); } if(complementoryRadioButton.Checked) { var filter = from searchItem in oItemList where searchItem.ComplementoryMessage.Length!=0 select searchItem; oItemList = filter.ToList(); } if (dueRadioButton.Checked) { var filter = from searchItem in oItemList where searchItem.DueMessage.Length != 0 select searchItem; oItemList = filter.ToList(); } if (orderComplementoryRadioButton.Checked) { var filter = from searchItem in oItemList where searchItem.ComplementoryPaid > 0 select searchItem; oItemList = filter.ToList(); } int totalCovers = (from item in oItemList select item.Covers).Sum(); lelGuest_Value.Text = totalCovers.ToString(); decimal totalFood = (from item in oItemList select item.FoodTotal).Sum(); lelFoodPrice_Value.Text = totalFood.ToString(); decimal totalNonFood = (from item in oItemList select item.NonfoodTotal).Sum(); lelNonfoodPrice_Value.Text = totalNonFood.ToString(); decimal totaltableFood = (from item in oItemList where item.OrderType == "Table" select item.FoodTotal).Sum(); lelTableFoodPrice_Value.Text = totaltableFood.ToString(); decimal totaltableNonFood = (from item in oItemList where item.OrderType == "Table" select item.NonfoodTotal).Sum(); lelTableNonfoodPrice_Value.Text = totaltableNonFood.ToString(); decimal totalTakeWayFood = (from item in oItemList where item.OrderType == "TakeAway" select item.FoodTotal).Sum(); lelTakeAwayFoodPrice_Value.Text = totalTakeWayFood.ToString(); decimal totalTakeWayNonFood = (from item in oItemList where item.OrderType == "TakeAway" select item.NonfoodTotal).Sum(); lelTakeAwayNonfoodPrice_Value.Text = totalTakeWayNonFood.ToString(); /*decimal totalbarWayFood = (from item in oItemList where item.OrderType == "Bars" select item.FoodTotal).Sum(); lelTabsFoodPrice_Value.Text = totalbarWayFood.ToString(); decimal totalBarWayNonFood = (from item in oItemList where item.OrderType == "Bars" select item.NonfoodTotal).Sum(); lelTabsNonfoodPrice_Value.Text = totalBarWayNonFood.ToString();*/ decimal totalDisCount = (from item in oItemList select item.Discount).Sum(); lelDiscount_Value.Text = totalDisCount.ToString(); decimal totalSerViceCharge = (from item in oItemList select item.ServiceChargeCash).Sum(); lelServiceCharge_Value.Text = totalSerViceCharge.ToString(); decimal totalOrderTotal = (from item in oItemList select item.OrderTotal).Sum(); lelOrderTotal_Value.Text = totalOrderTotal.ToString(); decimal totalpaidExvat = (from item in oItemList select item.TotalPaidExcludingVat).Sum(); lelTotalpaidEXVAT_value.Text = totalpaidExvat.ToString(); decimal totalpaidIncvat = (from item in oItemList select item.TotalPaidIncludingVat).Sum(); lelTotalpaidIncVAT_value.Text = totalpaidIncvat.ToString(); decimal totalpaidvat = (from item in oItemList select item.VatPaid).Sum(); lelVat_Value.Text = totalpaidvat.ToString(); decimal totalcash = (from item in oItemList select item.CashPaid).Sum(); lelCashTotal_value.Text = totalcash.ToString(); decimal totaleft = (from item in oItemList select item.EFTPaid).Sum(); lelEftTotal_value.Text = totaleft.ToString(); double totalCost = (from item in oItemList select item.TotalCost).Sum(); double profit = (double)totalpaidExvat - totalCost; profitlebel.Text = profit.ToString("F02"); double itemDiscount = (from item in oItemList select item.ItemDiscount).Sum(); itemDiscountlabel.Text = itemDiscount.ToString(); if(waiterradioButton.Checked) { string sr = waitercomboBox.Text; oItemList = (from oitemList in oItemList where oitemList.Waiter == sr select oitemList).ToList(); } else if (tableNumberradioButton.Checked) { try { int tablenumber = Convert.ToInt32(tableNumbertextBox.Text); oItemList = (from oitemList in oItemList where oitemList.TableNumber == tablenumber select oitemList).ToList(); } catch (Exception) { } } decimal dueBill = oItemList.Sum(a => a.DuePaid); dueTotalLabel.Text = dueBill.ToString("F02"); decimal complementoryBill = oItemList.Sum(a => a.ComplementoryPaid); complementorylabel.Text = complementoryBill.ToString("F02"); dataGridView1.DataSource = oItemList; dataGridView1.Columns["Vat_stat"].Visible = false; }
private void btnCurrentDay_Click(object sender, EventArgs e) { DataSet dsSalesRecords = new DataSet(); CResult objResult = new CResult(); SystemManager objSystemMgnr = new SystemManager(); DateTime dtNow = DateTime.Now; DateTime dtStart = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 0, 0, 0); DateTime dtEnd = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 23, 59, 59); objResult = objSystemMgnr.GetSalesRecords(dtStart.Ticks, dtEnd.Ticks); dsSalesRecords = (DataSet)objResult.Data; if (dsSalesRecords.Tables.Count > 0 && dsSalesRecords.Tables[0].Rows.Count > 0) { Int32 guestCounter = Convert.ToInt32(dsSalesRecords.Tables[0].Rows[0]["guest_count"]); CPrintMethods tempPrintMethods = new CPrintMethods(); string serialHeader = RMSClientController.CollectHeader(); string serialFooter = RMSClientController.CollectFooter(); List<CSerialPrintContent> serialBody = new List<CSerialPrintContent>(); CSerialPrintContent tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = " Inventory Sales Report\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Date of Consumption of Items:" + DateTime.Now.ToString("dd/MM/yyyy"); ; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "No. of Covers:" + guestCounter.ToString() + "\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Qty Item Price"; serialBody.Add(tempSerialPrintContent); SortedList slorderedFoodItems = new SortedList(); SortedList slorderedNonFoodItems = new SortedList(); if (dsSalesRecords.Tables[0].Rows.Count > 0) { foreach (DataRow dtRrow in dsSalesRecords.Tables[0].Rows) { clsOrderReport objOrderedItems = new clsOrderReport(); string[] returnedValue = GetProductName(dtRrow).Split(':'); string productName = Convert.ToString(returnedValue[0]); string cat1ID = Convert.ToString(returnedValue[1]); objOrderedItems.Quantity = Convert.ToInt32("0" + dtRrow["quantity"].ToString()); objOrderedItems.ItemName = productName; objOrderedItems.Price = Convert.ToDouble(dtRrow["amount"]); objOrderedItems.FoodTypeName = Convert.ToString(returnedValue[2]); Int32 category1OrderNumber = this.GetCategory1OrderNumber(Convert.ToInt32(cat1ID)); objOrderedItems.OrderNumber = category1OrderNumber; string keyCode = category1OrderNumber + "-" + objOrderedItems.Quantity.ToString() + "-" + objOrderedItems.ItemName; if (Convert.ToString(dtRrow["food_type"]).Equals("Food")) //Separate food/nonfoods { m_htFoods.Add(keyCode, objOrderedItems); } else { m_htNonFoods.Add(keyCode, objOrderedItems); } } int separatorNumber = -1; NumericComparer nc = new NumericComparer(); slorderedFoodItems = new SortedList(m_htFoods, nc); //Creating the sorted list from the hash table. slorderedNonFoodItems = new SortedList(m_htNonFoods, nc); SortedList slMaster1 = new SortedList(); ArrayList arrListItems = null; foreach (DictionaryEntry objOrderedItems in slorderedFoodItems) { clsOrderReport objItem = (clsOrderReport)objOrderedItems.Value; string keyValue = objOrderedItems.Key.ToString(); string[] splitter = new string[0]; splitter = keyValue.Split('-'); if (separatorNumber != Convert.ToInt32(splitter[0])) { separatorNumber = Convert.ToInt32(splitter[0]); arrListItems = new ArrayList(); arrListItems.Add(objItem); slMaster1.Add(separatorNumber, arrListItems); } else { arrListItems.Add(objItem); separatorNumber = Convert.ToInt32(splitter[0]); } } ArrayList alReverseOrderedItem; foreach (DictionaryEntry deReverseOrderedItem in slMaster1) { alReverseOrderedItem = (ArrayList)deReverseOrderedItem.Value; alReverseOrderedItem.Reverse();//Reversing the current item order. foreach (clsOrderReport objOrderedItems in alReverseOrderedItem) { if (separatorNumber != objOrderedItems.OrderNumber) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "----------------------------------------"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = objOrderedItems.FoodTypeName + ":"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine += objOrderedItems.Quantity.ToString() + " "; tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objOrderedItems.ItemName, 30); tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objOrderedItems.Price.ToString("F02"), 6); serialBody.Add(tempSerialPrintContent); separatorNumber = objOrderedItems.OrderNumber; } else { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine += objOrderedItems.Quantity.ToString() + " "; tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objOrderedItems.ItemName, 30); tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objOrderedItems.Price.ToString("F02"), 6); serialBody.Add(tempSerialPrintContent); } } } #region "Non food items" tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "-----------------Drinks-----------------"; serialBody.Add(tempSerialPrintContent); SortedList slMaster2 = new SortedList(); ArrayList arrListItemsNonFood = null; foreach (DictionaryEntry objOrderedNonFood in slorderedNonFoodItems) { clsOrderReport objItem = (clsOrderReport)objOrderedNonFood.Value; string keyValue = objOrderedNonFood.Key.ToString(); string[] splitter = new string[0]; splitter = keyValue.Split('-'); if (separatorNumber != Convert.ToInt32(splitter[0])) { separatorNumber = Convert.ToInt32(splitter[0]); arrListItemsNonFood = new ArrayList(); arrListItemsNonFood.Add(objItem); slMaster2.Add(separatorNumber, arrListItemsNonFood); } else { arrListItemsNonFood.Add(objItem); separatorNumber = Convert.ToInt32(splitter[0]); } } separatorNumber = -1; foreach (DictionaryEntry objNonFood in slMaster2) { ArrayList alNonFoods = (ArrayList)objNonFood.Value; alNonFoods.Reverse(); foreach (clsOrderReport objNonFoodItem in alNonFoods) { if (separatorNumber != objNonFoodItem.OrderNumber) { tempSerialPrintContent = new CSerialPrintContent(); // tempSerialPrintContent.StringLine = "----------------------------------------"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine += objNonFoodItem.Quantity.ToString() + " "; tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objNonFoodItem.ItemName, 30); tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objNonFoodItem.Price.ToString("F02"), 6); serialBody.Add(tempSerialPrintContent); separatorNumber = objNonFoodItem.OrderNumber; } else { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine += objNonFoodItem.Quantity.ToString() + " "; tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objNonFoodItem.ItemName, 30); tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objNonFoodItem.Price.ToString("F02"), 6); serialBody.Add(tempSerialPrintContent); } } } #endregion tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "----------------------------------------"; serialBody.Add(tempSerialPrintContent); #region "Testing printing area" string printingObject = ""; for (int arrayIndex = 0; arrayIndex < serialBody.Count; arrayIndex++) { printingObject += serialBody[arrayIndex].StringLine.ToString() + "\r\n"; } this.WriteString(printingObject);///Write to a file when print command is executed #endregion tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, serialBody, serialFooter, "SN".ToString()); } } else { MessageBox.Show("There is no record",RMSGlobal.MessageBoxTitle,MessageBoxButtons.OK,MessageBoxIcon.Information); } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Are you sure you want to remove the selected text?", RMSGlobal.MessageBoxTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Int32 kitchenTextID = Convert.ToInt32("0" + dgvKitchenText.CurrentRow.Cells[0].Value); SystemManager objSystem = new SystemManager(); if (m_specialModifyText == false) { objSystem.DeleteKitchenText(kitchenTextID); } else { objSystem.DeleteSpecialText(kitchenTextID); } this.LoadKitchenText(); } } catch (Exception exp) { throw exp; } }
private void SaveButton_Click(object sender, EventArgs e) { try { if (m_specialModifyText == false) { SortedList slKitchenText = new SortedList(); slKitchenText.Add("ID", txtKitchenText.Tag); slKitchenText.Add("KT", txtKitchenText.Text); SystemManager objSystem = new SystemManager(); objSystem.SaveKitchenText(slKitchenText); } else { SortedList slKitchenText = new SortedList(); slKitchenText.Add("SPID", txtKitchenText.Tag); slKitchenText.Add("SPTXT", txtKitchenText.Text); SystemManager objSystem = new SystemManager(); objSystem.SaveSpecialText(slKitchenText); } this.LoadKitchenText(); MessageBox.Show("Kitchen text has been saved scucessfully.", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception exp) { throw exp; } }
private void LoadKitchenText() { SortedList slKitchenText = new SortedList(); SystemManager objSystem = new SystemManager(); CResult objCresult = new CResult(); if (m_specialModifyText == false) //If for kitchen text { objCresult = objSystem.GetAllKitchenText(); slKitchenText = (SortedList)objCresult.Data; dgvKitchenText.RowCount = 0; foreach (clsKitchenText objKitchenText in slKitchenText.Values) { DataGridViewRowCollection dgvRow = (DataGridViewRowCollection)dgvKitchenText.Rows; dgvRow.Add(objKitchenText.KitchenTextId, objKitchenText.KitchenText); } } else //If for special modification { objCresult = objSystem.GetAllSpecialModifyText(); slKitchenText = (SortedList)objCresult.Data; dgvKitchenText.RowCount = 0; foreach (clsSpecialModfifyText objSpecialText in slKitchenText.Values) { DataGridViewRowCollection dgvRow = (DataGridViewRowCollection)dgvKitchenText.Rows; dgvRow.Add(objSpecialText.SpecialModfifyTextId, objSpecialText.SpecialModfifyText); } } dgvKitchenText.ClearSelection(); txtKitchenText.Clear(); }
private void btnCurrentDay_Click(object sender, EventArgs e) { DataSet dsSalesRecords = new DataSet(); CResult objResult = new CResult(); SystemManager objSystemMgnr = new SystemManager(); DateTime dtNow = DateTime.Now; DateTime dtStart = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 0, 0, 0); DateTime dtEnd = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 23, 59, 59); objResult = objSystemMgnr.GetSalesRecords(dtStart.Ticks, dtEnd.Ticks); DataTable dt = (DataTable)objResult.Data; dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = dt; { // MessageBox.Show("There is no record", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void showOrderDetails(string orderID) { SystemManager sysManager = new SystemManager(); List<CArchiveItemDetails> oItemList = new List<CArchiveItemDetails>(); int p_orderID = int.Parse(orderID); oItemList = sysManager.GetOrderDetailInfo(p_orderID); DataTable dtResult = new DataTable(); dtResult.Columns.Add("Item name", typeof(string)); dtResult.Columns.Add("Quantity", typeof(int)); dtResult.Columns.Add("Amount", typeof(double)); dtResult.Columns.Add("Remarks", typeof(string)); dtResult.Columns.Add("Food type", typeof(string)); // dtResult.Columns.Add("Table name", typeof(string)); // dtResult.Columns.Add("Guest no", typeof(int)); dtResult.Columns.Add("Order time", typeof(DateTime)); dtResult.Columns.Add("Order taken by", typeof(string)); for (int i = 0; i < oItemList.Count; i++) { dtResult.Rows.Add(oItemList[i].ItemName, oItemList[i].Quantity, oItemList[i].Amount, oItemList[i].Remarks, oItemList[i].FoodType, //oItemList[i].TableName, //oItemList[i].GuestCount, new DateTime(Int64.Parse(oItemList[i].ItemOrderTime.ToString())), oItemList[i].UserName); } dgvOrderDetails.DataSource = dtResult; }
//public void FormatDataTime() //{ // chkFromTime.Checked = true; // DateTime fromDateTaken = new DateTime(1971, 1, 1, System.DateTime.Now.Hour, System.DateTime.Now.Minute, System.DateTime.Now.Second); // fromDateTaken.Value = System.DateTime.Now; // toDateTaken.Value = System.DateTime.Now; // DateTime firstDate = new DateTime(1971, 1, 1, 12, 0, 0); // DateTime secondDate = new DateTime(1971, 1, 1, 6, 59, 59); // DateTime excepTime = dtpStart.Value.AddHours(-1); // if (fromDateTaken >= firstDate && fromDateTaken <= secondDate || excepTime.Day < dtpStart.Value.Day) // { // fromDate.Value = fromDate.Value.AddDays(-1); // } // else // { // toDate.Value = toDate.Value.AddDays(1); // } //} private void button1_Click(object sender, EventArgs e) { DataSet dsSalesRecords = new DataSet(); CResult objResult = new CResult(); SystemManager objSystemMgnr = new SystemManager(); DateTime fromDateTaken = new DateTime(); DateTime toDateTaken = new DateTime(); fromDateTaken = new DateTime(fromDate.Value.Year, fromDate.Value.Month, fromDate.Value.Day, 7, 0, 0); toDateTaken = new DateTime(toDate.Value.Year, toDate.Value.Month, toDate.Value.Day, 6, 59, 59); toDateTaken = toDateTaken.AddDays(1); objResult = objSystemMgnr.GetRawMat(fromDateTaken.Ticks, toDateTaken.Ticks); RawMatGrid.DataSource = null; DataTable dt = (DataTable)objResult.Data; tableReport = new DataTable(); tableReport.Columns.Add("cat3_id", typeof(int)); tableReport.Columns.Add("cat3_name", typeof(string)); tableReport.Columns.Add("UnitsInStock", typeof(float)); tableReport.Columns.Add("uom", typeof(string)); tableReport.Columns.Add("Date", typeof(DateTime)); tableReport.Columns.Add("AdditionalQty", typeof(float)); tableReport.Columns.Add("PrevQty",typeof(float)); //long beginTicks = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks; if (dt != null || dt.Rows.Count > 0) for (int i = 0; i < dt.Rows.Count; i++) { //long dateNumber = Convert.ToInt64(dt.Rows[i]["datetime"]); // DateTime dateValue = new DateTime(beginTicks + Convert.ToInt64(dt.Rows[i]["datetime"]) * 10000); tableReport.Rows.Add(Convert.ToInt16(dt.Rows[i]["cat3_id"]), Convert.ToString(dt.Rows[i]["cat3_name"]), dt.Rows[i]["UnitsInStock"].ToString(), dt.Rows[i]["uom"].ToString(), dt.Rows[i]["Date"], dt.Rows[i]["AdditionalQty"], dt.Rows[i]["PrevQty"]); } RawMatGrid.AutoGenerateColumns = false; RawMatGrid.DataSource = tableReport; // decimal GrandTotal = 0, TotalQty = 0; // foreach (DataRow row in dt.Rows) // { // GrandTotal = GrandTotal + Convert.ToDecimal(row["TotalAmount"]); // TotalQty = TotalQty + Convert.ToDecimal(row["quantity"]); // } // this.OpenConnection(); // SqlCommand Comm = new SqlCommand(); }
private void LoadKitchenTextButtons() { try { SortedList slKitchenText = new SortedList(); SystemManager objSystem = new SystemManager(); CResult objCresult = new CResult(); objCresult = objSystem.GetAllKitchenText(); slKitchenText = (SortedList)objCresult.Data; int buttonCount = slKitchenText.Count; buttons = new Button[buttonCount]; int btnCounter = 0; foreach (clsKitchenText objKitchenText in slKitchenText.Values) { DataGridViewRowCollection dgvRow = (DataGridViewRowCollection)dgvKitchenText.Rows; dgvRow.Add(new object[]{objKitchenText.KitchenText}); btnCounter++; } } catch (Exception exp) { throw exp; } }
private void btnPrint_Click(object sender, EventArgs e) { StringPrintFormater strPrintFormatter = new StringPrintFormater(40); DataSet dsSalesRecords = new DataSet(); CResult objResult = new CResult(); SystemManager objSystemMgnr = new SystemManager(); m_htFoods = new Hashtable(); m_htNonFoods = new Hashtable(); DateTime dtStart = new DateTime(dtpStart.Value.Year, dtpStart.Value.Month, dtpStart.Value.Day, 0, 0, 0); DateTime dtEnd = new DateTime(dtpEnd.Value.Year, dtpEnd.Value.Month, dtpEnd.Value.Day, 23, 59, 59); //if (chkFromTime.Checked) //{ dtStart = new DateTime(dtpStart.Value.Year, dtpStart.Value.Month, dtpStart.Value.Day, 7, 0, 0); dtEnd = new DateTime(dtpEnd.Value.Year, dtpEnd.Value.Month, dtpEnd.Value.Day, 6, 59, 59); // } dtEnd = dtEnd.AddDays(1); objResult = objSystemMgnr.GetSalesRecords(dtStart.Ticks, dtEnd.Ticks); dsSalesRecords = (DataSet)objResult.Data; if (dsSalesRecords.Tables.Count > 0 && dsSalesRecords.Tables[0].Rows.Count > 0) { Int32 guestCounter = Convert.ToInt32(dsSalesRecords.Tables[0].Rows[0]["guest_count"]); CPrintMethods tempPrintMethods = new CPrintMethods(); string serialHeader = RMSClientController.CollectHeader(); string serialFooter = RMSClientController.CollectFooter(); List<CSerialPrintContent> serialBody = new List<CSerialPrintContent>(); CSerialPrintContent tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CenterTextWithWhiteSpace("Inventory Sales Report"); serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CenterTextWithWhiteSpace("Date of Consumption of Items"); serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CenterTextWithWhiteSpace("From " + dtpStart.Value.Date.ToString("dd/MM/yyyy") + " To " + dtpEnd.Value.Date.ToString("dd/MM/yyyy")); serialBody.Add(tempSerialPrintContent); //tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = "No. of Covers:" + guestCounter.ToString() + "\n"; //serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CreateDashedLine(); serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Qty Item Price(£)"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CreateDashedLine(); serialBody.Add(tempSerialPrintContent); SortedList slorderedFoodItems = new SortedList(); SortedList slorderedNonFoodItems = new SortedList(); PrintUtility printUtility = new PrintUtility(); CCategory3DAO category3DAO = new CCategory3DAO(); foreach (DataRow dtRrow in dsSalesRecords.Tables[0].Rows) { clsOrderReport objOrderedItems = new clsOrderReport(); string[] returnedValue = GetProductName(dtRrow).Split(':'); // string productName = Convert.ToString(returnedValue[0]); string cat1ID = Convert.ToString(returnedValue[1]); objOrderedItems.Quantity = Convert.ToInt32("0" + dtRrow["quantity"].ToString()); // objOrderedItems.ItemName = productName; string productName = ""; CCategory3 cat3 = category3DAO.GetAllCategory3ByCategory3ID(Convert.ToInt32(dtRrow["product_id"].ToString())); if (cat3 != null && cat3.Category3Name.Length>0) { productName = cat3.Category3Name.Trim(); } else { productName = Convert.ToString(dtRrow["product_Name"].ToString()); // @hafiz } objOrderedItems.ItemName = productName; //Convert.ToString(dtRrow["product_Name"].ToString()); //@Hafiz objOrderedItems.Price = Convert.ToDouble(dtRrow["amount"]); objOrderedItems.FoodTypeName = Convert.ToString(returnedValue[2]); Int32 category1OrderNumber = this.GetCategory1OrderNumber(Convert.ToInt32("0" + cat1ID)); objOrderedItems.OrderNumber = category1OrderNumber; string keyCode = category1OrderNumber + "-" + objOrderedItems.Quantity.ToString() + "-" + objOrderedItems.ItemName; string tempKey = 99999 + "-" + objOrderedItems.Quantity.ToString() + "-" + objOrderedItems.ItemName; ; if (Convert.ToString(dtRrow["food_type"]).Equals("Food") && Convert.ToInt16(dtRrow["product_id"]) != 0) //Separate food/nonfoods { if (!m_htFoods.ContainsKey(keyCode)) { m_htFoods.Add(keyCode, objOrderedItems); } else { clsOrderReport orderReport = m_htFoods[keyCode] as clsOrderReport; objOrderedItems.Quantity = objOrderedItems.Quantity + orderReport.Quantity; m_htFoods[keyCode] = objOrderedItems; } } else if (Convert.ToString(dtRrow["product_id"]).Equals("0")) //Separate food/nonfoods { // m_htFoods.Add(tempKey, objOrderedItems); if (!m_htFoods.ContainsKey(tempKey)) { m_htFoods.Add(tempKey, objOrderedItems); } else { clsOrderReport orderReport = m_htFoods[tempKey] as clsOrderReport; objOrderedItems.Quantity = objOrderedItems.Quantity + orderReport.Quantity; m_htFoods[tempKey] = objOrderedItems; } } else { //m_htNonFoods.Add(keyCode, objOrderedItems); if (!m_htNonFoods.ContainsKey(keyCode)) { m_htNonFoods.Add(keyCode, objOrderedItems); } else { clsOrderReport orderReport = m_htNonFoods[keyCode] as clsOrderReport; objOrderedItems.Quantity = objOrderedItems.Quantity + orderReport.Quantity; m_htNonFoods[keyCode] = objOrderedItems; } } } int separatorNumber = -1; NumericComparer nc = new NumericComparer(); slorderedFoodItems = new SortedList(m_htFoods, nc); //Creating the sorted list from the hash table. slorderedNonFoodItems = new SortedList(m_htNonFoods, nc); SortedList slMaster1 = new SortedList(); ArrayList arrListItems = null; foreach (DictionaryEntry objOrderedItems in slorderedFoodItems) { clsOrderReport objItem = (clsOrderReport)objOrderedItems.Value; string keyValue = objOrderedItems.Key.ToString(); string[] splitter = new string[0]; splitter = keyValue.Split('-'); if (separatorNumber != Convert.ToInt32(splitter[0])) { separatorNumber = Convert.ToInt32(splitter[0]); arrListItems = new ArrayList(); arrListItems.Add(objItem); slMaster1.Add(separatorNumber, arrListItems); } else { arrListItems.Add(objItem); separatorNumber = Convert.ToInt32(splitter[0]); } } ArrayList alReverseOrderedItem; foreach (DictionaryEntry deReverseOrderedItem in slMaster1) { alReverseOrderedItem = (ArrayList)deReverseOrderedItem.Value; alReverseOrderedItem.Reverse();//Reversing the current item order. foreach (clsOrderReport objOrderedItems in alReverseOrderedItem) { if (separatorNumber != objOrderedItems.OrderNumber) { //tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = "----------------------------------------"; //serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = objOrderedItems.FoodTypeName + ":"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine += objOrderedItems.Quantity.ToString() + " "; tempSerialPrintContent.ISAlredyNewLine = true; // tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objOrderedItems.ItemName, 30); // tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objOrderedItems.Price.ToString("F02"), 6); tempSerialPrintContent.StringLine += printUtility.MultipleLine(objOrderedItems.ItemName, 30, objOrderedItems.Price.ToString("F02"), 37); serialBody.Add(tempSerialPrintContent); separatorNumber = objOrderedItems.OrderNumber; } else { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine += objOrderedItems.Quantity.ToString() + " "; // tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objOrderedItems.ItemName, 30); // tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objOrderedItems.Price.ToString("F02"), 6); tempSerialPrintContent.StringLine += printUtility.MultipleLine(objOrderedItems.ItemName, 30, objOrderedItems.Price.ToString("F02"), 37); tempSerialPrintContent.ISAlredyNewLine = true; serialBody.Add(tempSerialPrintContent); } } } #region "Non food items" tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "-----------------Drinks-----------------"; serialBody.Add(tempSerialPrintContent); SortedList slMaster2 = new SortedList(); ArrayList arrListItemsNonFood = new ArrayList(); separatorNumber = -1; foreach (DictionaryEntry objOrderedNonFood in slorderedNonFoodItems) { clsOrderReport objItem = (clsOrderReport)objOrderedNonFood.Value; string keyValue = objOrderedNonFood.Key.ToString(); string[] splitter = new string[0]; splitter = keyValue.Split('-'); if (separatorNumber != Convert.ToInt32(splitter[0])) { separatorNumber = Convert.ToInt32(splitter[0]); arrListItemsNonFood = new ArrayList(); arrListItemsNonFood.Add(objItem); slMaster2.Add(separatorNumber, arrListItemsNonFood); } else { arrListItemsNonFood.Add(objItem); separatorNumber = Convert.ToInt32(splitter[0]); } } separatorNumber = -1; foreach (DictionaryEntry objNonFood in slMaster2) { ArrayList alNonFoods = (ArrayList)objNonFood.Value; alNonFoods.Reverse(); foreach (clsOrderReport objNonFoodItem in alNonFoods) { if (separatorNumber != objNonFoodItem.OrderNumber) { //tempSerialPrintContent = new CSerialPrintContent(); //// tempSerialPrintContent.StringLine = "----------------------------------------"; //serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine += objNonFoodItem.Quantity.ToString() + " "; // tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objNonFoodItem.ItemName, 30); // tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objNonFoodItem.Price.ToString("F02"), 6); tempSerialPrintContent.StringLine += printUtility.MultipleLine(objNonFoodItem.ItemName, 30, objNonFoodItem.Price.ToString("F02"), 37); serialBody.Add(tempSerialPrintContent); tempSerialPrintContent.ISAlredyNewLine = true; separatorNumber = objNonFoodItem.OrderNumber; } else { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine += objNonFoodItem.Quantity.ToString() + " "; // tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objNonFoodItem.ItemName, 30); // tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objNonFoodItem.Price.ToString("F02"), 6); tempSerialPrintContent.StringLine += printUtility.MultipleLine(objNonFoodItem.ItemName, 30, objNonFoodItem.Price.ToString("F02"), 37); tempSerialPrintContent.ISAlredyNewLine = true; serialBody.Add(tempSerialPrintContent); } } } #endregion tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CreateDashedLine();// "----------------------------------------"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Total No Of Item: " + lblNoOfItemsSold.Text; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Total Qty: " + lblTotalQty.Text; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Total Item Amount: " + lblTotalAmount.Text; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CreateDashedLine(); serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = strPrintFormatter.CenterTextWithWhiteSpace("Developed By: www.ibacs.co.uk") + "\r\n\n"; serialBody.Add(tempSerialPrintContent); #region "Testing printing area" string printingObject = ""; for (int arrayIndex = 0; arrayIndex < serialBody.Count; arrayIndex++) { if (serialBody[arrayIndex].ISAlredyNewLine) { printingObject += serialBody[arrayIndex].StringLine.ToString() ; } else { printingObject += serialBody[arrayIndex].StringLine.ToString() + "\r\n"; } } this.WriteString(printingObject);///Write to a file when print command is executed #endregion A4Text = printingObject; CPrintMethodsEXT tempPrintMethods1 = new CPrintMethodsEXT(); DataSet tempDataSet = new DataSet(); tempDataSet.ReadXml("Config/Print_Config.xml"); if (dataGridView1.Rows.Count > 0) if (Convert.ToBoolean(tempDataSet.Tables[0].Rows[0]["IsGuestBillPrinterSerial"]) == true) { // tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, serialBody, serialFooter, "SN".ToString()); tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, printingObject, serialFooter, "SN".ToString()); } else { tempPrintMethods1.USBPrint(printingObject, PrintDestiNation.CLIENT, true); } else { MessageBox.Show("There is no record", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("There is no record", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnPrintSummary_Click(object sender, EventArgs e) { m_htFoods = new Hashtable(); m_htNonFoods = new Hashtable(); // FormatDataTime(); DataSet dsSalesRecords = new DataSet(); CResult objResult = new CResult(); SystemManager objSystemMgnr = new SystemManager(); DateTime dtNow = DateTime.Now; DateTime dtStart = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 0, 0, 0); DateTime dtEnd = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 23, 59, 59); //if (chkFromTime.Checked) //{ dtStart = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, 7, 0, 0); dtEnd = new DateTime(dtEnd.Year, dtEnd.Month, dtEnd.Day, 6, 59, 59); // } dtEnd = dtEnd.AddDays(1); objResult = objSystemMgnr.GetSalesRecordsForINV(dtStart.Ticks, dtEnd.Ticks); StringPrintFormater strPrintFormatter = new StringPrintFormater(40); DataTable dt = (DataTable)objResult.Data; tableReport = new DataTable(); tableReport.Columns.Add("product_id", typeof(int)); tableReport.Columns.Add("product_Name", typeof(string)); tableReport.Columns.Add("amount", typeof(string)); tableReport.Columns.Add("quantity", typeof(string)); tableReport.Columns.Add("TotalAmount", typeof(string)); tableReport.Columns.Add("guest_count", typeof(int)); tableReport.Columns.Add("cat_level", typeof(int)); tableReport.Columns.Add("food_type", typeof(string)); if (dt != null || dt.Rows.Count > 0) for (int i = 0; i < dt.Rows.Count; i++) { tableReport.Rows.Add(Convert.ToInt16(dt.Rows[i]["product_id"]), Convert.ToString(dt.Rows[i]["product_Name"]), dt.Rows[i]["amount"].ToString(), dt.Rows[i]["quantity"].ToString(), dt.Rows[i]["TotalAmount"].ToString(), Convert.ToInt16(dt.Rows[i]["guest_count"]), Convert.ToInt16(dt.Rows[i]["cat_level"]), dt.Rows[i]["food_type"].ToString()); } if (dataGridView1.Rows.Count > 0) if (tableReport.Rows.Count > 0) { // Int32 guestCounter = Convert.ToInt32(dsSalesRecords.Tables[0].Rows[0]["guest_count"]); Int32 guestCounter = Convert.ToInt32(tableReport.Rows[0]["guest_count"]); CPrintMethods tempPrintMethods = new CPrintMethods(); string serialHeader = RMSClientController.CollectHeader(); string serialFooter = RMSClientController.CollectFooter(); List<CSerialPrintContent> serialBody = new List<CSerialPrintContent>(); CSerialPrintContent tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "\r\n" + strPrintFormatter.CenterTextWithWhiteSpace("Inventory Sales Report") + "\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CenterTextWithWhiteSpace("Date of Consumption of Items:" + DateTime.Now.ToString("dd/MM/yyyy")) + "\r\n"; serialBody.Add(tempSerialPrintContent); //tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = "No. of Covers:" + guestCounter.ToString() + "\n"; //serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CreateDashedLine() +"\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Qty Item Price(£)"+"\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CreateDashedLine() + "\r\n"; serialBody.Add(tempSerialPrintContent); CCategory3DAO category3DAO = new CCategory3DAO(); SortedList slorderedFoodItems = new SortedList(); SortedList slorderedNonFoodItems = new SortedList(); //if (dsSalesRecords.Tables[0].Rows.Count > 0) if (tableReport.Rows.Count > 0) { // foreach (DataRow dtRrow in dsSalesRecords.Tables[0].Rows) foreach (DataRow dtRrow in tableReport.Rows) { clsOrderReport objOrderedItems = new clsOrderReport(); string[] returnedValue = GetProductName(dtRrow).Split(':'); // string productName = Convert.ToString(returnedValue[0]); string productName = ""; CCategory3 cat3 = category3DAO.GetAllCategory3ByCategory3ID(Convert.ToInt32(dtRrow["product_id"].ToString())); if (cat3 != null && cat3.Category3Name.Length>0) { productName = cat3.Category3Name; } else { productName = Convert.ToString(dtRrow["product_Name"].ToString()); // @hafiz } string cat1ID = Convert.ToString(returnedValue[1]); objOrderedItems.Quantity = Convert.ToInt32("0" + dtRrow["quantity"].ToString()); objOrderedItems.ItemName = productName; objOrderedItems.Price = Convert.ToDouble(dtRrow["TotalAmount"]); objOrderedItems.FoodTypeName = Convert.ToString(returnedValue[2]); Int32 category1OrderNumber = 0; if (cat1ID != "") { category1OrderNumber = this.GetCategory1OrderNumber(Convert.ToInt32(cat1ID)); objOrderedItems.OrderNumber = category1OrderNumber; string keyCode = category1OrderNumber + "-" + objOrderedItems.Quantity.ToString() + "-" + objOrderedItems.ItemName; if (Convert.ToString(dtRrow["food_type"]).Equals("Food")) //Separate food/nonfoods { m_htFoods.Add(keyCode, objOrderedItems); } else { m_htNonFoods.Add(keyCode, objOrderedItems); } } else { category1OrderNumber = maxOrder + 1; objOrderedItems.OrderNumber = category1OrderNumber; string keyCode = category1OrderNumber + "-" + objOrderedItems.Quantity.ToString() + "-" + objOrderedItems.ItemName; if (Convert.ToString(dtRrow["food_type"]).Equals("Food")) //Separate food/nonfoods { m_htFoods.Add(keyCode, objOrderedItems); } else { m_htNonFoods.Add(keyCode, objOrderedItems); } } } int separatorNumber = -1; NumericComparer nc = new NumericComparer(); slorderedFoodItems = new SortedList(m_htFoods, nc); //Creating the sorted list from the hash table. slorderedNonFoodItems = new SortedList(m_htNonFoods, nc); SortedList slMaster1 = new SortedList(); ArrayList arrListItems = null; foreach (DictionaryEntry objOrderedItems in slorderedFoodItems) { clsOrderReport objItem = (clsOrderReport)objOrderedItems.Value; string keyValue = objOrderedItems.Key.ToString(); string[] splitter = new string[0]; splitter = keyValue.Split('-'); if (separatorNumber != Convert.ToInt32(splitter[0])) { separatorNumber = Convert.ToInt32(splitter[0]); arrListItems = new ArrayList(); arrListItems.Add(objItem); slMaster1.Add(separatorNumber, arrListItems); } else { arrListItems.Add(objItem); separatorNumber = Convert.ToInt32(splitter[0]); } } PrintUtility printUtility = new PrintUtility(); ArrayList alReverseOrderedItem; foreach (DictionaryEntry deReverseOrderedItem in slMaster1) { alReverseOrderedItem = (ArrayList)deReverseOrderedItem.Value; alReverseOrderedItem.Reverse();//Reversing the current item order. foreach (clsOrderReport objOrderedItems in alReverseOrderedItem) { if (separatorNumber != objOrderedItems.OrderNumber) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = objOrderedItems.FoodTypeName + ":" +"\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine += objOrderedItems.Quantity.ToString() + " "; //tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objOrderedItems.ItemName, 30); //tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objOrderedItems.Price.ToString("F02"), 6); tempSerialPrintContent.StringLine = strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + " " + printUtility.MultipleLine(objOrderedItems.ItemName, 32, objOrderedItems.Price.ToString("F02"), 37), ""); serialBody.Add(tempSerialPrintContent); separatorNumber = objOrderedItems.OrderNumber; } else { tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine += objOrderedItems.Quantity.ToString() + " "; //tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objOrderedItems.ItemName, 30); //tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objOrderedItems.Price.ToString("F02"), 6); tempSerialPrintContent.StringLine = strPrintFormatter.ItemLabeledText(objOrderedItems.Quantity.ToString() + " " + printUtility.MultipleLine(objOrderedItems.ItemName, 32, objOrderedItems.Price.ToString("F02"), 37), ""); serialBody.Add(tempSerialPrintContent); } } } #region "Non food items" tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CenterTextWithDashed("Drinks") + "\r\n"; // tempSerialPrintContent.StringLine = "-----------------Drinks-----------------" + "\r\n"; serialBody.Add(tempSerialPrintContent); SortedList slMaster2 = new SortedList(); ArrayList arrListItemsNonFood = new ArrayList(); separatorNumber = -1; foreach (DictionaryEntry objOrderedNonFood in slorderedNonFoodItems) { clsOrderReport objItem = (clsOrderReport)objOrderedNonFood.Value; string keyValue = objOrderedNonFood.Key.ToString(); string[] splitter = new string[0]; splitter = keyValue.Split('-'); if (separatorNumber != Convert.ToInt32(splitter[0])) { separatorNumber = Convert.ToInt32(splitter[0]); arrListItemsNonFood = new ArrayList(); arrListItemsNonFood.Add(objItem); slMaster2.Add(separatorNumber, arrListItemsNonFood); } else { arrListItemsNonFood.Add(objItem); separatorNumber = Convert.ToInt32(splitter[0]); } } separatorNumber = -1; bool istrue = false; foreach (DictionaryEntry objNonFood in slMaster2) { ArrayList alNonFoods = (ArrayList)objNonFood.Value; alNonFoods.Reverse(); foreach (clsOrderReport objNonFoodItem in alNonFoods) { if (separatorNumber != objNonFoodItem.OrderNumber) { tempSerialPrintContent = new CSerialPrintContent(); // tempSerialPrintContent.StringLine = "----------------------------------------"; serialBody.Add(tempSerialPrintContent); if (tempSerialPrintContent != null && tempSerialPrintContent.StringLine.Equals("") && !istrue) { tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = objNonFoodItem.FoodTypeName + ":" +"\r\n"; serialBody.Add(tempSerialPrintContent); } tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine += objNonFoodItem.Quantity.ToString() + " "; //tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objNonFoodItem.ItemName, 30); //tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objNonFoodItem.Price.ToString("F02"), 6); tempSerialPrintContent.StringLine = strPrintFormatter.ItemLabeledText(objNonFoodItem.Quantity.ToString() + " " + printUtility.MultipleLine(objNonFoodItem.ItemName, 32, objNonFoodItem.Price.ToString("F02"), 37), ""); serialBody.Add(tempSerialPrintContent); separatorNumber = objNonFoodItem.OrderNumber; istrue = true; } else { tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine += objNonFoodItem.Quantity.ToString() + " "; //tempSerialPrintContent.StringLine += CPrintMethods.GetFixedString(objNonFoodItem.ItemName, 30); //tempSerialPrintContent.StringLine += CPrintMethods.RightAlign(objNonFoodItem.Price.ToString("F02"), 6); tempSerialPrintContent.StringLine = strPrintFormatter.ItemLabeledText(objNonFoodItem.Quantity.ToString() + " " + printUtility.MultipleLine(objNonFoodItem.ItemName, 32, objNonFoodItem.Price.ToString("F02"), 37), ""); serialBody.Add(tempSerialPrintContent); } } } #endregion tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "----------------------------------------\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Total No Of Item: " + lblNoOfItemsSold.Text + "\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Total Qty: " + lblTotalQty.Text + "\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = "Total Item Amount: " + lblTotalAmount.Text + "\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); tempSerialPrintContent.StringLine = strPrintFormatter.CreateDashedLine() + "\r\n"; serialBody.Add(tempSerialPrintContent); tempSerialPrintContent = new CSerialPrintContent(); //tempSerialPrintContent.StringLine = strPrintFormatter.CenterTextWithWhiteSpace("Developed By: www.ibacs.co.uk") + "\r\n\n"; serialBody.Add(tempSerialPrintContent); #region "Testing printing area" string printingObject = ""; for (int arrayIndex = 0; arrayIndex < serialBody.Count; arrayIndex++) { printingObject += serialBody[arrayIndex].StringLine.ToString(); } this.WriteString(printingObject);///Write to a file when print command is executed #endregion //@aamr Remote Print CCommonConstants m_oCommonConstants; m_oCommonConstants = ConfigManager.GetConfig<CCommonConstants>(); CLogin oLogin = new CLogin(); oLogin = (RmsRemote.CLogin)Activator.GetObject(typeof(RmsRemote.CLogin), m_oCommonConstants.RemoteURL); CResult oResult = oLogin.GetInitialDBStr(); Object o = oLogin.GetType(); CPrintingFormat inPrintRequest = new CPrintingFormat(); inPrintRequest.Header = "Header"; inPrintRequest.Footer = "Footer"; inPrintRequest.Body = "Hello Remote Printing..."; try { oLogin.PostPrintingRequest(inPrintRequest); PostPrintingRequest1(inPrintRequest); } catch (Exception ex) { } CPrintMethodsEXT tempPrintMethods1 = new CPrintMethodsEXT(); DataSet tempDataSet = new DataSet(); tempDataSet.ReadXml("Config/Print_Config.xml"); if (Convert.ToBoolean(tempDataSet.Tables[0].Rows[0]["IsGuestBillPrinterSerial"]) == true) { // tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, serialBody, serialFooter, "SN".ToString()); tempPrintMethods.SerialPrint(PRINTER_TYPES.NORMAL_PRINTER, serialHeader, printingObject, serialFooter, "SN".ToString()); } else { tempPrintMethods1.USBPrint(printingObject, PrintDestiNation.CLIENT, true); } } } else { MessageBox.Show("There is no record", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void LoadModificationText() { SortedList slKitchenText = new SortedList(); SystemManager objSystem = new SystemManager(); CResult objCresult = new CResult(); objCresult = objSystem.GetAllSpecialModifyText(); slKitchenText = (SortedList)objCresult.Data; dgvKitchenText.RowCount = 0; foreach (clsSpecialModfifyText objSpecialText in slKitchenText.Values) { DataGridViewRowCollection dgvRow = (DataGridViewRowCollection)dgvKitchenText.Rows; dgvRow.Add(objSpecialText.SpecialModfifyTextId, objSpecialText.SpecialModfifyText); } dgvKitchenText.ClearSelection(); ContentTextBox.Clear(); //Initially clearing the text box }
private void btnUpdate_Click(object sender, EventArgs e) { try { Int32 kitchenTextID = Convert.ToInt32("0" + dgvKitchenText.CurrentRow.Cells[0].Value); string kitchenText = txtKitchenText.Text; SystemManager objSystem = new SystemManager(); if (m_specialModifyText == false) { objSystem.UpdateKitchenText(kitchenTextID, kitchenText); } else { objSystem.UpdateSpecialText(kitchenTextID, kitchenText); } this.LoadKitchenText(); } catch (Exception exp) { throw exp; } }
//private class ShiftWiseData //{ // private int _orderID; // private int _product_id; // private string _product_Name; // private string _amount; // private string _quantity; // private string _totalAmount; // private int _guest_count; // private int _cat_level; // private string _food_type; // public int OrderId // { // get { return _orderID; } // set { _orderID = value; } // } // public int ProductId // { // get { return _product_id; } // set { _product_id = value; } // } // public string ProductName // { // get { return _product_Name; } // set { _product_Name = value; } // } // public string Amount // { // get { return _amount; } // set { _amount = value; } // } // public string Quantity // { // get { return _quantity; } // set { _quantity = value; } // } // public string TotalAmount // { // get { return _totalAmount; } // set { _totalAmount = value; } // } // public int GuestCount // { // get { return _guest_count; } // set { _guest_count = value; } // } // public int CatLevel // { // get { return _cat_level; } // set { _cat_level = value; } // } // public string FoodType // { // get { return _food_type; } // set { _food_type = value; } // } //} private void button1_Click(object sender, EventArgs e) { //if (checkBoxDateRangeWise.Checked) //{ // DataSet dsSalesRecords = new DataSet(); // CResult objResult = new CResult(); // SystemManager objSystemMgnr = new SystemManager(); // m_htFoods = new Hashtable(); // m_htNonFoods = new Hashtable(); // DateTime dtStart = new DateTime(dtpStart.Value.Year, dtpStart.Value.Month, dtpStart.Value.Day, 0, 0, 0); // DateTime dtEnd = new DateTime(dtpEnd.Value.Year, dtpEnd.Value.Month, dtpEnd.Value.Day, 23, 59, 59); // objResult = objSystemMgnr.GetSalesRecordsForINV(dtStart.Ticks, dtEnd.Ticks); // dataGridView1.DataSource = null; // DataTable dt = (DataTable)objResult.Data; // // List<ShiftWiseData> listCSearchOrderInfoForShift = new List<ShiftWiseData>(); // var queryforShift = from cShiftOrderInfo in listCShiftOrderInfo // where cShiftOrderInfo.ShiftID == Convert.ToInt64(listCShiftSchedule[comboBoxshift.SelectedIndex].ShiftId) // select cShiftOrderInfo; // DataTable FilterTable = new DataTable(); // FilterTable = dt.Clone(); // foreach (var query in queryforShift.Select(item => (from summaryByOrder in dt.AsEnumerable() // where summaryByOrder.Field<Int64>("order_id") == item.OrderID // select summaryByOrder))) // { // FilterTable = query.CopyToDataTable(); // } // if (checkBoxISShift.Checked == true) // { // dt.Clear(); // dt = FilterTable; // } // tableReport = new DataTable(); // tableReport.Columns.Add("product_id", typeof(int)); // tableReport.Columns.Add("product_Name", typeof(string)); // tableReport.Columns.Add("amount", typeof(string)); // tableReport.Columns.Add("quantity", typeof(string)); // tableReport.Columns.Add("TotalAmount", typeof(string));// // tableReport.Columns.Add("guest_count", typeof(int)); // tableReport.Columns.Add("cat_level", typeof(int)); // tableReport.Columns.Add("food_type", typeof(string)); // if (dt != null || dt.Rows.Count > 0) // for (int i = 0; i < dt.Rows.Count; i++) // { // tableReport.Rows.Add(Convert.ToInt16(dt.Rows[i]["product_id"]), Convert.ToString(dt.Rows[i]["product_Name"]), Convert.ToDecimal(dt.Rows[i]["amount"].ToString()).ToString("F2"), dt.Rows[i]["quantity"].ToString(), Convert.ToDecimal(dt.Rows[i]["TotalAmount"].ToString()).ToString("F2"), Convert.ToInt16(dt.Rows[i]["guest_count"]), Convert.ToInt16(dt.Rows[i]["cat_level"]), dt.Rows[i]["food_type"].ToString()); // } // dataGridView1.AutoGenerateColumns = false; // dataGridView1.DataSource = tableReport; // decimal GrandTotal = 0, TotalQty = 0; // foreach (DataRow row in dt.Rows) // { // GrandTotal = GrandTotal + Convert.ToDecimal(row["TotalAmount"]); // TotalQty = TotalQty + Convert.ToDecimal(row["quantity"]); // } // lblTotalQty.Text = TotalQty.ToString(); // lblTotalAmount.Text = GrandTotal.ToString("F2"); // lblNoOfItemsSold.Text = (dt.Rows.Count).ToString(); // lblFromDate.Text = dtpStart.Text; // lblToDate.Text = dtpEnd.Text; // } // else // { DataSet dsSalesRecords = new DataSet(); CResult objResult = new CResult(); SystemManager objSystemMgnr = new SystemManager(); // DateTime dtNow = DateTime.Now; DateTime fromDate = new DateTime(); DateTime toDate = new DateTime(); //if (chkFromTime.Checked) //{ fromDate = new DateTime(dtpStart.Value.Year, dtpStart.Value.Month, dtpStart.Value.Day, 7, 0, 0); toDate = new DateTime(dtpEnd.Value.Year, dtpEnd.Value.Month, dtpEnd.Value.Day, 6, 59, 59); //} //else //{ // fromDate = new DateTime(dtpStart.Value.Year, dtpStart.Value.Month, dtpStart.Value.Day, 0, 0, 0); // toDate = new DateTime(dtpEnd.Value.Year, dtpEnd.Value.Month, dtpEnd.Value.Day, 23, 59, 59); //} toDate = toDate.AddDays(1); objResult = objSystemMgnr.GetSalesRecordsForINV(fromDate.Ticks, toDate.Ticks); dataGridView1.DataSource = null; DataTable dt = (DataTable)objResult.Data; tableReport = new DataTable(); tableReport.Columns.Add("product_id", typeof(int)); tableReport.Columns.Add("product_Name", typeof(string)); tableReport.Columns.Add("amount", typeof(string)); tableReport.Columns.Add("quantity", typeof(string)); tableReport.Columns.Add("TotalAmount", typeof(string)); tableReport.Columns.Add("guest_count", typeof(int)); tableReport.Columns.Add("cat_level", typeof(int)); tableReport.Columns.Add("food_type", typeof(string)); tableReport.Columns.Add("UoM", typeof(string)); tableReport.Columns.Add("productType", typeof(string)); if (dt != null || dt.Rows.Count > 0) for (int i = 0; i < dt.Rows.Count; i++) { //string ItemName = ""; //if (dt.Rows[i]["ItemName"].ToString() == "" && dt.Rows[i]["SelectionItemName"].ToString() == "") //{ // ItemName = dt.Rows[i]["Miscellaneous"].ToString(); //} //else //{ // ItemName = dt.Rows[i]["ItemName"].ToString(); // if (ItemName == "") // ItemName = dt.Rows[i]["SelectionItemName"].ToString(); //} tableReport.Rows.Add(Convert.ToInt16(dt.Rows[i]["product_id"]), Convert.ToString(dt.Rows[i]["product_Name"]), dt.Rows[i]["amount"].ToString(), dt.Rows[i]["quantity"].ToString(), dt.Rows[i]["TotalAmount"].ToString(), Convert.ToInt16(dt.Rows[i]["guest_count"]), Convert.ToInt16(dt.Rows[i]["cat_level"]), dt.Rows[i]["food_type"].ToString()); } dataGridView1.AutoGenerateColumns = false; dataGridView1.DataSource = tableReport; decimal GrandTotal = 0, TotalQty = 0; foreach (DataRow row in dt.Rows) { GrandTotal = GrandTotal + Convert.ToDecimal(row["TotalAmount"]); TotalQty = TotalQty + Convert.ToDecimal(row["quantity"]); } lblTotalQty.Text = TotalQty.ToString(); lblTotalAmount.Text = GrandTotal.ToString(); lblNoOfItemsSold.Text = (dt.Rows.Count).ToString(); lblFromDate.Text = dtpStart.Text; lblToDate.Text = dtpEnd.Text; // } }