private void cmbECategory_SelectedIndexChanged(object sender, EventArgs e) { try { if (checkSelectedIndexChange) { Category_BS cat = (Category_BS)cmbECategory.SelectedItem; Sales_BM sale = new Sales_BM(); List <Sales_BM> saleList = new List <Sales_BM>(); saleList = sale.getSalesByCatID(con, cat.ID); loadGrid(saleList); checkSelectedIndexChange = false; } else { checkSelectedIndexChange = false; } } catch (Exception ex) { MetroMessageBox.Show(this, "System Error " + ex.Message, "System Error !", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void txtProductName_TextChanged(object sender, EventArgs e) { try { if (txtProductName.Text == string.Empty) { return; } if (txtProductName.Text.Length > 0) { string pname = txtProductName.Text; Sales_BM sale = new Sales_BM(); List <Sales_BM> saleList = new List <Sales_BM>(); saleList = sale.getSalesByP_Name(con, pname); loadGrid(saleList); } } catch (Exception ex) { MetroMessageBox.Show(this, "! System Error. " + ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void loadGridIntial() { BusinessObjects.Sales_BM ss = new Sales_BM(); GridLoadedSalesList_Public.Clear(); GridLoadedSalesList_Public = ss.getSales(con); tblSales.Rows.Clear(); int i = 0; //MessageBox.Show(cObjList.Count.ToString()); foreach (BusinessObjects.Sales_BM item in GridLoadedSalesList_Public) { tblSales.Rows.Add(); tblSales.Rows[i].Cells[0].Value = item.sales_id.ToString(); tblSales.Rows[i].Cells[1].Value = item.customer_name; tblSales.Rows[i].Cells[2].Value = item.total.ToString(); tblSales.Rows[i].Cells[3].Value = item.date_time.ToString(); tblSales.Rows[i].Cells[4].Value = item.paid.ToString(); tblSales.Rows[i].Cells[5].Value = item.credit.ToString(); tblSales.Rows[i].Cells[6].Value = "View"; i++; } }
void InitialloadGrid() { try { List <Sales_BM> slist = new List <Sales_BM>(); Sales_BM sal = new Sales_BM(); slist = sal.getSalesCreditors(con); GridLoadedSalesList_Public = slist; tblSales.Rows.Clear(); int i = 0; foreach (BusinessObjects.Sales_BM item in slist) { tblSales.Rows.Add(); tblSales.Rows[i].Cells[0].Value = item.sales_id.ToString(); tblSales.Rows[i].Cells[1].Value = item.customer_name; tblSales.Rows[i].Cells[2].Value = item.total.ToString(); tblSales.Rows[i].Cells[3].Value = item.date_time.ToString(); tblSales.Rows[i].Cells[4].Value = item.paid.ToString(); tblSales.Rows[i].Cells[5].Value = item.credit.ToString(); tblSales.Rows[i].Cells[6].Value = "View"; tblSales.Rows[i].Cells[7].Value = "Update"; i++; } } catch (Exception ex) { MetroMessageBox.Show(this, "! System Error . Code 104. " + ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSearch_Click(object sender, EventArgs e) { DateTime sDate = Convert.ToDateTime(dateStart.Text); DateTime eDate = Convert.ToDateTime(dateEnd.Text); List <Sales_BM> salesList = new List <Sales_BM>(); Sales_BM sales = new Sales_BM(); salesList = sales.getSalesByDate(con, sDate, eDate); // GridLoadedSalesList_Public = salesList; loadGrid(salesList); }
private void txtReceiptNo_TextChanged(object sender, EventArgs e) { try { if (txtReceiptNo.Text == string.Empty) { return; } if (txtReceiptNo.Text.Length > 0) { int sid = Convert.ToInt32(txtReceiptNo.Text); Sales_BM sale = new Sales_BM(); sale.sales_id = sid; List <Sales_BM> saleList = new List <Sales_BM>(); sale = sale.getSalesByID(con); SalesList_Public.Clear(); SalesList_Public.Add(sale); tblSales.Rows.Clear(); int i = 0; foreach (BusinessObjects.Sales_BM item in SalesList_Public) { tblSales.Rows.Add(); tblSales.Rows[i].Cells[0].Value = item.sales_id.ToString(); tblSales.Rows[i].Cells[1].Value = item.customer_name; tblSales.Rows[i].Cells[2].Value = item.total.ToString(); tblSales.Rows[i].Cells[3].Value = item.date_time.ToString(); tblSales.Rows[i].Cells[4].Value = item.paid.ToString(); tblSales.Rows[i].Cells[5].Value = item.credit.ToString(); tblSales.Rows[i].Cells[6].Value = "View"; i++; } } } catch (Exception ex) { MetroMessageBox.Show(this, "! System Error. " + ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void autoComplete() { try { txtReceiptNo.AutoCompleteMode = AutoCompleteMode.Suggest; txtReceiptNo.AutoCompleteSource = AutoCompleteSource.CustomSource; txtProductName.AutoCompleteMode = AutoCompleteMode.Suggest; txtProductName.AutoCompleteSource = AutoCompleteSource.CustomSource; AutoCompleteStringCollection stringColl = new AutoCompleteStringCollection(); AutoCompleteStringCollection stringColl2 = new AutoCompleteStringCollection(); BusinessObjects.M_Product_BS p = new M_Product_BS(); BusinessObjects.Sales_BM s = new Sales_BM(); List <M_Product_BS> PList = new List <M_Product_BS>(); List <Sales_BM> SList = new List <Sales_BM>(); PList = p.GetProducts(con); SList = s.getSales(con); SalesList_Public = SList; foreach (M_Product_BS item in PList) { // stringColl.Add(item.ID.ToString()); stringColl.Add(item.name); } foreach (Sales_BM item in SList) { stringColl2.Add(item.sales_id.ToString()); } txtProductName.AutoCompleteCustomSource = stringColl; txtReceiptNo.AutoCompleteCustomSource = stringColl2; } catch (Exception ex) { MetroMessageBox.Show(this, "! System Error . Code 104. " + ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void loadTodaySale() { DateTime sDate = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy")); DateTime eDate = Convert.ToDateTime(DateTime.Now.AddDays(+1).ToString("MM/dd/yyyy")); List <Sales_BM> salesList = new List <Sales_BM>(); Sales_BM sales = new Sales_BM(); SalesList_Public = salesList = sales.getSalesByDate(con, sDate, eDate); // chartTodaySale.Series["Sales"].ChartArea = "ChartArea1"; foreach (var item in salesList) { decimal cash = 0; cash = (item.total > item.paid) ? item.paid : item.total; this.chartTodaySale.Series["Sales"].Points.AddXY(item.customer_name, item.total); this.chartTodaySale.Series["Cash"].Points.AddY(cash); } }
private void btnSearch_Click(object sender, EventArgs e) { try { DateTime sDate = Convert.ToDateTime(dateStart.Text); DateTime eDate = Convert.ToDateTime(dateEnd.Text); List <Sales_BM> salesList = new List <Sales_BM>(); Sales_BM sales = new Sales_BM(); salesList = sales.getSalesByDateCredit(con, sDate, eDate); // GridLoadedSalesList_Public = salesList; loadGrid(salesList); } catch (Exception ex) { MetroMessageBox.Show(this, "! System Error . Code 104. " + ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnupdate_Click(object sender, EventArgs e) { try { if (txtPName.Text == "" || txtPName.Text == string.Empty || txtDesc.Text == string.Empty || txtQuantity.Text == string.Empty) { MessageBox.Show("Incomplete Data!"); return; } if (!tglTempStockRecord.Checked) { if (cmbSupplier.SelectedIndex == -1 || txtStockDate.Text == string.Empty) { MessageBox.Show("Incomplete Data!"); return; } } int typed = Convert.ToInt32(txtQuantity.Text); if (typed == 0 || typed > quantity) { txtQuantity.Text = quantity.ToString(); MessageBox.Show("Please enter valid data!"); return; } using (TransactionScope txScope = new TransactionScope()) { //firstly update the sales product table int returnQuantity = Convert.ToInt32(txtQuantity.Text); string desc = txtDesc.Text; sales_product SalePro = new sales_product(); Sales_BM saleObject = new Sales_BM(); int stepOneCount = 0; BusinessObjects.SalesReturn salesReturnObject = new BusinessObjects.SalesReturn(); if (quantity == returnQuantity) { //delete record from sales_product SalePro.DeleteSalesReturn(con, sales_id, ProdID);//this will delete the relevant product from sales product data //calculating new amount decimal deletedAMount = quantity * soldPrice; saleObject = saleObject.getSalesByIDSalesReturn(con, sales_id);//getting the relevant sales data decimal newTotal = saleObject.total - deletedAMount; decimal newCredit = newTotal - saleObject.paid; //update the sales table saleObject.UpdateSalesReturn(con, newTotal, newCredit);//updating amount and the credit of that sales //insert to sales return table int salesReturnTableCount = 0; salesReturnTableCount = salesReturnObject.GetCountSalesReturn(con, sales_id); if (salesReturnTableCount > 0) { int salesReturnProductTableCount = 0; salesReturnProductTableCount = salesReturnObject.GetCountSalesProduct(con, sales_id, ProdID); decimal ReturnAMount = returnQuantity * soldPrice; if (salesReturnProductTableCount > 0) { string salesReturnProductsQuery = @"update sales_return_products set quantity= quantity + " + returnQuantity + " where product_id=" + ProdID + " AND sales_id=" + sales_id + ""; salesReturnObject.ExecuteNonQuery(salesReturnProductsQuery, con); } else { string salesReturnProductsQuery = @"insert sales_return_products (product_id, sales_id, quantity, product_sold_price) values (" + ProdID + "," + sales_id + "," + returnQuantity + "," + soldPrice + ")"; salesReturnObject.ExecuteNonQuery(salesReturnProductsQuery, con); } } else { string salesReturnQuery = @"insert sales_return (sales_id, Total, _date, customer,paid) values (" + saleObject.sales_id + "," + saleObject.total + ",'" + saleObject.date_time.ToString("G", DateTimeFormatInfo.InvariantInfo) + "','" + saleObject.customer_name + "'," + saleObject.paid + ")"; salesReturnObject.ExecuteNonQuery(salesReturnQuery, con); string salesReturnProductsQuery = @"insert sales_return_products (product_id, sales_id, quantity, product_sold_price) values (" + ProdID + "," + sales_id + "," + returnQuantity + "," + soldPrice + ")"; salesReturnObject.ExecuteNonQuery(salesReturnProductsQuery, con); } } else { //updating sale_product table int newQuantity = quantity - returnQuantity; decimal newTotalSalesProductPrice = newQuantity * soldPrice; SalePro.UpdateSalesReturn(con, sales_id, ProdID, newQuantity, newTotalSalesProductPrice); // //update the sales table decimal deletedAMount = returnQuantity * soldPrice; saleObject = saleObject.getSalesByIDSalesReturn(con, sales_id); decimal newTotal = saleObject.total - deletedAMount; decimal newCredit = newTotal - saleObject.paid; saleObject.UpdateSalesReturn(con, newTotal, newCredit); //insert to sales return table int salesReturnTableCount = 0; salesReturnTableCount = salesReturnObject.GetCountSalesReturn(con, sales_id); if (salesReturnTableCount > 0) { int salesReturnProductTableCount = 0; salesReturnProductTableCount = salesReturnObject.GetCountSalesProduct(con, sales_id, ProdID); decimal ReturnAMount = returnQuantity * soldPrice; if (salesReturnProductTableCount > 0) { //int countAvalQun= salesReturnProductTableCount = salesReturnObject.GetQuantitySalesProduct(con, sales_id, ProdID); //int newQuanttt = returnQuantity + countAvalQun; string salesReturnProductsQuery = @"update sales_return_products set quantity=quantity+" + returnQuantity + " where product_id=" + ProdID + " AND sales_id=" + sales_id + ""; salesReturnObject.ExecuteNonQuery(salesReturnProductsQuery, con); } else { string salesReturnProductsQuery = @"insert sales_return_products (product_id, sales_id, quantity, product_sold_price) values (" + ProdID + "," + sales_id + "," + returnQuantity + "," + soldPrice + ")"; salesReturnObject.ExecuteNonQuery(salesReturnProductsQuery, con); } } else { string salesReturnQuery = @"insert sales_return (sales_id, Total, _date, customer,paid) values (" + saleObject.sales_id + "," + saleObject.total + ",'" + saleObject.date_time.ToString("G", DateTimeFormatInfo.InvariantInfo) + "','" + saleObject.customer_name + "'," + saleObject.paid + ")"; salesReturnObject.ExecuteNonQuery(salesReturnQuery, con); string salesReturnProductsQuery = @"insert sales_return_products (product_id, sales_id, quantity, product_sold_price) values (" + ProdID + "," + sales_id + "," + returnQuantity + "," + soldPrice + ")"; salesReturnObject.ExecuteNonQuery(salesReturnProductsQuery, con); } } int SalesTableProductCount = salesReturnObject.GetCountSalesProductTable(con, sales_id); if (SalesTableProductCount == 0) { string salesDeleteQueru = @"Delete from _Sales where sales_id=" + sales_id + ""; salesReturnObject.ExecuteNonQuery(salesDeleteQueru, con); } //update the stock data here********************************************************************* // returnQuantity ProdID cmbSupplier.SelectedIndex txtStockInvoice.text; #region removed_by_new_code /* * #region if * if (tglTempStockRecord.Checked) * { * //string invoiceNum = txtStockInvoice.Text; * string custStockName = "SalesReturnStock"; * string getTemStockRecordExistece = @"select stock_id from _Stokc where sup_name='" + custStockName + "'"; * int existence= 0; * if (BusinessObjects.SalesReturn.getScalar(con, getTemStockRecordExistece) != DBNull.Value) * { * object temPonj=BusinessObjects.SalesReturn.getScalar(con, getTemStockRecordExistece); * if (temPonj != null) * existence = (int)temPonj; * } * if (existence > 0)//this means the temp sales return data is in stock table * { * string getCountOfstokcreturn = @"select quantity from _stock_product where pid=" + ProdID + " AND stock_id='" + existence + "'"; * int AllreadyAvaliableQuant = 0; * if (BusinessObjects.SalesReturn.getScalar(con, getCountOfstokcreturn) != DBNull.Value) * { * object temPobj = BusinessObjects.SalesReturn.getScalar(con, getCountOfstokcreturn); * if (temPobj != null) * AllreadyAvaliableQuant = (int)temPobj; * } * if (AllreadyAvaliableQuant > 0) * { * int newQuan = AllreadyAvaliableQuant + returnQuantity; * * string stockProductUpdateQuery = @"update _stock_product set quantity=" + newQuan + " where pid=" + ProdID + " and stock_id =" + existence + ""; * * salesReturnObject.ExecuteNonQuery(stockProductUpdateQuery, con); * } * else * { * * string stockProductInsertQuery = @"insert _stock_product (pid,quantity,stock_id) values(" + ProdID + "," + returnQuantity + "," + existence + ") "; * salesReturnObject.ExecuteNonQuery(stockProductInsertQuery, con); * * } * } * else //this means the temp stock return data is not availeble in stock table. * { * //addign data to stock table first (SalesReturn Temp Record) * string addTempStockData = @"insert _Stokc (sup_name,s_date,invoice_no) values('SalesReturnStock','" + DateTime.Now.ToString("G", DateTimeFormatInfo.InvariantInfo) + "','00000') "; * salesReturnObject.ExecuteNonQuery(addTempStockData, con); * * //getting last inserted ID * string querySI = @"select IDENT_CURRENT('_Stokc')"; * int lastInsertedID = Convert.ToInt32(Sales_BM.getScalar(con, querySI)); * * //now we add data the the stock product table * string AfterInsertSPQuery = @"insert _stock_product (pid,quantity,stock_id) values(" + ProdID + "," + returnQuantity + "," + lastInsertedID + ") "; * salesReturnObject.ExecuteNonQuery(AfterInsertSPQuery, con); * } * } #endregion #region else * else * { * //string invoiceNum = txtStockInvoice.Text; * int stockIDRt=Convert.ToInt32(txtStokIDRetrieved.Text); * string getCountOfstokcreturn = @"select quantity from _stock_product where pid=" + ProdID + " AND stock_id='" + stockIDRt + "'"; * int AllreadyAvaliableQuant=0; * if (BusinessObjects.SalesReturn.getScalar(con, getCountOfstokcreturn) != DBNull.Value) * { * object objTemp=BusinessObjects.SalesReturn.getScalar(con, getCountOfstokcreturn); * if (objTemp != null) * AllreadyAvaliableQuant = (int)objTemp; * } * if (AllreadyAvaliableQuant > 0) * { * int newQuan=AllreadyAvaliableQuant+returnQuantity; * * string stockProductUpdateQuery = @"update _stock_product set quantity=" + newQuan + " where pid=" + ProdID + " and stock_id =" + stockIDRt + ""; * * salesReturnObject.ExecuteNonQuery(stockProductUpdateQuery, con); * } * else * { * string stockProductInsertQuery = @"insert _stock_product (pid,quantity,stock_id) values(" + ProdID + "," + returnQuantity + "," + stockIDRt + ") "; * salesReturnObject.ExecuteNonQuery(stockProductInsertQuery, con); * } * //returnQuantity;ProdID * // cmbSupplier.SelectedIndex * } #endregion * */ #endregion int stockIDD = Convert.ToInt32(cmbSupplier.SelectedValue.ToString()); updateStock(ProdID, stockIDD, returnQuantity); txScope.Complete();//transaction commit MetroMessageBox.Show(this, "Transaction Complete ", "Process completed", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } catch (Exception ex) { MetroMessageBox.Show(this, "System Error " + ex.Message, "System Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void updateStock(int productID, int StockID, int Quanityt) { int existenceStockTable = 0; int existenceStockProductTable = 0; BusinessObjects.SalesReturn salesReturnObject = new BusinessObjects.SalesReturn(); string queryExistenseStockTable = "select count (*) from _Stokc where stock_id=" + StockID + " "; object objTemp = BusinessObjects.SalesReturn.getScalar(con, queryExistenseStockTable); if (objTemp != null) { existenceStockTable = (int)objTemp; } if (existenceStockTable > 0) { string queryExistenseStockProductTable = @"select count (*) from _stock_product where stock_id=" + StockID + " and pid=" + productID + " "; object objTemp2 = BusinessObjects.SalesReturn.getScalar(con, queryExistenseStockProductTable); if (objTemp2 != null) { existenceStockProductTable = (int)objTemp; } if (existenceStockProductTable > 0) { //update the stoc_product table string updateQuerySP1 = @"update _stock_product set quantity=quantity+" + Quanityt + " where pid=" + ProdID + " and stock_id =" + StockID + ""; salesReturnObject.ExecuteNonQuery(updateQuerySP1, con); } else { //add to the stockProduct table decimal cost = 0; string selectQuerySotkcProductDetails = @"select cost from purchase_product where stock_id=" + StockID + " and pid=" + productID + " "; object objTemp3 = BusinessObjects.SalesReturn.getScalar(con, selectQuerySotkcProductDetails); if (objTemp3 != null) { cost = (decimal)objTemp3; } string stockProductInsert = @"insert _stock_product (pid,quantity,stock_id,price) values(" + ProdID + "," + Quanityt + "," + StockID + ",'" + cost + "') "; salesReturnObject.ExecuteNonQuery(stockProductInsert, con); } } else { //add to stock Purchase pm = new Purchase(); pm = pm.GetPurchaseAndPProdBySID(con, StockID); string queryGetSupID = @"select Id from Supplier where Name='" + pm.sup_name + "'"; int supID = 1; object objTemp4 = BusinessObjects.SalesReturn.getScalar(con, queryGetSupID); if (objTemp4 != null) { supID = (int)objTemp4; } string o = "(return)"; string insertStock = @"insert _Stokc (sup_name,s_date,invoice_no,Sup_id) values('" + pm.sup_name + o + "','" + pm.s_date.ToString("G", DateTimeFormatInfo.InvariantInfo) + "','" + pm.invoice_no + "'," + supID + ") "; salesReturnObject.ExecuteNonQuery(insertStock, con); //getting last inserted ID string queryx = @"select IDENT_CURRENT('_Stokc')"; int lastInsertedID = Convert.ToInt32(Sales_BM.getScalar(con, queryx)); //adding stock product stock_product sp = new stock_product(); sp.price = pm.StockProductList.Find(prod => prod.pid == productID).cost; sp.quantity = Quanityt; sp.stock_id = lastInsertedID; sp.pid = ProdID; sp.Add(con); } }
void loadCharts() { try { //this.salesChartLine.Series["SALES"].Points.AddXY("dues",1500); //this.salesChartLine.Series["SALES"].Points.AddXY("Blaow", 1800); //this.salesChartLine.Series["SALES"].Points.AddXY("dsa", 80); BusinessObjects.Sales_BM ss = new Sales_BM(); List <Sales_BM> salesList = new List <Sales_BM>(); List <salesByDateData> salesByDateList = new List <salesByDateData>(); DateTime dateNow = DateTime.Now; DateTime date10Before = dateNow.AddDays(-10); DateTime date9Before = dateNow.AddDays(-9); DateTime date8Before = dateNow.AddDays(-8); DateTime date7Before = dateNow.AddDays(-7); DateTime date6Before = dateNow.AddDays(-6); DateTime date5Before = dateNow.AddDays(-5); DateTime date4Before = dateNow.AddDays(-4); DateTime date3Before = dateNow.AddDays(-3); DateTime date2Before = dateNow.AddDays(-2); DateTime date1Before = dateNow.AddDays(-1); salesByDateData filterObj10 = new salesByDateData(); salesByDateData filterObj9 = new salesByDateData(); salesByDateData filterObj8 = new salesByDateData(); salesByDateData filterObj7 = new salesByDateData(); salesByDateData filterObj6 = new salesByDateData(); salesByDateData filterObj5 = new salesByDateData(); salesByDateData filterObj4 = new salesByDateData(); salesByDateData filterObj3 = new salesByDateData(); salesByDateData filterObj2 = new salesByDateData(); salesByDateData filterObj1 = new salesByDateData(); salesByDateData filterObjNow = new salesByDateData(); salesList = ss.getSalesByDate(con, date10Before, dateNow); foreach (var item in salesList) { if (item.date_time.Date == date10Before.Date) { filterObj10.amount += item.total; filterObj10.date_time = item.date_time; if (item.total > item.paid) { filterObj10.paid += item.paid; Decimal temSto = 0; temSto = item.total - item.paid; filterObj10.credit += temSto; } else { filterObj10.paid += item.total; filterObj10.credit += 0; } } if (item.date_time.Date == date9Before.Date) { filterObj9.amount += item.total; filterObj9.date_time = item.date_time; if (item.total > item.paid) { filterObj9.paid += item.paid; Decimal temSto = 0; temSto = item.total - item.paid; filterObj9.credit += temSto; } else { filterObj9.paid += item.total; filterObj9.credit += 0; } } if (item.date_time.Date == date8Before.Date) { filterObj8.amount += item.total; filterObj8.date_time = item.date_time; if (item.total > item.paid) { filterObj8.paid += item.paid; Decimal temSto = 0; temSto = item.total - item.paid; filterObj8.credit += temSto; } else { filterObj8.paid += item.total; filterObj8.credit += 0; } } if (item.date_time.Date == date7Before.Date) { filterObj7.amount += item.total; filterObj7.date_time = item.date_time; if (item.total > item.paid) { filterObj7.paid += item.paid; Decimal temSto = 0; temSto = item.total - item.paid; filterObj7.credit += temSto; } else { filterObj7.paid += item.total; filterObj7.credit += 0; } } if (item.date_time.Date == date6Before.Date) { filterObj6.amount += item.total; filterObj6.date_time = item.date_time; if (item.total > item.paid) { filterObj6.paid += item.paid; Decimal temSto = 0; temSto = item.total - item.paid; filterObj6.credit += temSto; } else { filterObj6.paid += item.total; filterObj6.credit += 0; } } if (item.date_time.Date == date5Before.Date) { filterObj5.amount += item.total; filterObj5.date_time = item.date_time; if (item.total > item.paid) { filterObj5.paid += item.paid; Decimal temSto = 0; temSto = item.total - item.paid; filterObj5.credit += temSto; } else { filterObj5.paid += item.total; filterObj5.credit += 0; } } if (item.date_time.Date == date4Before.Date) { filterObj4.amount += item.total; filterObj4.date_time = item.date_time; if (item.total > item.paid) { filterObj4.paid += item.paid; Decimal temSto = 0; temSto = item.total - item.paid; filterObj4.credit += temSto; } else { filterObj4.paid += item.total; filterObj4.credit += 0; } } if (item.date_time.Date == date3Before.Date) { filterObj3.amount += item.total; filterObj3.date_time = item.date_time; if (item.total > item.paid) { filterObj3.paid += item.paid; Decimal temSto = 0; temSto = item.total - item.paid; filterObj3.credit += temSto; } else { filterObj3.paid += item.total; filterObj3.credit += 0; } } if (item.date_time.Date == date2Before.Date) { filterObj2.amount += item.total; filterObj2.date_time = item.date_time; if (item.total > item.paid) { filterObj2.paid += item.paid; Decimal temSto = 0; temSto = item.total - item.paid; filterObj2.credit += temSto; } else { filterObj2.paid += item.total; filterObj2.credit += 0; } } if (item.date_time.Date == date1Before.Date) { filterObj1.amount += item.total; filterObj1.date_time = item.date_time; if (item.total > item.paid) { filterObj1.paid += item.paid; Decimal temSto = 0; temSto = item.total - item.paid; filterObj1.credit += temSto; } else { filterObj1.paid += item.total; filterObj1.credit += 0; } } if (item.date_time.Date == dateNow.Date) { filterObjNow.amount += item.total; filterObjNow.date_time = item.date_time; if (item.total > item.paid) { filterObjNow.paid += item.paid; Decimal temSto = 0; temSto = item.total - item.paid; filterObjNow.credit += temSto; } else { filterObjNow.paid += item.total; filterObjNow.credit += 0; } } } salesByDateList.Add(filterObj10); salesByDateList.Add(filterObj9); salesByDateList.Add(filterObj8); salesByDateList.Add(filterObj7); salesByDateList.Add(filterObj6); salesByDateList.Add(filterObj5); salesByDateList.Add(filterObj4); salesByDateList.Add(filterObj3); salesByDateList.Add(filterObj2); salesByDateList.Add(filterObj1); salesByDateList.Add(filterObjNow); //salesChartLine.Series.Add("Sales"); //salesChartLine.Series["Sales"].ChartType = SeriesChartType.Area; //salesChartLine.Palette = ChartColorPalette.None; //salesChartLine.PaletteCustomColors = new Color[] { Color.Red, Color.Blue, Color.Yellow }; ////salesChartLine.Series["Sales"].Points.AddXY( (10); salesChartLine.Series["Sales"].ChartArea = "ChartArea1"; foreach (var item in salesByDateList) { int date = Convert.ToInt32(item.date_time.Day); int month = Convert.ToInt32(item.date_time.Month); this.salesChartLine.Series["Sales"].Points.AddXY(month.ToString() + "/" + date.ToString(), Convert.ToInt32(item.amount)); this.salesChartLine.Series["Cash"].Points.AddY(item.paid); this.salesChartLine.Series["Credit"].Points.AddY(item.credit); } } catch (Exception ex) { MetroMessageBox.Show(this, "! System Error . Code 104. " + ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void loadParam() { string text = ""; Sales_BM sale = new Sales_BM(); sale.sales_id = sales_id; sale = sale.getSalesByID(connString2); if (sale.credit > 0) { text = "Credit"; } else { text = "Balance"; } Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[] { new Microsoft.Reporting.WinForms.ReportParameter("ReportParamSales", sales_id.ToString()), new Microsoft.Reporting.WinForms.ReportParameter("paramCustName", name.ToString()), new Microsoft.Reporting.WinForms.ReportParameter("paramAddress", addrs.ToString()), new Microsoft.Reporting.WinForms.ReportParameter("paramTotal", sale.total.ToString()), new Microsoft.Reporting.WinForms.ReportParameter("paramPayment", sale.paid.ToString()), new Microsoft.Reporting.WinForms.ReportParameter("ReportParamBalance", sale.credit.ToString()), new Microsoft.Reporting.WinForms.ReportParameter("paramBC", text), new Microsoft.Reporting.WinForms.ReportParameter("paramDate", sale.date_time.ToString("dd-MMM-yyyy")) }; reportViewer1.LocalReport.SetParameters(param); BusinessObjects.Print print = new Print(); // string connString2 = @"Data Source=SURESH\SQLEXPRESS;Initial Catalog=FutureSoft;Integrated Security=True"; print = print.GetP(connString2); PrintDialog printDialog = new PrintDialog(); PrintDocument printDocument = new PrintDocument(); printDialog.Document = printDocument; //printDocument.PrintPage +=new PrintPageEventHandler(printDocument_PrintPage); printDocument.PrinterSettings.PrinterName = print.PrinterName; printDocument.DefaultPageSettings.PaperSize = printDocument.PrinterSettings.PaperSizes[print.PaperSize]; printDocument.DefaultPageSettings.PaperSource = printDocument.PrinterSettings.PaperSources[print.Source]; printDocument.DefaultPageSettings.PrinterResolution = printDocument.PrinterSettings.PrinterResolutions[print.Resolution]; printDocument.DefaultPageSettings.Margins.Left = 4; printDocument.DefaultPageSettings.Margins.Right = 4; printDocument.DefaultPageSettings.Margins.Top = 5; printDocument.DefaultPageSettings.Margins.Bottom = 8; printDocument.DocumentName = "Vista_Receipt"; printDocument.DefaultPageSettings.PrinterSettings.MaximumPage = 1; printDocument.DefaultPageSettings.PrinterSettings.Duplex = Duplex.Vertical; reportViewer1.SetPageSettings(printDocument.DefaultPageSettings); // printDocument.PrintPage += printDocument_PrintPage2; //printDocument.Print(); }
private void btnAdd_Click(object sender, EventArgs e) { //Thread t = new Thread(new ThreadStart(GifLoadingSaveSales)); try { if (txtSupName.SelectedValue == null) { MessageBox.Show("Invalid Supplier Name"); txtSupName.ResetText(); txtSupName.DataSource = null; txtSupName.DataSource = bank; txtSupName.ValueMember = "Id"; txtSupName.DisplayMember = "Company"; return; } if (txtSupName.Text == "SalesReturnStock") { MetroMessageBox.Show(this, "Selected suppilier name is system reserved keyword. You can't use this record, Please try another suppilier name or add a new name", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //MessageBox.Show(txtSupName.SelectedValue.ToString()); //MessageBox.Show(txtSupName.Text.ToString()); if (string.IsNullOrEmpty(txtSupName.Text) || string.IsNullOrEmpty(txtInvoiceNo.Text) || string.IsNullOrEmpty(txtStockID.Text) || string.IsNullOrEmpty(cmbDate.Text) || txtSupName.SelectedValue == null) { MetroMessageBox.Show(this, "Please enter valid data to the text fields", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } bool resul = stock_product_list.Any(); if (!resul) { MessageBox.Show("No Product details were added to the stock"); return; } else { // t.Start(); using (TransactionScope txScope = new TransactionScope()) { DateTime d; d = Convert.ToDateTime(cmbDate.Text); int stockID = Convert.ToInt32(txtStockID.Text); string supName = txtSupName.Text; string invoiceNo = txtInvoiceNo.Text; Stock stock = new Stock(); stock.invoice_no = invoiceNo; stock.stock_id = stockID; stock.sup_name = supName; stock.s_date = d; stock.Sup_id = Convert.ToInt32(txtSupName.SelectedValue.ToString()); if (stock.Add(con)) { string query = @"select IDENT_CURRENT('_Stokc')"; int lastInsertedID = Convert.ToInt32(Sales_BM.getScalar(con, query)); stockID = lastInsertedID; int count = 0; foreach (var item in stock_product_list) { item.stock_id = lastInsertedID; item.Add(con); count++; } int cehckPurchase = 0; Purchase pr = new Purchase(); if (pr.AddPurchase(con, lastInsertedID)) { pr.AddPurchaseProduct(con, lastInsertedID); cehckPurchase++; } // t.Abort(); if (cehckPurchase > 0 && count > 0) { txScope.Complete();//transaction commit //MessageBox.Show("Products were added"); PopupNotifier pop = new PopupNotifier(); pop.ContentText = "Products Stock data stored to the system"; pop.TitleText = "Notification"; pop.Image = Resources.success_48; // or Image.FromFile(--Path--) pop.IsRightToLeft = false; pop.ContentHoverColor = Color.Teal; pop.Popup(); MetroMessageBox.Show(this, "Stock Details stored to the system. :-P ", "Successfull!", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); refresh(); } else { MetroMessageBox.Show(this, "Something Went Wrong. Please restrart the form and try again... ", "Unexpected Interuption!", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop); } } else { // t.Abort(); MetroMessageBox.Show(this, "Something Went Wrong. Please restrart the form and try again... ", "Unexpected Interuption!", MessageBoxButtons.OKCancel, MessageBoxIcon.Stop); } }//end of using statement } } catch (Exception ex) { //t.Abort(); MetroMessageBox.Show(this, ex.Message, "System Error!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } finally { // t.Abort(); } }