/// <summary> /// Adding PhysicalStockDetails when updating /// </summary> public void EditPhysicalStockDetails() { try { ProductInfo infoProduct = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); PhysicalStockDetailsInfo infoPhysicalStockDetails = new PhysicalStockDetailsInfo(); PhysicalStockBll BllPhysicalStock = new PhysicalStockBll(); int inRowcount = dgvPhysicalStock.Rows.Count; for (int inI = 0; inI < inRowcount - 1; inI++) { infoPhysicalStockDetails.PhysicalStockMasterId = decMasterId; infoPhysicalStockDetails.PhysicalStockDetailsId = Convert.ToDecimal(dgvPhysicalStock.Rows[inI].Cells["dgvtxtPhysicalStockDetailId"].Value); if (dgvPhysicalStock.Rows[inI].Cells["dgvtxtProductCode"].Value != null && dgvPhysicalStock.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty) { infoProduct = BllProductCreation.ProductViewByCode(dgvPhysicalStock.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoPhysicalStockDetails.ProductId = infoProduct.ProductId; } if (dgvPhysicalStock.Rows[inI].Cells["dgvcmbGodown"].Value != null && dgvPhysicalStock.Rows[inI].Cells["dgvcmbGodown"].Value.ToString() != string.Empty) { infoPhysicalStockDetails.GodownId = Convert.ToDecimal(dgvPhysicalStock.Rows[inI].Cells["dgvcmbGodown"].Value.ToString()); } else { infoPhysicalStockDetails.GodownId = 0; } if (dgvPhysicalStock.Rows[inI].Cells["dgvcmbRack"].Value != null && dgvPhysicalStock.Rows[inI].Cells["dgvcmbRack"].Value.ToString() != string.Empty) { infoPhysicalStockDetails.RackId = Convert.ToDecimal(dgvPhysicalStock.Rows[inI].Cells["dgvcmbRack"].Value.ToString()); } else { infoPhysicalStockDetails.RackId = 0; } if (dgvPhysicalStock.Rows[inI].Cells["dgvcmbBatch"].Value != null && dgvPhysicalStock.Rows[inI].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { infoPhysicalStockDetails.BatchId = Convert.ToDecimal(Convert.ToString(dgvPhysicalStock.Rows[inI].Cells["dgvcmbBatch"].Value)); } else { infoPhysicalStockDetails.BatchId = 0; } if (dgvPhysicalStock.Rows[0].Cells["dgvcmbBatch"].Value == null && dgvPhysicalStock.Rows[0].Cells["dgvcmbBatch"].Value == null) { MessageBox.Show("Can't update physical stock without atleast one product with complete details", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvPhysicalStock.ClearSelection(); dgvPhysicalStock.Focus(); } if (dgvPhysicalStock.Rows[inI].Cells["dgvtxtQty"].Value != null && dgvPhysicalStock.Rows[inI].Cells["dgvtxtQty"].Value.ToString() != string.Empty) { infoPhysicalStockDetails.Qty = Convert.ToDecimal(dgvPhysicalStock.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); } if (dgvPhysicalStock.Rows[inI].Cells["dgvcmbUnit"].Value != null && dgvPhysicalStock.Rows[inI].Cells["dgvcmbUnit"].Value.ToString() != string.Empty) { infoPhysicalStockDetails.UnitId = Convert.ToDecimal(dgvPhysicalStock.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); } infoPhysicalStockDetails.Rate = Convert.ToDecimal(dgvPhysicalStock.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoPhysicalStockDetails.Amount = Convert.ToDecimal(dgvPhysicalStock.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoPhysicalStockDetails.Slno = Convert.ToInt32(dgvPhysicalStock.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); infoPhysicalStockDetails.Extra1 = string.Empty; infoPhysicalStockDetails.Extra2 = string.Empty; BllPhysicalStock.PhysicalStockDetailsAdd(infoPhysicalStockDetails); decimal decPId = infoPhysicalStockDetails.ProductId; string strVoucher = infoPhysicalStockMaster.VoucherNo; AddtoStockPosting(decPId, strVoucher); } } catch (Exception ex) { MessageBox.Show("PS:23" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save Function /// </summary> public void SaveFunction() { try { ProductInfo infoProduct = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); PhysicalStockMasterInfo infoPhysicalStockMaster = new PhysicalStockMasterInfo(); //PhysicalStockDetailsSP spPhysicalStockDetails = new PhysicalStockDetailsSP(); PhysicalStockBll BllPhysicalStock = new PhysicalStockBll(); //PhysicalStockMasterSP spPhysicalStockMaster = new PhysicalStockMasterSP(); infoPhysicalStockMaster.VoucherNo = txtVoucherNo.Text.Trim(); infoPhysicalStockMaster.Date = Convert.ToDateTime(txtDate.Text); infoPhysicalStockMaster.Narration = txtNarration.Text.Trim(); string s = txtTotalAmount.Text; infoPhysicalStockMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); if (isAutomatic) { infoPhysicalStockMaster.SuffixPrefixId = decPhysicalStockSuffixPrefixId; infoPhysicalStockMaster.VoucherNo = strVoucherNo; infoPhysicalStockMaster.InvoiceNo = txtVoucherNo.Text; } else { infoPhysicalStockMaster.SuffixPrefixId = 0; infoPhysicalStockMaster.VoucherNo = txtVoucherNo.Text; infoPhysicalStockMaster.InvoiceNo = txtVoucherNo.Text; } infoPhysicalStockMaster.VoucherTypeId = decPhysicalStockVoucherTypeId; infoPhysicalStockMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPhysicalStockMaster.Extra1 = string.Empty; infoPhysicalStockMaster.Extra2 = string.Empty; decPhysicalStockMasterIdentity = Convert.ToDecimal(BllPhysicalStock.PhysicalStockMasterAdd(infoPhysicalStockMaster)); int inRowcount = dgvPhysicalStock.Rows.Count; for (int inI = 0; inI < inRowcount - 1; inI++) { if (dgvPhysicalStock.Rows[inI].HeaderCell.Value.ToString() != "X") { infoPhysicalStockDetails.PhysicalStockMasterId = decPhysicalStockMasterIdentity; if (dgvPhysicalStock.Rows[inI].Cells["dgvtxtProductCode"].Value != null && dgvPhysicalStock.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty) { infoProduct = BllProductCreation.ProductViewByCode(dgvPhysicalStock.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoPhysicalStockDetails.ProductId = infoProduct.ProductId; } if (dgvPhysicalStock.Rows[inI].Cells["dgvcmbGodown"].Value != null && dgvPhysicalStock.Rows[inI].Cells["dgvcmbGodown"].Value.ToString() != string.Empty) { infoPhysicalStockDetails.GodownId = Convert.ToDecimal(dgvPhysicalStock.Rows[inI].Cells["dgvcmbGodown"].Value.ToString()); } else { infoPhysicalStockDetails.GodownId = 0; } if (dgvPhysicalStock.Rows[inI].Cells["dgvcmbRack"].Value != null && dgvPhysicalStock.Rows[inI].Cells["dgvcmbRack"].Value.ToString() != string.Empty) { infoPhysicalStockDetails.RackId = Convert.ToDecimal(dgvPhysicalStock.Rows[inI].Cells["dgvcmbRack"].Value.ToString()); } else { infoPhysicalStockDetails.RackId = 0; } if (dgvPhysicalStock.Rows[inI].Cells["dgvcmbBatch"].Value != null && dgvPhysicalStock.Rows[inI].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { infoPhysicalStockDetails.BatchId = Convert.ToDecimal(Convert.ToString(dgvPhysicalStock.Rows[inI].Cells["dgvcmbBatch"].Value)); } else { infoPhysicalStockDetails.BatchId = 0; } if (dgvPhysicalStock.Rows[inI].Cells["dgvtxtQty"].Value != null && dgvPhysicalStock.Rows[inI].Cells["dgvtxtQty"].Value.ToString() != string.Empty) { infoPhysicalStockDetails.Qty = Convert.ToDecimal(dgvPhysicalStock.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); } if (dgvPhysicalStock.Rows[inI].Cells["dgvcmbUnit"].Value != null && dgvPhysicalStock.Rows[inI].Cells["dgvcmbUnit"].Value.ToString() != string.Empty) { infoPhysicalStockDetails.UnitId = Convert.ToDecimal(dgvPhysicalStock.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); infoPhysicalStockDetails.UnitConversionId = decConversionId; } infoPhysicalStockDetails.Rate = Convert.ToDecimal(dgvPhysicalStock.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoPhysicalStockDetails.Amount = Convert.ToDecimal(dgvPhysicalStock.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoPhysicalStockDetails.Slno = Convert.ToInt32(dgvPhysicalStock.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); infoPhysicalStockDetails.Extra1 = string.Empty; infoPhysicalStockDetails.Extra2 = string.Empty; BllPhysicalStock.PhysicalStockDetailsAdd(infoPhysicalStockDetails); decimal decPId = infoPhysicalStockDetails.ProductId; string strVoucher = infoPhysicalStockMaster.VoucherNo; AddtoStockPosting(decPId, strVoucher); } } Messages.SavedMessage(); if (dgvPhysicalStock.RowCount > 1) { if (cbxPrint.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPhysicalStockMasterIdentity); } else { Print(decPhysicalStockMasterIdentity); } } } clear(); } catch (Exception ex) { MessageBox.Show("PS:27" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }