private void btnDelete_Click(object sender, EventArgs e) { try { DEWSRMEntities db = new DEWSRMEntities(); int[] selRows = ((GridView)grdColorInfos.MainView).GetSelectedRows(); DataRowView oColorInfosID = (DataRowView)(((GridView)grdColorInfos.MainView).GetRow(selRows[0])); int nColorInfosID = Convert.ToInt32(oColorInfosID["ColorInfosID"]); INVENTORY.DA.Color oColorInfo = db.Colors.FirstOrDefault(p => p.ColorID == nColorInfosID); if (oColorInfo == null) { MessageBox.Show("select an item to delete", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBox.Show("Do you want to delete the selected item?", "Delete Setup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { db.Colors.Attach(oColorInfo); db.Colors.Remove(oColorInfo); db.SaveChanges(); MessageBox.Show("Data Deleted Successfully.", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information); RefreshList(); } } catch (Exception Ex) { MessageBox.Show("Cannot delete item due to " + Ex.Message); } }
private void btnEdit_Click(object sender, EventArgs e) { try { using (DEWSRMEntities db = new DEWSRMEntities()) { int[] selRows = ((GridView)grdColorInfos.MainView).GetSelectedRows(); DataRowView oColorInfosD = (DataRowView)(((GridView)grdColorInfos.MainView).GetRow(selRows[0])); int nColorInfosID = Convert.ToInt32(oColorInfosD["ColorInfosID"]); INVENTORY.DA.Color oColorInfo = db.Colors.FirstOrDefault(p => p.ColorID == nColorInfosID); if (oColorInfo == null) { MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } fColorInfo frm = new fColorInfo(); frm.ItemChanged = RefreshList; frm.ShowDlg(oColorInfo, false); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void ShowDlg(INVENTORY.DA.Color oColInfo, bool IsNew) { _IsNew = IsNew; _ColorInfo = oColInfo; RefreshValue(); this.ShowDialog(); }
private void grdColors_MouseDoubleClick(object sender, MouseEventArgs e) { try { int[] selRows = ((GridView)grdColors.MainView).GetSelectedRows(); DataRowView oID = (DataRowView)(((GridView)grdColors.MainView).GetRow(selRows[0])); int nID = Convert.ToInt32(oID["ID"]); INVENTORY.DA.Color oColorInfo = null; if (nID > 0) { oColorInfo = db.Colors.FirstOrDefault(p => p.ColorID == nID); _ctl.SelectedID = oColorInfo.ColorID; _ctl.Code = oColorInfo.Description; } if (ItemChanged != null) { ItemChanged(); } this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void RefreshGrid() { try { int count = 0; int nSLNo = 1; dgProducts.Rows.Clear(); if (_ReturnDetails.Count != 0) { var RDData = (from rd in _ReturnDetails join std in _oStockDetailList on rd.SDetailID equals std.SDetailID group rd by new { rd.ProductID, std.ColorID } into g select new VMReturnDetail { ProductID = g.Key.ProductID, ColorID = g.Key.ColorID, Quantity = g.Sum(o => o.Quantity), UnitPrice = g.Select(o => o.UnitPrice).FirstOrDefault(), UTAmount = g.Sum(o => o.UTAmount) }); if (RDData.Count() > 0) { foreach (var oPODItem in RDData) { dgProducts.Rows.Add(); Product oProduct = _oProList.FirstOrDefault(o => o.ProductID == oPODItem.ProductID); // StockDetail oSDetail = _oStockDetailList.FirstOrDefault(sd => sd.SDetailID == oPODItem.SDetailID); INVENTORY.DA.Color oColor = _ColorList.FirstOrDefault(c => c.ColorID == oPODItem.ColorID); dgProducts.Rows[count].Cells[0].Value = nSLNo.ToString(); dgProducts.Rows[count].Cells[1].Value = oProduct.ProductName; dgProducts.Rows[count].Cells[2].Value = oProduct.Company.Description; dgProducts.Rows[count].Cells[3].Value = oProduct.Category.Description; dgProducts.Rows[count].Cells[4].Value = oColor.Description; dgProducts.Rows[count].Cells[5].Value = oPODItem.Quantity.ToString(); dgProducts.Rows[count].Cells[6].Value = oPODItem.UnitPrice.ToString(); dgProducts.Rows[count].Cells[7].Value = oPODItem.UTAmount.ToString(); dgProducts.Rows[count].Tag = oPODItem; count++; nSLNo++; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void RefreshGrid() { try { int count = 0; int nSLNo = 1; dgProducts.Rows.Clear(); if (_ReturnDetails != null) { if (_ReturnDetails.Count > 0) { foreach (ReturnDetail oPODItem in _ReturnDetails) { dgProducts.Rows.Add(); Product oProduct = _oProList.FirstOrDefault(o => o.ProductID == oPODItem.ProductID); StockDetail oSDetail = _oStockDetailList.FirstOrDefault(sd => sd.SDetailID == oPODItem.SDetailID); INVENTORY.DA.Color oColor = _ColorList.FirstOrDefault(c => c.ColorID == oSDetail.ColorID); dgProducts.Rows[count].Cells[0].Value = nSLNo.ToString(); dgProducts.Rows[count].Cells[1].Value = oProduct.ProductName; dgProducts.Rows[count].Cells[2].Value = oProduct.Company.Description; //dgProducts.Rows[count].Cells[3].Value = oColor.Description; dgProducts.Rows[count].Cells[3].Value = oProduct.Category.Description; dgProducts.Rows[count].Cells[4].Value = ""; dgProducts.Rows[count].Cells[5].Value = oPODItem.Quantity.ToString(); dgProducts.Rows[count].Cells[6].Value = oPODItem.UnitPrice.ToString(); dgProducts.Rows[count].Cells[7].Value = oPODItem.UTAmount.ToString(); dgProducts.Rows[count].Tag = oPODItem; count++; nSLNo++; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void RefreshList() { try { DataTable dt = new DataTable(); DataRow dr = null; dt.Columns.Add("ProductID"); dt.Columns.Add("Code"); dt.Columns.Add("Name"); dt.Columns.Add("Company"); dt.Columns.Add("SDetailID"); dt.Columns.Add("Category"); dt.Columns.Add("Size"); dt.Columns.Add("Color"); List <Product> ProductList = db.Products.ToList(); List <Category> CategoryList = db.Categorys.ToList(); List <Model> ModelList = db.Models.ToList(); List <Company> CompanyList = db.Companies.ToList(); List <StockDetail> StockDetailList = db.StockDetails.ToList(); List <INVENTORY.DA.Color> oColorList = db.Colors.ToList(); Product oProduct = null; Category oCategory = null; Company oCompany = null; Model oModel = null; INVENTORY.DA.Color oColor = null; if (_ObjectName == "SReturn") { StockDetail oStockDetail = null; var CustomerSOrderDetailList = db.SOrderDetails.Where(o => o.SOrder.CustomerID == _CustID && o.SOrder.Status == (int)EnumSalesType.Sales).ToList(); #region Barcode and Serial Product var ALLSOrderDetailsList = (from sod in CustomerSOrderDetailList join p in ProductList on sod.ProductID equals p.ProductID where p.ProductType != (int)EnumProductType.NoBarCode select sod).ToList(); var ALLDisSOrderDetailsList = (from d in ALLSOrderDetailsList group d by new { d.ProductID, d.StockDetailID } into g select new SOrderDetail { ProductID = g.Key.ProductID, StockDetailID = g.Key.StockDetailID }).ToList(); int nTempProId = 0; this.Text = "All Sales Products"; if (ALLDisSOrderDetailsList != null) { foreach (var grd in ALLDisSOrderDetailsList) { oProduct = ProductList.FirstOrDefault(s => s.ProductID == grd.ProductID); oCategory = CategoryList.FirstOrDefault(p => p.CategoryID == oProduct.CategoryID); oCompany = CompanyList.FirstOrDefault(p => p.CompanyID == oProduct.CompanyID); oModel = ModelList.FirstOrDefault(p => p.ModelID == oProduct.ModelID); oStockDetail = new StockDetail(); oStockDetail = StockDetailList.FirstOrDefault(p => p.SDetailID == grd.StockDetailID); oColor = oColorList.FirstOrDefault(c => c.ColorID == oStockDetail.ColorID); if (oStockDetail.Status == (int)EnumStockDetailStatus.Sold) { dr = dt.NewRow(); dr["ProductID"] = oProduct.ProductID; dr["Code"] = oProduct.Code; dr["Name"] = oProduct.ProductName; dr["Company"] = oCompany.Description; dr["Category"] = oCategory.Description; dr["SDetailID"] = grd.StockDetailID; dr["Color"] = oColor.Description; dr["Size"] = oStockDetail.IMENO; dt.Rows.Add(dr); } } } #endregion #region Nobarcode var ALLnobarcodeSODList = (from sod in CustomerSOrderDetailList join p in ProductList on sod.ProductID equals p.ProductID where p.ProductType == (int)EnumProductType.NoBarCode select sod).ToList(); if (ALLnobarcodeSODList.Count() != 0) { var ALLNobarcodeDisSODList = (from d in ALLnobarcodeSODList group d by new { d.StockDetailID } into g select new SOrderDetail { StockDetailID = g.Key.StockDetailID, }).ToList(); foreach (var grd in ALLNobarcodeDisSODList) { oStockDetail = new StockDetail(); oStockDetail = StockDetailList.FirstOrDefault(p => p.SDetailID == grd.StockDetailID); oProduct = ProductList.FirstOrDefault(s => s.ProductID == oStockDetail.ProductID); oCategory = CategoryList.FirstOrDefault(p => p.CategoryID == oProduct.CategoryID); oCompany = CompanyList.FirstOrDefault(p => p.CompanyID == oProduct.CompanyID); oModel = ModelList.FirstOrDefault(p => p.ModelID == oProduct.ModelID); oColor = oColorList.FirstOrDefault(c => c.ColorID == oStockDetail.ColorID); dr = dt.NewRow(); dr["ProductID"] = oProduct.ProductID; dr["Code"] = oProduct.Code; dr["Name"] = oProduct.ProductName; dr["Category"] = oCategory.Description; dr["Company"] = oCompany.Description; dr["SDetailID"] = grd.StockDetailID; dr["Color"] = oColor.Description; dr["Size"] = oStockDetail.IMENO; dt.Rows.Add(dr); } } #endregion grdProducts.DataSource = dt; lblTotal.Text = "Total :" + ALLSOrderDetailsList.Count().ToString(); // + ALLnobarcodeSODList.Sum(i => i.Quantity) } else if (_ObjectName == "PReturn") { StockDetail oStockDetail = null; int nCount = 0; var SuppPOrderDetailList = db.POrderDetails.Where(o => o.POrder.SupplierID == _CustID && o.POrder.Status == (int)EnumPurchaseType.Purchase).ToList(); #region Barcode and Serial Product var ALLSOrderDetailsList = (from sod in SuppPOrderDetailList join p in ProductList on sod.ProductID equals p.ProductID join std in db.StockDetails on sod.POrderDetailID equals std.POrderDetailID where p.ProductType != (int)EnumProductType.NoBarCode select new { sod, std }).ToList(); var ALLDisSOrderDetailsList = (from d in ALLSOrderDetailsList where d.std.Status == (int)EnumStockDetailStatus.Stock group d by new { d.std.SDetailID, d.std.ProductID, d.std.ColorID } into g select new { ProductID = g.Key.ProductID, SDetailID = g.Key.SDetailID, ColorID = g.Key.ColorID }).ToList(); //int nTempProId = 0; this.Text = "All Purchase Products"; if (ALLDisSOrderDetailsList != null && ALLDisSOrderDetailsList.Count > 0) { foreach (var grd in ALLDisSOrderDetailsList) { oProduct = ProductList.FirstOrDefault(s => s.ProductID == grd.ProductID); oCategory = CategoryList.FirstOrDefault(p => p.CategoryID == oProduct.CategoryID); oCompany = CompanyList.FirstOrDefault(p => p.CompanyID == oProduct.CompanyID); oModel = ModelList.FirstOrDefault(p => p.ModelID == oProduct.ModelID); oStockDetail = new StockDetail(); oStockDetail = StockDetailList.FirstOrDefault(p => p.SDetailID == grd.SDetailID); oColor = oColorList.FirstOrDefault(c => c.ColorID == oStockDetail.ColorID); if (oStockDetail.Status == (int)EnumStockDetailStatus.Stock) { dr = dt.NewRow(); dr["ProductID"] = oProduct.ProductID; dr["Code"] = oProduct.Code; dr["Name"] = oProduct.ProductName; dr["Company"] = oCompany.Description; dr["Category"] = oCategory.Description; dr["SDetailID"] = grd.SDetailID; dr["Color"] = oColor.Description; dr["Size"] = oStockDetail.IMENO; dt.Rows.Add(dr); } } } #endregion #region Nobarcode var ALLnobarcodeSODList = (from sod in SuppPOrderDetailList join p in ProductList on sod.ProductID equals p.ProductID where p.ProductType == (int)EnumProductType.NoBarCode select sod).ToList(); if (ALLnobarcodeSODList.Count() != 0) { var ALLNobarcodeDisSODList = (from d in ALLnobarcodeSODList group d by new { d.ProductID, d.ColorID } into g select new POrderDetail { // POrderDetailID=g.Key.POrderDetailID, ProductID = g.Key.ProductID, ColorID = g.Key.ColorID }).ToList(); //int nProductId = 0; //int nColorId = 0; foreach (var grd in ALLNobarcodeDisSODList) { oStockDetail = new StockDetail(); oStockDetail = StockDetailList.FirstOrDefault(p => p.ProductID == grd.ProductID && p.ColorID == grd.ColorID); oProduct = ProductList.FirstOrDefault(s => s.ProductID == oStockDetail.ProductID); oCategory = CategoryList.FirstOrDefault(p => p.CategoryID == oProduct.CategoryID); oCompany = CompanyList.FirstOrDefault(p => p.CompanyID == oProduct.CompanyID); oModel = ModelList.FirstOrDefault(p => p.ModelID == oProduct.ModelID); oColor = oColorList.FirstOrDefault(c => c.ColorID == oStockDetail.ColorID); dr = dt.NewRow(); dr["ProductID"] = oProduct.ProductID; dr["Code"] = oProduct.Code; dr["Name"] = oProduct.ProductName; dr["Category"] = oCategory.Description; dr["Company"] = oCompany.Description; dr["SDetailID"] = oStockDetail.SDetailID; dr["Color"] = oColor.Description; dr["Size"] = oStockDetail.IMENO; dt.Rows.Add(dr); nCount++; } } #endregion grdProducts.DataSource = dt; lblTotal.Text = "Total :" + nCount.ToString(); //+",Qty:"+ ALLnobarcodeSODList.Sum(i => i.Quantity) } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnPreview_Click(object sender, EventArgs e) { try { using (DEWSRMEntities db = new DEWSRMEntities()) { int nCount = 0; List <Stock> oStocks = null; if (rbCompany.Checked) { oStocks = db.Stocks.Where(s => s.Quantity > 0).OrderBy(s => s.Product.Company.Description).ThenBy(s => s.Product.Category.Description).ToList(); } else if (rbCategory.Checked) { oStocks = db.Stocks.Where(s => s.Quantity > 0).OrderBy(s => s.Product.Company.Description).ThenBy(s => s.Product.Category.Description).ToList(); } else if (rbModel.Checked) { oStocks = db.Stocks.Where(s => s.Quantity > 0).OrderBy(s => s.Product.Company.Description).ThenBy(s => s.Product.Category.Description).ToList(); } else if (rbColorCode.Checked) { oStocks = db.Stocks.Where(s => s.Quantity > 0).OrderBy(s => s.Product.Company.Description).ThenBy(s => s.Color.Code).ToList(); } if (ctlBrand.SelectedID > 0) { oStocks = db.Stocks.Where(s => s.Product.CompanyID == ctlBrand.SelectedID && s.Quantity > 0).OrderBy(s => s.Product.Company.Description).ThenBy(s => s.Product.Category.Description).ToList(); } else if (ctlCategory.SelectedID > 0) { oStocks = db.Stocks.Where(s => s.Product.CategoryID == ctlCategory.SelectedID && s.Quantity > 0).OrderBy(s => s.Product.Company.Description).ThenBy(s => s.Product.Category.Description).ToList(); } else if (ctlPreOrProduct.SelectedID > 0) { oStocks = db.Stocks.Where(s => s.Product.ProductID == ctlPreOrProduct.SelectedID && s.Quantity > 0).OrderBy(s => s.Product.Company.Description).ThenBy(s => s.Product.Category.Description).ToList(); } else if (ctlColor.SelectedID > 0) { oStocks = db.Stocks.Where(s => s.ColorID == ctlColor.SelectedID && s.Quantity > 0).OrderBy(s => s.Product.Company.Description).ThenBy(s => s.Product.Category.Description).ToList(); } List <Category> oCatList = db.Categorys.ToList(); List <Company> oComList = db.Companies.ToList(); List <INVENTORY.DA.Color> oColList = db.Colors.ToList(); List <Product> oProList = db.Products.ToList(); if (oStocks != null) { if (rbCategory.Checked || ctlCategory.SelectedID > 0) { nCount = 1; rptDataSet.StockInfoDataTable dt = new rptDataSet.StockInfoDataTable(); DataSet ds = new DataSet(); foreach (Stock oSTItem in oStocks) { Product oPro = oProList.FirstOrDefault(o => o.ProductID == oSTItem.ProductID); Category oCat = oCatList.FirstOrDefault(o => o.CategoryID == oPro.CategoryID); Company oCom = oComList.FirstOrDefault(o => o.CompanyID == oPro.CompanyID); dt.Rows.Add((EnumProductType)oPro.ProductType, ((DateTime)oSTItem.EntryDate).ToString("dd MMM yyyy"), oSTItem.StockCode, oCat.Description, oCom.Description, oSTItem.Product.ProductName, oSTItem.Color.Description, oSTItem.Quantity, oSTItem.PMPrice, (oSTItem.Quantity * oSTItem.PMPrice)); nCount++; } dt.TableName = "rptDataSet_StockInfo"; ds.Tables.Add(dt); string embededResource = "INVENTORY.UI.RDLC.rptCategoryWiseStock.rdlc"; List <ReportParameter> parameters = new List <ReportParameter>(); ReportParameter rParam = null; rParam = new ReportParameter("PrintedBy", Global.CurrentUser.UserName); parameters.Add(rParam); rParam = new ReportParameter("SLNO", nCount.ToString()); parameters.Add(rParam); fReportViewer frm = new fReportViewer(); if (dt.Rows.Count > 0) { frm.CommonReportViewer(embededResource, ds, parameters, true); } else { MessageBox.Show("No Recors Found.", "Report", MessageBoxButtons.OK, MessageBoxIcon.Information); } rbCategory.Checked = false; ctlCategory.SelectedID = 0; RefreshControl(); } else if (rbCompany.Checked || ctlBrand.SelectedID > 0) { nCount = 1; rptDataSet.StockInfoDataTable dt = new rptDataSet.StockInfoDataTable(); DataSet ds = new DataSet(); foreach (Stock oSTItem in oStocks) { Product oPro = oProList.FirstOrDefault(o => o.ProductID == oSTItem.ProductID); Category oCat = oCatList.FirstOrDefault(o => o.CategoryID == oPro.CategoryID); Company oCom = oComList.FirstOrDefault(o => o.CompanyID == oPro.CompanyID); dt.Rows.Add((EnumProductType)oPro.ProductType, ((DateTime)oSTItem.EntryDate).ToString("dd MMM yyyy"), oSTItem.StockCode, oCat.Description, oCom.Description, oSTItem.Product.ProductName, oSTItem.Color.Description, oSTItem.Quantity, oSTItem.PMPrice, (oSTItem.Quantity * oSTItem.PMPrice)); nCount++; } dt.TableName = "rptDataSet_StockInfo"; ds.Tables.Add(dt); string embededResource = "INVENTORY.UI.RDLC.rptCompanyWiseStock.rdlc"; List <ReportParameter> parameters = new List <ReportParameter>(); ReportParameter rParam = null; rParam = new ReportParameter("PrintedBy", Global.CurrentUser.UserName); parameters.Add(rParam); rParam = new ReportParameter("SLNO", nCount.ToString()); parameters.Add(rParam); fReportViewer frm = new fReportViewer(); if (dt.Rows.Count > 0) { frm.CommonReportViewer(embededResource, ds, parameters, true); } else { MessageBox.Show("No Recors Found.", "Report", MessageBoxButtons.OK, MessageBoxIcon.Information); } rbCompany.Checked = false; ctlBrand.SelectedID = 0; RefreshControl(); } else if (rbModel.Checked || ctlPreOrProduct.SelectedID > 0) { nCount = 1; rptDataSet.StockInfoDataTable dt = new rptDataSet.StockInfoDataTable(); DataSet ds = new DataSet(); foreach (Stock oSTItem in oStocks) { Product oPro = oProList.FirstOrDefault(o => o.ProductID == oSTItem.ProductID); Category oCat = oCatList.FirstOrDefault(o => o.CategoryID == oPro.CategoryID); Company oCom = oComList.FirstOrDefault(o => o.CompanyID == oPro.CompanyID); dt.Rows.Add((EnumProductType)oPro.ProductType, ((DateTime)oSTItem.EntryDate).ToString("dd MMM yyyy"), oSTItem.StockCode, oCat.Description, oCom.Description, oSTItem.Product.ProductName, oSTItem.Color.Description, oSTItem.Quantity, oSTItem.PMPrice, (oSTItem.Quantity * oSTItem.PMPrice)); nCount++; } dt.TableName = "rptDataSet_StockInfo"; ds.Tables.Add(dt); string embededResource = "INVENTORY.UI.RDLC.StockInfo.rdlc"; List <ReportParameter> parameters = new List <ReportParameter>(); ReportParameter rParam = null; rParam = new ReportParameter("PrintedBy", Global.CurrentUser.UserName); parameters.Add(rParam); rParam = new ReportParameter("SLNO", nCount.ToString()); parameters.Add(rParam); fReportViewer frm = new fReportViewer(); if (dt.Rows.Count > 0) { frm.CommonReportViewer(embededResource, ds, parameters, true); } else { MessageBox.Show("No Recors Found.", "Report", MessageBoxButtons.OK, MessageBoxIcon.Information); } rbModel.Checked = false; ctlPreOrProduct.SelectedID = 0; RefreshControl(); } else if (rbColorCode.Checked || ctlColor.SelectedID > 0) { nCount = 1; rptDataSet.StockInfoDataTable dt = new rptDataSet.StockInfoDataTable(); DataSet ds = new DataSet(); foreach (Stock oSTItem in oStocks) { Product oPro = oProList.FirstOrDefault(o => o.ProductID == oSTItem.ProductID); Category oCat = oCatList.FirstOrDefault(o => o.CategoryID == oPro.CategoryID); Company oCom = oComList.FirstOrDefault(o => o.CompanyID == oPro.CompanyID); INVENTORY.DA.Color oColor = oColList.FirstOrDefault(c => c.ColorID == oSTItem.ColorID); dt.Rows.Add((EnumProductType)oPro.ProductType, ((DateTime)oSTItem.EntryDate).ToString("dd MMM yyyy"), oSTItem.StockCode, oCat.Description, oCom.Description, oPro.ProductName, oColor.Description, oSTItem.Quantity, oSTItem.PMPrice, (oSTItem.Quantity * oSTItem.PMPrice)); nCount++; } dt.TableName = "rprDataSet_StockInfo"; ds.Tables.Add(dt); string embededResource = "INVENTORY.UI.RDLC.rptColorWise.rdlc"; List <ReportParameter> parameters = new List <ReportParameter>(); ReportParameter rParam = new ReportParameter(); rParam = new ReportParameter("PrintedBy", Global.CurrentUser.UserName); parameters.Add(rParam); rParam = new ReportParameter("SLNO", nCount.ToString()); parameters.Add(rParam); fReportViewer frm = new fReportViewer(); if (dt.Rows.Count > 0) { frm.CommonReportViewer(embededResource, ds, parameters, true); } else { MessageBox.Show("No Recors Found.", "Report", MessageBoxButtons.OK, MessageBoxIcon.Information); } }// } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void RefreshStock() { try { using (DEWSRMEntities db = new DEWSRMEntities()) { var _Stocks = db.Stocks; var _Companies = db.Companies; var _Categories = db.Categorys; var _Colors = db.Colors; var _Products = db.Products; var _StockDetails = db.StockDetails; _StockList = _Stocks.ToList(); _CompanyList = _Companies.ToList(); _CategoryList = _Categories.ToList(); _ProductList = _Products.ToList(); _StockDetailList = _StockDetails.ToList(); _ColorList = _Colors.ToList(); DataTable dt = new DataTable(); DataRow oDR = null; dt.Columns.Add("StockID"); dt.Columns.Add("StockCode"); dt.Columns.Add("ProductName"); dt.Columns.Add("Category"); dt.Columns.Add("Company"); dt.Columns.Add("Color"); dt.Columns.Add("Qty"); dt.Columns.Add("PurRate"); dt.Columns.Add("TotalPrice"); dt.Columns.Add("MRP"); if (_StockList != null) { foreach (Stock oStock in _StockList) { if (oStock.Quantity > 0) { oDR = dt.NewRow(); Product oPro = _ProductList.FirstOrDefault(o => o.ProductID == oStock.ProductID); Company oCom = _CompanyList.FirstOrDefault(o => o.CompanyID == oPro.CompanyID); Category oCat = _CategoryList.FirstOrDefault(o => o.CategoryID == oPro.CategoryID); INVENTORY.DA.Color oColor = _ColorList.FirstOrDefault(o => o.ColorID == oStock.ColorID); StockDetail oStockDetail = _StockDetailList.OrderByDescending(o => o.SDetailID).FirstOrDefault(o => o.StockID == oStock.StockID); if (oPro == null || oCom == null || oCat == null || oColor == null || oStockDetail == null) { } oDR["StockID"] = oStock.StockID; oDR["StockCode"] = oStock.StockCode; oDR["ProductName"] = oPro.ProductName; oDR["Category"] = oCat.Description; oDR["Company"] = oCom.Description; oDR["Color"] = oColor.Description; oDR["Qty"] = Math.Round((decimal)oStock.Quantity, 0); oDR["PurRate"] = oStock.PMPrice; oDR["TotalPrice"] = Math.Round((decimal)(oStock.Quantity * oStock.PMPrice), 2).ToString(); oDR["MRP"] = oStockDetail.SalesRate; dt.Rows.Add(oDR); } } grdStocks.DataSource = dt; lblStockTotal.Text = "Total :" + _StockList.Count.ToString(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ctlProduct_SelectedItemChanged(object sender, EventArgs e) { try { //List<Godown> oGodownList = db.Godowns.ToList(); //Godown oGD = oGodownList.FirstOrDefault(o => o.GodownName == ctlProduct.GodownName); _StockDetailControl = (StockDetail)(db.StockDetails.FirstOrDefault(o => o.SDetailID == ctlProduct.SelectedID)); if (_StockDetailControl != null) { var oProduct = db.Products.FirstOrDefault(i => i.ProductID == _StockDetailControl.ProductID); _StockControl = db.Stocks.FirstOrDefault(o => o.StockID == _StockDetailControl.StockID); if (oProduct.ProductType == (int)EnumProductType.NoBarCode) { var Totalrturns = (from so in db.Returns join sod in db.ReturnDetails on so.ReturnID equals sod.ReturnID join sd in db.StockDetails on sod.SDetailID equals sd.SDetailID where (so.SupplierID == ctlSupplier.SelectedID && sod.ProductID == _StockControl.ProductID && sd.ColorID == _StockControl.ColorID) select new { so.ReturnDate, sod.Quantity, sod.UnitPrice }).OrderByDescending(x => x.ReturnDate).ToList(); var TotalPurchases = (from po in db.POrders join pod in db.POrderDetails on po.POrderID equals pod.POrderID where (po.SupplierID == ctlSupplier.SelectedID && pod.ProductID == _StockControl.ProductID && po.Status == (int)EnumPurchaseType.Purchase && pod.ColorID == _StockDetailControl.ColorID) select new { po.OrderDate, pod.Quantity, UnitPrice = (pod.UnitPrice + ((po.LaborCost - po.TDiscount) / (po.GrandTotal - po.NetDiscount + po.TDiscount)) * pod.UnitPrice) }).OrderByDescending(x => x.OrderDate).ToList(); var lastsale = TotalPurchases.FirstOrDefault(); decimal uPrice = lastsale != null?Convert.ToDecimal(lastsale.UnitPrice) : 0m; if (_StockControl != null) { numSalesQty.Value = 0; numStock.Value = 0; numQTY.Value = 0; numStock.Value = _StockControl.Quantity; //_StockDetailControl.Quantity != null ? (decimal)_StockDetailControl.Quantity : 0m; numUnitPrice.Value = uPrice; //_StockControl.PMPrice != null ? (decimal)_StockControl.PMPrice : 0; INVENTORY.DA.Color oColor = _ColorList.FirstOrDefault(o => o.ColorID == _StockDetailControl.ColorID); decimal saleqty = 0; decimal returnqty = 0; if (TotalPurchases.Count > 0) { saleqty = (decimal)TotalPurchases.Sum(x => x.Quantity); } if (Totalrturns.Count > 0) { returnqty = (decimal)Totalrturns.Sum(x => x.Quantity); } numSalesQty.Value = saleqty - returnqty; numQTY.Focus(); numUnitPrice.Enabled = true; numQTY.Enabled = true; } } else { if (_StockControl != null) { var TotalPOrders = (from po in db.POrders join pod in db.POrderDetails on po.POrderID equals pod.POrderID where (po.SupplierID == ctlSupplier.SelectedID && pod.ProductID == _StockControl.ProductID && po.Status == (int)EnumSalesType.Sales && pod.ColorID == _StockDetailControl.ColorID) select new { po.OrderDate, pod.Quantity, SalesPrice = (pod.UnitPrice + ((po.LaborCost - po.TDiscount) / (po.GrandTotal - po.NetDiscount + po.TDiscount)) * pod.UnitPrice) }).OrderByDescending(x => x.OrderDate).ToList(); var lastSOD = TotalPOrders.FirstOrDefault(); numSalesQty.Value = lastSOD.Quantity; numStock.Value = 0; numQTY.Value = 1; numStock.Value = _StockControl.Quantity != null ? (decimal)_StockControl.Quantity : 0m; numUnitPrice.Value = lastSOD != null ? lastSOD.SalesPrice : 0m; numUnitPrice.Enabled = false; numQTY.Enabled = false; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void grdItems_MouseDoubleClick(object sender, MouseEventArgs e) { try { Category oCategory = null; Company oCompany = null; INVENTORY.DA.Color oColor = null; ExpenseItem oExpenseItem = null; Model oModel = null; int[] selRows = ((GridView)grdItems.MainView).GetSelectedRows(); DataRowView oID = (DataRowView)(((GridView)grdItems.MainView).GetRow(selRows[0])); int nID = Convert.ToInt32(oID["ID"]); Bank oBank = null; if (nID > 0) { if (_ObjectName == "Category") { this.Text = "Part Control"; oCategory = db.Categorys.FirstOrDefault(p => p.CategoryID == nID); _ctl.SelectedID = oCategory.CategoryID; _ctl.Code = oCategory.Code; _ctl.Name = oCategory.Description; } else if (_ObjectName == "BCompany") { this.Text = "Company Control"; oCompany = db.Companies.FirstOrDefault(p => p.CompanyID == nID); _ctl.SelectedID = oCompany.CompanyID; _ctl.Code = oCompany.Code; _ctl.Name = oCompany.Description; } else if (_ObjectName == "Color") { this.Text = "Color Control"; oColor = db.Colors.FirstOrDefault(p => p.ColorID == nID); _ctl.SelectedID = oColor.ColorID; _ctl.Code = oColor.Code; _ctl.Name = oColor.Description; } else if (_ObjectName == "Model") { this.Text = "Employee Control"; oModel = db.Models.FirstOrDefault(p => p.ModelID == nID); _ctl.SelectedID = oModel.ModelID; _ctl.Code = oModel.Code; _ctl.Name = oModel.Description; } else if (_ObjectName == "Expense") { this.Text = "Expense Control"; oExpenseItem = db.ExpenseItems.FirstOrDefault(p => p.ExpenseItemID == nID); _ctl.SelectedID = oExpenseItem.ExpenseItemID; _ctl.Code = oExpenseItem.Code; _ctl.Name = oExpenseItem.Description; } else if (_ObjectName == "IncomeOnly") { this.Text = "Expense Control"; oExpenseItem = db.ExpenseItems.FirstOrDefault(p => p.ExpenseItemID == nID); _ctl.SelectedID = oExpenseItem.ExpenseItemID; _ctl.Code = oExpenseItem.Code; _ctl.Name = oExpenseItem.Description; } else if (_ObjectName == "ExpenseOnly") { this.Text = "Expense Control"; oExpenseItem = db.ExpenseItems.FirstOrDefault(p => p.ExpenseItemID == nID); _ctl.SelectedID = oExpenseItem.ExpenseItemID; _ctl.Code = oExpenseItem.Code; _ctl.Name = oExpenseItem.Description; } else if (_ObjectName == "Bank") { this.Text = "Bank Control"; oBank = db.Banks.FirstOrDefault(p => p.BankID == nID); _ctl.SelectedID = oBank.BankID; _ctl.Code = oBank.Code; _ctl.Name = oBank.BankName; } } if (ItemChanged != null) { ItemChanged(); } this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (!IsValid()) { return; } bool IsNew = false; using (DEWSRMEntities db = new DEWSRMEntities()) { if (_ColorInfo.ColorID <= 0) { if (txtDescription.Text.Length > 0) { INVENTORY.DA.Color oColorInfo = null; oColorInfo = (INVENTORY.DA.Color)db.Colors.FirstOrDefault(o => o.Description.Trim().ToUpper() == txtDescription.Text.Trim().ToUpper()); if (oColorInfo != null) { MessageBox.Show("This Color already Exists.", "Duplicate Color", MessageBoxButtons.OK, MessageBoxIcon.Error); txtDescription.Focus(); return; } } RefreshObject(); _ColorInfo.ColorID = db.Colors.Count() > 0 ? db.Colors.Max(obj => obj.ColorID) + 1 : 1; db.Colors.Add(_ColorInfo); IsNew = true; } else { _ColorInfo = db.Colors.FirstOrDefault(obj => obj.ColorID == _ColorInfo.ColorID); RefreshObject(); } db.SaveChanges(); MessageBox.Show("Data saved successfully.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information); if (!IsNew) { if (ItemChanged != null) { ItemChanged(); } this.Close(); } else { if (ItemChanged != null) { ItemChanged(); } _ColorInfo = new INVENTORY.DA.Color(); RefreshValue(); txtCode.Text = GenerateColorCode(); } } } catch (Exception ex) { if (ex.InnerException == null) { MessageBox.Show(ex.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(ex.InnerException.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void GenerateReturnInvoice(Return _Return) { if (_Return != null) { DataTable orderdDT = new DataTable(); rptDataSet.dtInvoice1DataTable dt = new rptDataSet.dtInvoice1DataTable(); Customer customer = _Return.Customer; List <Product> products = db.Products.ToList(); List <StockDetail> stockDetails = db.StockDetails.ToList(); List <INVENTORY.DA.Color> colors = db.Colors.ToList(); Product product = null; INVENTORY.DA.Color color = null; StockDetail stockDetail = null; DataSet ds = new DataSet(); foreach (ReturnDetail item in _Return.ReturnDetails) { product = products.FirstOrDefault(o => o.ProductID == item.ProductID); stockDetail = stockDetails.FirstOrDefault(o => o.SDetailID == item.SDetailID); color = db.Colors.FirstOrDefault(o => o.ColorID == stockDetail.ColorID); dt.Rows.Add(product.ProductName, product.Company.Description, product.Category.Description, color.Description, item.Quantity, "Pcs", item.UnitPrice, " 0 %", item.UTAmount, 0, 0); } orderdDT = dt.AsEnumerable().OrderBy(o => (String)o["ProductName"]).CopyToDataTable(); dt.TableName = "rptDataSet_dtInvoice"; ds.Tables.Add(dt); string embededResource = "INVENTORY.UI.RDLC.AMReturnInvoice.rdlc"; ReportParameter rParam = new ReportParameter(); List <ReportParameter> parameters = new List <ReportParameter>(); string sInwodTk = Global.TakaFormat(Convert.ToDouble(_Return.GrandTotal)); rParam = new ReportParameter("GTotal", _Return.GrandTotal.ToString()); parameters.Add(rParam); rParam = new ReportParameter("Paid", _Return.PaidAmount.ToString()); parameters.Add(rParam); rParam = new ReportParameter("CurrDue", _Return.Customer.TotalDue.ToString()); parameters.Add(rParam); rParam = new ReportParameter("TDiscount", _Return.PaidAmount.ToString());//oOrder.TDAmount.ToString() parameters.Add(rParam); rParam = new ReportParameter("Total", _Return.PaidAmount.ToString()); parameters.Add(rParam); rParam = new ReportParameter("PreDue", _Return.PaidAmount.ToString()); parameters.Add(rParam); rParam = new ReportParameter("TotalDue", _Return.Customer.TotalDue.ToString()); parameters.Add(rParam); rParam = new ReportParameter("InvoiceNo", _Return.InvoiceNo); parameters.Add(rParam); rParam = new ReportParameter("InvoiceDate", _Return.ReturnDate.ToString()); parameters.Add(rParam); rParam = new ReportParameter("Company", _Return.Customer.CompanyName); parameters.Add(rParam); rParam = new ReportParameter("CAddress", _Return.Customer.Address); parameters.Add(rParam); rParam = new ReportParameter("Name", _Return.Customer.Name); parameters.Add(rParam); rParam = new ReportParameter("MobileNo", _Return.Customer.ContactNo); parameters.Add(rParam); rParam = new ReportParameter("PrintedBy", Global.CurrentUser.UserName); parameters.Add(rParam); rParam = new ReportParameter("LaborCost", _Return.PaidAmount.ToString()); parameters.Add(rParam); rParam = new ReportParameter("JobNumber", ""); parameters.Add(rParam); rParam = new ReportParameter("LessAmt", _Return.PaidAmount.ToString()); parameters.Add(rParam); //rParam = new ReportParameter("Logo1", Application.StartupPath + @"\Logo1.bmp"); //parameters.Add(rParam); rParam = new ReportParameter("InWordTK", sInwodTk); parameters.Add(rParam); fReportViewer frm = new fReportViewer(); frm.CommonReportViewer(embededResource, ds, parameters, true); } }
private void ctlProduct_SelectedItemChanged(object sender, EventArgs e) { try { //List<Godown> oGodownList = db.Godowns.ToList(); //Godown oGD = oGodownList.FirstOrDefault(o => o.GodownName == ctlProduct.GodownName); _StockDetailControl = (StockDetail)(db.StockDetails.FirstOrDefault(o => o.SDetailID == ctlProduct.SelectedID)); if (_StockDetailControl != null) { var oProduct = db.Products.FirstOrDefault(i => i.ProductID == _StockDetailControl.ProductID); _StockControl = db.Stocks.FirstOrDefault(o => o.StockID == _StockDetailControl.StockID); //if (oProduct != null) // txtSize.Text =""; if (oProduct.ProductType == (int)EnumProductType.NoBarCode) { var Totalrturns = (from sod in db.ReturnDetails from so in db.Returns where (so.ReturnID == sod.ReturnID && so.CustomerID == ctlCustomer.SelectedID && sod.ProductID == _StockControl.ProductID) select new { so.ReturnDate, sod.Quantity, sod.UnitPrice }).OrderByDescending(x => x.ReturnDate).ToList(); var TotalSales = (from sod in db.SOrderDetails from so in db.SOrders where (so.SOrderID == sod.SOrderID && so.CustomerID == ctlCustomer.SelectedID && sod.ProductID == _StockControl.ProductID && so.Status == (int)EnumSalesType.Sales) select new { so.InvoiceDate, sod.Quantity, UnitPrice = ((sod.UnitPrice - sod.PPDAmount) + ((0 - so.TDAmount - so.Adjustment) / (so.GrandTotal - so.NetDiscount + so.TDAmount)) * (sod.UnitPrice - sod.PPDAmount)), }).OrderByDescending(x => x.InvoiceDate).ToList(); var lastsale = TotalSales.FirstOrDefault(); decimal uPrice = lastsale != null?Convert.ToDecimal(lastsale.UnitPrice) : 0m; if (_StockControl != null) { numSalesQty.Value = 0; numStock.Value = 0; numQTY.Value = 0; numStock.Value = _StockDetailControl.Quantity != null ? (decimal)_StockDetailControl.Quantity : 0m; numUnitPrice.Value = uPrice;//_StockControl.PMPrice != null ? (decimal)_StockControl.PMPrice : 0; INVENTORY.DA.Color oColor = _ColorList.FirstOrDefault(o => o.ColorID == _StockDetailControl.ColorID); //if (oColor != null) // txtColor.Text = oColor.Description; decimal saleqty = 0; decimal returnqty = 0; if (TotalSales.Count > 0) { saleqty = (decimal)TotalSales.Sum(x => x.Quantity); } if (Totalrturns.Count > 0) { returnqty = (decimal)Totalrturns.Sum(x => x.Quantity); } numSalesQty.Value = saleqty - returnqty; numQTY.Focus(); numUnitPrice.Enabled = true; numQTY.Enabled = true; //txtIMEI.TextChanged -= txtIMEI_TextChanged; //txtIMEI.Text = _StockDetailControl.IMENO; //txtIMEI.TextChanged += txtIMEI_TextChanged; } } else { if (_StockControl != null) { var TotalSales = (from so in db.SOrders join sod in db.SOrderDetails on so.SOrderID equals sod.SOrderID where (so.CustomerID == ctlCustomer.SelectedID && sod.ProductID == _StockControl.ProductID && so.Status == (int)EnumSalesType.Sales && sod.StockDetailID == _StockDetailControl.SDetailID) select new { so.InvoiceDate, sod.Quantity, SalesPrice = ((sod.UnitPrice - sod.PPDAmount) + ((0 - so.TDAmount - so.Adjustment) / (so.GrandTotal - so.NetDiscount + so.TDAmount)) * (sod.UnitPrice - sod.PPDAmount)), }).OrderByDescending(x => x.InvoiceDate).ToList(); var lastSOD = TotalSales.FirstOrDefault(); numSalesQty.Value = lastSOD.Quantity; numStock.Value = 0; numQTY.Value = 1; numStock.Value = _StockControl.Quantity != null ? (decimal)_StockControl.Quantity : 0m; numUnitPrice.Value = lastSOD != null ? lastSOD.SalesPrice : 0m; numUnitPrice.Enabled = false; numQTY.Enabled = false; //txtIMEI.TextChanged -= txtIMEI_TextChanged; //txtIMEI.Text = _StockDetailControl.IMENO; //txtIMEI.TextChanged += txtIMEI_TextChanged; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Refresh() { try { using (DEWSRMEntities db = new DEWSRMEntities()) { if (ObjectName == "Company") { _Supplier = db.Suppliers.FirstOrDefault(o => o.SupplierID == SelectedID); if (_Supplier == null) { _CID = 0; } else { _CID = _Supplier.SupplierID; } if (_Supplier != null) { txtCode.Text = _Supplier.Code; txtName.Text = _Supplier.OwnerName;//_Supplier.Name; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "Customer") { _Customer = db.Customers.FirstOrDefault(o => o.CustomerID == SelectedID); if (_Customer != null) { _CID = _Customer.CustomerID; txtCode.Text = _Customer.Code; txtName.Text = _Customer.Name; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "Model") { _Model = db.Models.FirstOrDefault(o => o.ModelID == SelectedID); if (_Model != null) { txtCode.Text = _Model.Code; txtName.Text = _Model.Description; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "ReturnProduct") { StockDetail oSD = db.StockDetails.FirstOrDefault(o => o.SDetailID == SelectedID); if (oSD != null) { _Product = db.Products.FirstOrDefault(o => o.ProductID == oSD.Stock.ProductID); txtCode.Text = _Product.Code; txtName.Text = _Product.ProductName; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "Employee") { _Employee = db.Employees.FirstOrDefault(o => o.EmployeeID == SelectedID); if (_Employee != null) { txtCode.Text = _Employee.Code; txtName.Text = _Employee.Name; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "Product") { _Product = db.Products.FirstOrDefault(o => o.ProductID == SelectedID); if (_Product != null) { txtCode.Text = _Product.Code; txtName.Text = _Product.ProductName; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "OProduct") { _Product = db.Products.FirstOrDefault(o => o.ProductID == SelectedID); if (_Product != null) { txtCode.Text = _Product.Code; txtName.Text = _Product.ProductName; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "SPReport") { _Product = db.Products.FirstOrDefault(o => o.ProductID == SelectedID); if (_Product != null) { txtCode.Text = _Product.Code; txtName.Text = _Product.ProductName; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "CCompany") { _Supplier = db.Suppliers.FirstOrDefault(o => o.SupplierID == SelectedID); if (_Supplier != null) { txtCode.Text = _Supplier.Code; txtName.Text = _Supplier.OwnerName;//_Supplier.Name; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "IncomeOnly") { _ExpenseItem = db.ExpenseItems.FirstOrDefault(o => o.ExpenseItemID == SelectedID); if (_ExpenseItem != null) { txtCode.Text = _ExpenseItem.Code; txtName.Text = _ExpenseItem.Description; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "ExpenseOnly") { _ExpenseItem = db.ExpenseItems.FirstOrDefault(o => o.ExpenseItemID == SelectedID); if (_ExpenseItem != null) { txtCode.Text = _ExpenseItem.Code; txtName.Text = _ExpenseItem.Description; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "CCustomer") { _Customer = db.Customers.FirstOrDefault(o => o.CustomerID == SelectedID); if (_Customer != null) { txtCode.Text = _Customer.Code; txtName.Text = _Customer.Name; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "CreditCustomer") { _Customer = db.Customers.FirstOrDefault(o => o.CustomerID == SelectedID); if (_Customer != null) { txtCode.Text = _Customer.Code; txtName.Text = _Customer.Name; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "SReturn") { StockDetail OSD = db.StockDetails.FirstOrDefault(o => o.SDetailID == SelectedID); if (OSD != null) { _Product = db.Products.FirstOrDefault(o => o.ProductID == OSD.ProductID); } else { _Product = null; } if (_Product != null) { txtCode.Text = _Product.Code; txtName.Text = _Product.ProductName; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "PReturn") { StockDetail OSD = db.StockDetails.FirstOrDefault(o => o.SDetailID == SelectedID); if (OSD != null) { _Product = db.Products.FirstOrDefault(o => o.ProductID == OSD.ProductID); } else { _Product = null; } if (_Product != null) { txtCode.Text = _Product.Code; txtName.Text = _Product.ProductName; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "StockDetail") { StockDetail stockDetail = db.StockDetails.FirstOrDefault(o => o.SDetailID == SelectedID); if (stockDetail != null) { txtName.Text = stockDetail.Product.ProductName; txtCode.Text = stockDetail.Product.Code; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "Category") { _Category = db.Categorys.FirstOrDefault(o => o.CategoryID == SelectedID); if (_Category != null) { txtCode.Text = _Category.Code; txtName.Text = _Category.Description; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "BCompany") { _Company = db.Companies.FirstOrDefault(o => o.CompanyID == SelectedID); if (_Company != null) { txtCode.Text = _Company.Code; txtName.Text = _Company.Description; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "Color") { _Color = db.Colors.FirstOrDefault(o => o.ColorID == SelectedID); if (_Color != null) { txtCode.Text = _Color.Code; txtName.Text = _Color.Description; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "FAsset") { _ShareInvestment = db.ShareInvestmentHeads.FirstOrDefault(o => o.SIHID == SelectedID); if (_ShareInvestment != null) { txtCode.Text = _ShareInvestment.Code; txtName.Text = _ShareInvestment.Name; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "CAsset") { _ShareInvestment = db.ShareInvestmentHeads.FirstOrDefault(o => o.SIHID == SelectedID); if (_ShareInvestment != null) { txtCode.Text = _ShareInvestment.Code; txtName.Text = _ShareInvestment.Name; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "LReceive") { _ShareInvestment = db.ShareInvestmentHeads.FirstOrDefault(o => o.SIHID == SelectedID); if (_ShareInvestment != null) { txtCode.Text = _ShareInvestment.Code; txtName.Text = _ShareInvestment.Name; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "LPay") { _ShareInvestment = db.ShareInvestmentHeads.FirstOrDefault(o => o.SIHID == SelectedID); if (_ShareInvestment != null) { txtCode.Text = _ShareInvestment.Code; txtName.Text = _ShareInvestment.Name; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "Liability") { _ShareInvestment = db.ShareInvestmentHeads.FirstOrDefault(o => o.SIHID == SelectedID); if (_ShareInvestment != null) { txtCode.Text = _ShareInvestment.Code; txtName.Text = _ShareInvestment.Name; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "Expense") { _ExpenseItem = db.ExpenseItems.FirstOrDefault(o => o.ExpenseItemID == SelectedID); if (_ExpenseItem != null) { txtCode.Text = _ExpenseItem.Code; txtName.Text = _ExpenseItem.Description; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "Godown") { _Godown = db.Godowns.FirstOrDefault(o => o.GodownID == SelectedID); if (_Godown != null) { txtCode.Text = _Godown.GodownCode; txtName.Text = _Godown.GodownName; } else { txtCode.Text = ""; txtName.Text = ""; } } else if (ObjectName == "MSCustomer") { if (_IDList == null) { txtCode.Text = ""; txtName.Text = ""; } else { txtCode.Text = "00000"; txtName.Text = "Selected Total:" + _IDList.Count().ToString(); } } else if (ObjectName == "Bank") { _BankInfo = db.Banks.FirstOrDefault(o => o.BankID == SelectedID); if (_BankInfo != null) { BankID = _BankInfo.BankID; txtCode.Text = _BankInfo.Code; txtName.Text = _BankInfo.BankName + "," + _BankInfo.AccountNo; } else { txtCode.Text = ""; txtName.Text = ""; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }