private void AssignData(DEProduct product) { product.Product_Id = Convert.ToInt32(txt_Code.Tag); product.Product_Code = txt_Code.Text.Trim(); product.Product_Description = txt_Description.Text; product.Unit_Weight = Convert.ToDecimal(txt_Weight.Text); product.NoOfUnitsPerCarton = Convert.ToInt32(txt_NoOfUnits.Text); product.Unit_Price = Convert.ToDecimal(txt_UnitPrice.Text); product.Carton_Price = Convert.ToDecimal(txt_CartonPrice.Text); product.Unit_Price2 = Convert.ToDecimal(txt_UnitPrice2.Text); product.Carton_Price2 = Convert.ToDecimal(txt_CartonPrice2.Text); product.MinLVL = Convert.ToInt32(txt_MinLvl.Text); product.ReorderCtn = Convert.ToInt32(txt_ReorderCtn.Text); try { product.Catagory_Id = Convert.ToInt32(cbx_Catagory.SelectedItem.Col3); } catch (Exception ex) { product.Catagory_Id = 0; } try { product.SrNo = Convert.ToInt32(txt_SrNo.Text); } catch (Exception ex) { product.SrNo = 0; } }
private void save() { DEProduct product = new DEProduct(); AssignData(product); BLLProduct obj_BLLProduct = new BLLProduct(); try { int int_Result = obj_BLLProduct.InsertData(product); if (int_Result > 0) { MessageBox.Show(UIConstantMessage.Const_strSaveSuccessfully); BindDataGridView(); clearScreen(); } } catch (Exception ex) { throw ex; } finally { product = null; obj_BLLProduct = null; } }
public Boolean LoadProductRow(DEProduct product) { DALProduct obj_DALProduct = new DALProduct(); Boolean bool_HasRows = obj_DALProduct.LoadProductRow(product); obj_DALProduct = null; return(bool_HasRows); }
public int DeleteData(DEProduct product) { DALProduct obj_DALProduct = new DALProduct(); int int_Result = obj_DALProduct.DeleteData(product); obj_DALProduct = null; return(int_Result); }
public DataTable LoadProductTableForAllDataByProductCode(DEProduct product) { DALProduct obj_DALProduct = new DALProduct(); DataTable dt_Product = obj_DALProduct.LoadProductTableForAllDataByProductCode(product); obj_DALProduct = null; return(dt_Product); }
public Boolean LoadProductRow(DEProduct product) { Boolean bool_HasRows = false; SqlCommand sqlCmd = new SqlCommand(); sqlCmd.CommandText = "SELECT Pro.Product_Id,Pro.Product_Code,Pro.Product_Description,Pro.Unit_Weight,Pro.NoOfUnitsPerCarton,Pro.Unit_Price,Pro.Carton_Price,Pro.CartonPrice_Buying,Pro.Catagory_Id,Cat.Catagory_Description,Pro.Active,Pro.ModifiedBy,Pro.ModifiedDate, Pro.Unit_Price2, Pro.Carton_Price2, Pro.MinLVL, Pro.ReorderCtn, Pro.SrNo FROM tbl_Product Pro LEFT JOIN tbl_Catagory Cat on Pro.Catagory_Id = Cat.Catagory_Id where Pro.Active = 'true' And Pro.Product_Id = @Product_Id"; sqlCmd = DeclareSqlCmdParameter(sqlCmd, product); SqlConnection con = new SqlConnection(SqlConjunction.DataConn); SqlDataReader sqlDataReader = SqlConjunction.GetSQLExecuteReader(sqlCmd, con); while (sqlDataReader.Read()) { product.Product_Id = sqlDataReader.GetInt32(0); product.Product_Code = sqlDataReader.GetString(1); product.Product_Description = sqlDataReader.GetString(2); product.Unit_Weight = sqlDataReader.GetDecimal(3); product.NoOfUnitsPerCarton = sqlDataReader.GetInt32(4); product.Unit_Price = sqlDataReader.GetDecimal(5); product.Carton_Price = sqlDataReader.GetDecimal(6); product.CartonPrice_Buying = sqlDataReader.GetDecimal(7); product.Catagory_Id = sqlDataReader.GetInt32(8); product.Catagory_Description = sqlDataReader.GetString(9); product.Active = sqlDataReader.GetBoolean(10); product.ModifiedBy = sqlDataReader.GetString(11); product.ModifiedDate = sqlDataReader.GetDateTime(12); product.Unit_Price2 = sqlDataReader.GetDecimal(13); product.Carton_Price2 = sqlDataReader.GetDecimal(14); product.MinLVL = sqlDataReader.GetInt32(15); product.ReorderCtn = sqlDataReader.GetInt32(16); product.SrNo = sqlDataReader.GetInt32(17); } if (sqlDataReader.HasRows) { bool_HasRows = true; } else { bool_HasRows = false; } con.Close(); sqlCmd = null; return(bool_HasRows); }
private void DisplayData(DEProduct product) { txt_Code.Tag = product.Product_Id; txt_Code.Text = product.Product_Code; txt_Description.Text = product.Product_Description; txt_Weight.Text = Convert.ToString(product.Unit_Weight); txt_NoOfUnits.Text = Convert.ToString(product.NoOfUnitsPerCarton); txt_UnitPrice.Text = Convert.ToString(product.Unit_Price); txt_CartonPrice.Text = Convert.ToString(product.Carton_Price); cbx_Catagory.SelectedValue = product.Catagory_Id.ToString(); txt_UnitPrice2.Text = Convert.ToString(product.Unit_Price2); txt_CartonPrice2.Text = Convert.ToString(product.Carton_Price2); txt_MinLvl.Text = Convert.ToString(product.MinLVL); txt_ReorderCtn.Text = Convert.ToString(product.ReorderCtn); txt_SrNo.Text = Convert.ToString(product.SrNo); }
public DataTable LoadProductTableForAllDataByProductCode(DEProduct product) { DataTable dt_Product; SqlCommand sqlCmd = new SqlCommand(); sqlCmd.CommandText = "SELECT 0 As 'No',Pro.Product_Id,Pro.Product_Code,Pro.Product_Description,Pro.Unit_Weight,Pro.NoOfUnitsPerCarton,Pro.Unit_Price,Pro.Carton_Price,Pro.CartonPrice_Buying,Pro.Catagory_Id,Cat.Catagory_Description,Pro.Active,Pro.ModifiedBy,Pro.ModifiedDate, Pro.Unit_Price2, Pro.Carton_Price2, Pro.MinLVL, Pro.ReorderCtn, Pro.SrNo FROM tbl_Product Pro LEFT JOIN tbl_Catagory Cat on Pro.Catagory_Id = Cat.Catagory_Id where Pro.Active = 'true' And Pro.Product_Code LIKE '%' + @Product_Code+ '%' order by Pro.SrNo"; sqlCmd = DeclareSqlCmdParameter(sqlCmd, product); dt_Product = SqlConjunction.GetSQLDataTable(sqlCmd); sqlCmd = null; return(dt_Product); }
public int DeleteData(DEProduct product) { int int_Result; SqlCommand sqlCmd = new SqlCommand(); sqlCmd.CommandText = "DELETE FROM tbl_Product WHERE Product_Id = @Product_Id"; DeclareSqlCmdParameter(sqlCmd, product); int_Result = SqlConjunction.GetSQLVoid(sqlCmd); sqlCmd = null; return(int_Result); }
public int UpdateData(DEProduct product) { int int_Result; SqlCommand sqlCmd = new SqlCommand(); sqlCmd.CommandText = "UPDATE tbl_Product SET Product_Id= @Product_Id, Product_Code=@Product_Code, Product_Description = @Product_Description, Unit_Weight = @Unit_Weight, NoOfUnitsPerCarton = @NoOfUnitsPerCarton,Unit_Price = @Unit_Price, Carton_Price = @Carton_Price, CartonPrice_Buying = @CartonPrice_Buying, Catagory_Id = @Catagory_Id , Active = @Active ,ModifiedBy = @ModifiedBy ,ModifiedDate = @ModifiedDate, Unit_Price2 = @Unit_Price2, Carton_Price2 = @Carton_Price2, MinLVL = @MinLVL, ReorderCtn = @ReorderCtn, SrNo = @SrNo WHERE Product_Id = @Product_Id"; DeclareSqlCmdParameter(sqlCmd, product); int_Result = SqlConjunction.GetSQLVoid(sqlCmd); sqlCmd = null; return(int_Result); }
public int InsertData(DEProduct product) { int int_Result; SqlCommand sqlCmd = new SqlCommand(); sqlCmd.CommandText = "SELECT @Product_Id = ISNULL(MAX(Product_Id),0)+1 FROM tbl_Product INSERT tbl_Product VALUES(@Product_Id,@Product_Code,@Product_Description,@Unit_Weight,@NoOfUnitsPerCarton,@Unit_Price,@Carton_Price,@CartonPrice_Buying,@Catagory_Id,@Active,@ModifiedBy,@ModifiedDate,@Unit_Price2,@Carton_Price2,@MinLVL,@ReorderCtn, @SrNo)"; DeclareSqlCmdParameter(sqlCmd, product); int_Result = SqlConjunction.GetSQLVoid(sqlCmd); sqlCmd = null; return(int_Result); }
public int InsertData(DEProduct product) { DALProduct obj_DALProduct = new DALProduct(); int int_Result; if (product.Product_Id == 0) { int_Result = obj_DALProduct.InsertData(product); } else { int_Result = obj_DALProduct.UpdateData(product); } obj_DALProduct = null; return(int_Result); }
private void dgv_Product_DoubleClick(object sender, EventArgs e) { DEProduct product = new DEProduct(); product.Product_Id = Convert.ToInt32(dgv_Product.CurrentRow.Cells[1].Value); BLLProduct obj_BLLProduct = new BLLProduct(); bool bool_Result = obj_BLLProduct.LoadProductRow(product); if (bool_Result == true) { DisplayData(product); } else { MessageBox.Show("Record is not found."); } product = null; obj_BLLProduct = null; }
private void search() { BLLInvoiceDetail obj_BLLInvoiceDetail = new BLLInvoiceDetail(); BLLInvoiceReturnDetail obj_BLLInvoiceReturnDetail = new BLLInvoiceReturnDetail(); BLLProduct obj_BLLProduct = new BLLProduct(); DEInvoiceDetail invDetail = new DEInvoiceDetail(); DEInvoiceReturnDetail invRDetail = new DEInvoiceReturnDetail(); DEProduct product = new DEProduct(); DateTime dateTime_From = Convert.ToDateTime(dtp_InvoiceDateFrom.Value); DateTime dateTime_To = Convert.ToDateTime(dtp_InvoiceDateTo.Value.Date.AddHours(23.9)); try { invDetail.Product_Id = Convert.ToInt32(cbx_Product.SelectedItem.Col3); invRDetail.Product_Id = Convert.ToInt32(cbx_Product.SelectedItem.Col3); product.Product_Id = Convert.ToInt32(cbx_Product.SelectedItem.Col3); } catch (Exception ex) { invDetail.Product_Id = 0; invRDetail.Product_Id = 0; product.Product_Id = 0; } DataTable dt_Sale = new DataTable(); DataTable dt_Return = new DataTable(); dt_Sale = obj_BLLInvoiceDetail.LoadInvoiceDetailTableForAllDataByInvoiceDate(invDetail, dateTime_From, dateTime_To); dt_Return = obj_BLLInvoiceReturnDetail.LoadInvoiceReturnDetailTableForAllDataByInvoiceDate(invRDetail, dateTime_From, dateTime_To); obj_BLLProduct.LoadProductRow(product); bindReport(product, dt_Sale, dt_Return); }
private SqlCommand DeclareSqlCmdParameter(SqlCommand SqlCmd, DEProduct product) { SqlCmd.Parameters.AddWithValue("@Product_Id", product.Product_Id); SqlCmd.Parameters.AddWithValue("@Product_Code", product.Product_Code); SqlCmd.Parameters.AddWithValue("@Product_Description", product.Product_Description); SqlCmd.Parameters.AddWithValue("@Unit_Weight", product.Unit_Weight); SqlCmd.Parameters.AddWithValue("@NoOfUnitsPerCarton", product.NoOfUnitsPerCarton); SqlCmd.Parameters.AddWithValue("@Unit_Price", product.Unit_Price); SqlCmd.Parameters.AddWithValue("@Carton_Price", product.Carton_Price); SqlCmd.Parameters.AddWithValue("@CartonPrice_Buying", product.CartonPrice_Buying); SqlCmd.Parameters.AddWithValue("@Catagory_Id", product.Catagory_Id); SqlCmd.Parameters.AddWithValue("@Active", product.Active); SqlCmd.Parameters.AddWithValue("@ModifiedBy", product.ModifiedBy); SqlCmd.Parameters.AddWithValue("@ModifiedDate", product.ModifiedDate); SqlCmd.Parameters.AddWithValue("@Unit_Price2", product.Unit_Price2); SqlCmd.Parameters.AddWithValue("@Carton_Price2", product.Carton_Price2); SqlCmd.Parameters.AddWithValue("@MinLVL", product.MinLVL); SqlCmd.Parameters.AddWithValue("@ReorderCtn", product.ReorderCtn); SqlCmd.Parameters.AddWithValue("@SrNo", product.SrNo); return(SqlCmd); }
private void BindDataGridView() { DEProduct product = new DEProduct(); BLLProduct obj_BLLProduct = new BLLProduct(); DataTable dt_Product; if (txt_FilteredCode.Text.Trim().Length <= 0) { dt_Product = obj_BLLProduct.LoadProductTableForAllData(); } else { product.Product_Code = txt_FilteredCode.Text; dt_Product = obj_BLLProduct.LoadProductTableForAllDataByProductCode(product); } dgv_Product.DataSource = dt_Product; NumberingTableForDataGridView(dt_Product); FormatDataGridView(); }
private void bindReport(DEProduct product, DataTable dt_Sale, DataTable dt_Return) { String str_Product_Code; String str_Product_Description; try { str_Product_Code = Convert.ToString(cbx_Product.SelectedItem.Col1); } catch (Exception ex) { str_Product_Code = string.Empty; } try { str_Product_Description = Convert.ToString(cbx_Product.SelectedItem.Col2); } catch (Exception ex) { str_Product_Description = string.Empty; } rptv_ProductInvoiceReport.Clear(); rptv_ProductInvoiceReport.Reset(); rptv_ProductInvoiceReport.ProcessingMode = ProcessingMode.Local; LocalReport localReport = rptv_ProductInvoiceReport.LocalReport; localReport.ReportEmbeddedResource = "StockAndSale.WinUI.Reports.Classes.Rpt_ProductInvoiceReport.rdlc"; ReportDataSource ds_InvoiceSale = new ReportDataSource(); ds_InvoiceSale.Name = "DS_InvoiceReport_dt_ProductSale"; ds_InvoiceSale.Value = dt_Sale; ReportDataSource ds_InvoiceReturn = new ReportDataSource(); ds_InvoiceReturn.Name = "DS_InvoiceReport_dt_ProductReturn"; ds_InvoiceReturn.Value = dt_Return; ReportParameter parDateFrom = new ReportParameter(); parDateFrom.Name = "parDateFrom"; ReportParameter parDateTo = new ReportParameter(); parDateTo.Name = "parDateTo"; ReportParameter parShowSale = new ReportParameter(); parShowSale.Name = "parShowSale"; ReportParameter parShowReturn = new ReportParameter(); parShowReturn.Name = "parShowReturn"; ReportParameter parProductCode = new ReportParameter(); parProductCode.Name = "parProductCode"; ReportParameter parProductDescription = new ReportParameter(); parProductDescription.Name = "parProductDescription"; ReportParameter parNoOfUnitsPerCarton = new ReportParameter(); parNoOfUnitsPerCarton.Name = "parNoOfUnitsPerCarton"; parDateFrom.Values.Add(dtp_InvoiceDateFrom.Value.Date.ToString()); parDateTo.Values.Add(dtp_InvoiceDateTo.Value.Date.ToString()); if (rdo_All.Checked) { parShowSale.Values.Add("true"); parShowReturn.Values.Add("true"); } else if (rdo_Sale.Checked) { parShowSale.Values.Add("true"); parShowReturn.Values.Add("false"); } else { parShowSale.Values.Add("false"); parShowReturn.Values.Add("true"); } parProductCode.Values.Add(str_Product_Code); parProductDescription.Values.Add(product.Product_Description); parNoOfUnitsPerCarton.Values.Add(product.NoOfUnitsPerCarton.ToString()); rptv_ProductInvoiceReport.LocalReport.SetParameters(new ReportParameter[] { parDateFrom, parDateTo, parShowSale, parShowReturn, parProductCode, parProductDescription, parNoOfUnitsPerCarton }); localReport.DataSources.Add(ds_InvoiceSale); localReport.DataSources.Add(ds_InvoiceReturn); rptv_ProductInvoiceReport.RefreshReport(); }
public int InsertData(DECustomerReturn customerReturn) { int int_Result = 0; DALProductInStore obj_DALProductInStore = new DALProductInStore(); DALProduct obj_DALProduct = new DALProduct(); DEProductInStore productInStore = new DEProductInStore(); productInStore.Product_Id = customerReturn.Product_Id; DEProduct product = new DEProduct(); product.Product_Id = customerReturn.Product_Id; obj_DALProduct.LoadProductRow(product); SqlConnection SqlCon = new SqlConnection(SqlConjunction.DataConn); try { if (SqlCon.State != ConnectionState.Open) { SqlCon.Open(); } } catch (SqlException ex) { Console.WriteLine(ex); } SqlTransaction tn = SqlCon.BeginTransaction(); { try { this.InsertData(customerReturn, SqlCon, tn); int int_NoOfUnitsSale = 0; if (customerReturn.isCarton == true) { int_NoOfUnitsSale = (customerReturn.Qty * product.NoOfUnitsPerCarton); } else { int_NoOfUnitsSale = customerReturn.Qty; } DataTable dt_ProductInStoreTemp = obj_DALProductInStore.LoadProductInStoreTableByProductId(productInStore, SqlCon, tn); if (dt_ProductInStoreTemp.Rows.Count > 0) { int int_NoOfUnitsInStore = Convert.ToInt32(dt_ProductInStoreTemp.Rows[0][0].ToString()); productInStore.NoOfUnits = (int_NoOfUnitsInStore + int_NoOfUnitsSale); obj_DALProductInStore.UpdateData(productInStore, SqlCon, tn); } else { productInStore.NoOfUnits = (int_NoOfUnitsSale * (-1)); obj_DALProductInStore.InsertData(productInStore, SqlCon, tn); } tn.Commit(); int_Result = 1; } catch (Exception ex) { tn.Rollback(); int_Result = 0; throw (ex); } finally { obj_DALProductInStore = null; SqlCon.Close(); tn.Dispose(); } return(int_Result); } }
public int CancelDetailInvoice(DEInvoiceDetail invoiceDetail) { int int_Result = 0; DALProductInStore obj_DALProductInStore = new DALProductInStore(); DALProduct obj_DALProduct = new DALProduct(); DEProductInStore productInStore = new DEProductInStore(); productInStore.Product_Id = invoiceDetail.Product_Id; DEProduct product = new DEProduct(); product.Product_Id = invoiceDetail.Product_Id; obj_DALProduct.LoadProductRow(product); SqlConnection SqlCon = new SqlConnection(SqlConjunction.DataConn); try { if (SqlCon.State != ConnectionState.Open) { SqlCon.Open(); } } catch (SqlException ex) { Console.WriteLine(ex); } SqlTransaction tn = SqlCon.BeginTransaction(); { try { int int_NoOfUnitsSale = 0; if (invoiceDetail.isCarton) { int_NoOfUnitsSale = invoiceDetail.Qty * product.NoOfUnitsPerCarton; } else { int_NoOfUnitsSale = invoiceDetail.Qty; } DataTable dt_ProductInStoreTemp = obj_DALProductInStore.LoadProductInStoreTableByProductId(productInStore, SqlCon, tn); if (dt_ProductInStoreTemp.Rows.Count > 0) { int int_NoOfUnitsInStore = Convert.ToInt32(dt_ProductInStoreTemp.Rows[0][0].ToString()); productInStore.NoOfUnits = (int_NoOfUnitsInStore + int_NoOfUnitsSale); obj_DALProductInStore.UpdateData(productInStore, SqlCon, tn); } else { } this.updateActiveData(invoiceDetail, SqlCon, tn); tn.Commit(); int_Result = 1; } catch (Exception ex) { tn.Rollback(); int_Result = 0; throw (ex); } finally { obj_DALProductInStore = null; SqlCon.Close(); tn.Dispose(); } return(int_Result); } }
private void rdo_isCarton_CheckedChanged(object sender, EventArgs e) { if (cbx_Product.Text.Trim().Length == 0 || cbx_Product.SelectedValue == null) { //MessageBox.Show("Invalid Product Code"); cbx_Product.Text = string.Empty; txt_ProductDescription.Text = string.Empty; txt_Rate.Text = string.Empty; cbx_Product.Focus(); } else { //txt_ProductDescription.Text = cbx_Product.SelectedItem.Col2; DEProduct product = new DEProduct(); product.Product_Id = Convert.ToInt32(cbx_Product.SelectedItem.Col3); BLLProduct obj_BLLProduct = new BLLProduct(); bool bool_Result = obj_BLLProduct.LoadProductRow(product); if (bool_Result == true) { if (rdo_Price1.Checked == true) { if (rdo_isCarton.Checked == true) { txt_Rate.Text = product.Carton_Price.ToString(); } else if (rdo_isUnit.Checked == true) { txt_Rate.Text = product.Unit_Price.ToString(); } else if (rdo_CartonPricePerUnits.Checked == true) { if (product.Carton_Price == 0) { txt_Rate.Text = "0.00"; } else { txt_Rate.Text = (product.Carton_Price / product.NoOfUnitsPerCarton).ToString("##.##"); } } } else { if (rdo_isCarton.Checked == true) { txt_Rate.Text = product.Carton_Price2.ToString(); } else if (rdo_isUnit.Checked == true) { txt_Rate.Text = product.Unit_Price2.ToString(); } else if (rdo_CartonPricePerUnits.Checked == true) { if (product.Carton_Price2 == 0) { txt_Rate.Text = "0.00"; } else { txt_Rate.Text = (product.Carton_Price2 / product.NoOfUnitsPerCarton).ToString("##.##"); } } } txt_Quantity.Focus(); } else { //MessageBox.Show("Invalid Product Code"); //cbx_Product.Text = string.Empty; //txt_ProductDescription.Text = string.Empty; } obj_BLLProduct = null; } }
private void cbx_Product_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (cbx_Product.Text.Trim().Length == 0 || cbx_Product.SelectedValue == null) { cbx_Product.Text = string.Empty; txt_ProductDescription.Text = string.Empty; txt_Rate.Text = string.Empty; cbx_Product.Focus(); } else { txt_ProductDescription.Text = cbx_Product.SelectedItem.Col2; DEProduct product = new DEProduct(); product.Product_Id = Convert.ToInt32(cbx_Product.SelectedItem.Col3); BLLProduct obj_BLLProduct = new BLLProduct(); bool bool_Result = obj_BLLProduct.LoadProductRow(product); if (bool_Result == true) { if (rdo_Price1.Checked == true) { if (rdo_isCarton.Checked == true) { txt_Rate.Text = product.Carton_Price.ToString(); } else if (rdo_isUnit.Checked == true) { txt_Rate.Text = product.Unit_Price.ToString(); } else if (rdo_CartonPricePerUnits.Checked == true) { txt_Rate.Text = (product.Carton_Price / product.NoOfUnitsPerCarton).ToString("##.##"); } } else { if (rdo_isCarton.Checked == true) { txt_Rate.Text = product.Carton_Price2.ToString(); } else if (rdo_isUnit.Checked == true) { txt_Rate.Text = product.Unit_Price2.ToString(); } else if (rdo_CartonPricePerUnits.Checked == true) { txt_Rate.Text = (product.Carton_Price2 / product.NoOfUnitsPerCarton).ToString("##.##"); } } } else { cbx_Product.Text = string.Empty; txt_ProductDescription.Text = string.Empty; cbx_Product.Focus(); } obj_BLLProduct = null; } } }