コード例 #1
0
        public decimal PurchaseOrderMasterAdd(PurchaseOrderMasterInfo purchaseordermasterinfo)
        {
            decimal decIdentity = 0m;

            try
            {
                if (base.sqlcon.State == ConnectionState.Closed)
                {
                    base.sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("PurchaseOrderMasterAdd", base.sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam17 = new SqlParameter();
                sprmparam17       = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
                sprmparam17.Value = purchaseordermasterinfo.VoucherNo;
                sprmparam17       = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
                sprmparam17.Value = purchaseordermasterinfo.InvoiceNo;
                sprmparam17       = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
                sprmparam17.Value = purchaseordermasterinfo.SuffixPrefixId;
                sprmparam17       = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
                sprmparam17.Value = purchaseordermasterinfo.VoucherTypeId;
                sprmparam17       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
                sprmparam17.Value = purchaseordermasterinfo.Date;
                sprmparam17       = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
                sprmparam17.Value = purchaseordermasterinfo.LedgerId;
                sprmparam17       = sccmd.Parameters.Add("@dueDate", SqlDbType.DateTime);
                sprmparam17.Value = purchaseordermasterinfo.DueDate;
                sprmparam17       = sccmd.Parameters.Add("@cancelled", SqlDbType.Bit);
                sprmparam17.Value = purchaseordermasterinfo.Cancelled;
                sprmparam17       = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal);
                sprmparam17.Value = purchaseordermasterinfo.EmployeeId;
                sprmparam17       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam17.Value = purchaseordermasterinfo.Narration;
                sprmparam17       = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
                sprmparam17.Value = purchaseordermasterinfo.TotalAmount;
                sprmparam17       = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
                sprmparam17.Value = purchaseordermasterinfo.UserId;
                sprmparam17       = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
                sprmparam17.Value = purchaseordermasterinfo.FinancialYearId;
                sprmparam17       = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
                sprmparam17.Value = purchaseordermasterinfo.exchangeRateId;
                sprmparam17       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam17.Value = purchaseordermasterinfo.Extra1;
                sprmparam17       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam17.Value = purchaseordermasterinfo.Extra2;
                decIdentity       = Convert.ToDecimal(sccmd.ExecuteScalar());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                base.sqlcon.Close();
            }
            return(decIdentity);
        }
コード例 #2
0
 /// <summary>
 /// Function to Update values in PurchaseOrderMaster Table
 /// </summary>
 /// <param name="purchaseordermasterinfo"></param>
 public void PurchaseOrderMasterEdit(PurchaseOrderMasterInfo purchaseordermasterinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("PurchaseOrderMasterEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@purchaseOrderMasterId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.PurchaseOrderMasterId;
         sprmparam       = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar);
         sprmparam.Value = purchaseordermasterinfo.VoucherNo;
         sprmparam       = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar);
         sprmparam.Value = purchaseordermasterinfo.InvoiceNo;
         sprmparam       = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.SuffixPrefixId;
         sprmparam       = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.VoucherTypeId;
         sprmparam       = sccmd.Parameters.Add("@date", SqlDbType.DateTime);
         sprmparam.Value = purchaseordermasterinfo.Date;
         sprmparam       = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.LedgerId;
         sprmparam       = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.exchangeRateId;
         sprmparam       = sccmd.Parameters.Add("@dueDate", SqlDbType.DateTime);
         sprmparam.Value = purchaseordermasterinfo.DueDate;
         sprmparam       = sccmd.Parameters.Add("@cancelled", SqlDbType.Bit);
         sprmparam.Value = purchaseordermasterinfo.Cancelled;
         sprmparam       = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.EmployeeId;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = purchaseordermasterinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.TotalAmount;
         sprmparam       = sccmd.Parameters.Add("@userId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.UserId;
         sprmparam       = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal);
         sprmparam.Value = purchaseordermasterinfo.FinancialYearId;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = purchaseordermasterinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = purchaseordermasterinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
コード例 #3
0
        public void PurchaseOrderMasterEdit(PurchaseOrderMasterInfo purchaseordermasterinfo)
        {
            PurchaseOrderMasterSP SPPurchaseOrderMaster = new PurchaseOrderMasterSP();

            try
            {
                SPPurchaseOrderMaster.PurchaseOrderMasterEdit(purchaseordermasterinfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("PoBll 19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #4
0
        public decimal PurchaseOrderMasterAdd(PurchaseOrderMasterInfo purchaseordermasterinfo)
        {
            PurchaseOrderMasterSP SPPurchaseOrderMaster = new PurchaseOrderMasterSP();
            decimal decIdentity = 0;

            try
            {
                decIdentity = SPPurchaseOrderMaster.PurchaseOrderMasterAdd(purchaseordermasterinfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("PoBll 21:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(decIdentity);
        }
コード例 #5
0
        public PurchaseOrderMasterInfo PurchaseOrderMasterView(decimal purchaseOrderMasterId)
        {
            PurchaseOrderMasterInfo purchaseordermasterinfo = new PurchaseOrderMasterInfo();
            PurchaseOrderMasterSP   SPPurchaseOrderMaster   = new PurchaseOrderMasterSP();

            try
            {
                purchaseordermasterinfo = SPPurchaseOrderMaster.PurchaseOrderMasterView(purchaseOrderMasterId);
            }
            catch (Exception ex)
            {
                MessageBox.Show("PoBll 1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(purchaseordermasterinfo);
        }
コード例 #6
0
        public PurchaseOrderMasterInfo PurchaseOrderMasterView(decimal purchaseOrderMasterId)
        {
            PurchaseOrderMasterInfo purchaseordermasterinfo = new PurchaseOrderMasterInfo();
            SqlDataReader           sdrreader = null;

            try
            {
                if (base.sqlcon.State == ConnectionState.Closed)
                {
                    base.sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("PurchaseOrderMasterView", base.sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam2 = new SqlParameter();
                sprmparam2       = sccmd.Parameters.Add("@purchaseOrderMasterId", SqlDbType.Decimal);
                sprmparam2.Value = purchaseOrderMasterId;
                sdrreader        = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    purchaseordermasterinfo.VoucherNo      = ((DbDataReader)sdrreader)["voucherNo"].ToString();
                    purchaseordermasterinfo.InvoiceNo      = ((DbDataReader)sdrreader)["invoiceNo"].ToString();
                    purchaseordermasterinfo.SuffixPrefixId = decimal.Parse(((DbDataReader)sdrreader)["suffixPrefixId"].ToString());
                    purchaseordermasterinfo.VoucherTypeId  = decimal.Parse(((DbDataReader)sdrreader)["voucherTypeId"].ToString());
                    purchaseordermasterinfo.Date           = DateTime.Parse(((DbDataReader)sdrreader)["date"].ToString());
                    purchaseordermasterinfo.LedgerId       = decimal.Parse(((DbDataReader)sdrreader)["ledgerId"].ToString());
                    purchaseordermasterinfo.DueDate        = DateTime.Parse(((DbDataReader)sdrreader)["dueDate"].ToString());
                    purchaseordermasterinfo.Narration      = ((DbDataReader)sdrreader)["narration"].ToString();
                    purchaseordermasterinfo.TotalAmount    = decimal.Parse(((DbDataReader)sdrreader)["totalAmount"].ToString());
                    purchaseordermasterinfo.exchangeRateId = decimal.Parse(((DbDataReader)sdrreader)["exchangeRateId"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                base.sqlcon.Close();
            }
            return(purchaseordermasterinfo);
        }
コード例 #7
0
        /// <summary>
        /// Fill function to updation
        /// </summary>
        /// <param name="isPending"></param>
        public void FillRegisterOrReport(bool isPending)
        {
            try
            {
                PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();

                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll();
                btnSave.Text = "Update";
                btnDelete.Enabled = true;
                txtOrderNo.ReadOnly = true;
                infoPurchaseOrderMaster = BllPurchaseOrder.PurchaseOrderMasterView(decPurchaseOrderMasterId);
                txtOrderNo.Text = infoPurchaseOrderMaster.InvoiceNo;
                strVoucherNo = infoPurchaseOrderMaster.VoucherNo.ToString();
                decPurchaseSuffixPrefixId = Convert.ToDecimal(infoPurchaseOrderMaster.SuffixPrefixId);
                decPurchaseVoucherId = Convert.ToDecimal(infoPurchaseOrderMaster.VoucherTypeId);
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPurchaseVoucherId);
                decPurchaseOrderTypeId = decPurchaseVoucherId;
                txtDate.Text = infoPurchaseOrderMaster.Date.ToString("dd-MMM-yyyy");
                cmbCashOrParty.SelectedValue = infoPurchaseOrderMaster.LedgerId;
                txtDueDate.Text = infoPurchaseOrderMaster.DueDate.ToString("dd-MMM-yyyy");
                TimeSpan objTs = Convert.ToDateTime(txtDueDate.Text).Subtract(Convert.ToDateTime(txtDate.Text));
                txtDueDays.Text = objTs.Days.ToString();
                txtNarration.Text = infoPurchaseOrderMaster.Narration;
                cmbCurrency.SelectedValue = infoPurchaseOrderMaster.exchangeRateId;
                txtTotalAmount.Text = infoPurchaseOrderMaster.TotalAmount.ToString();
                List<DataTable> ListObj = new List<DataTable>();
                if (isPending)
                {
                    ListObj = BllPurchaseOrder.PurchaseOrderDetailsViewWithRemaining(decPurchaseOrderMasterId);
                }
                else
                {
                    ListObj = BllPurchaseOrder.PurchaseOrderDetailsViewByMasterId(decPurchaseOrderMasterId);
                }
                if (CheckCancelStatus(decPurchaseOrderMasterId))
                {
                    isCheck = true;
                    cbxCancel.Checked = true;
                    cbxCancel.Enabled = false;
                    isCheck = false;
                }
                else
                {
                    isCheck = true;
                    cbxCancel.Enabled = true;
                    //  cbxCancel.Checked = false;
                    isCheck = false;
                }
                dgvPurchaseOrder.Rows.Clear();
                for (int i = 0; i < ListObj[0].Rows.Count; i++)
                {
                    isAmountcalc = false;
                    dgvPurchaseOrder.Rows.Add();
                    dgvPurchaseOrder.Rows[i].HeaderCell.Value = string.Empty;
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["purchaseOrderDetailsId"].ToString());
                    decPurchaseOrderDetailId = Convert.ToDecimal(ListObj[0].Rows[i]["purchaseOrderDetailsId"].ToString());
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtProductId"].Value = ListObj[0].Rows[i]["productId"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtProductCode"].Value = ListObj[0].Rows[i]["productCode"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtProductName"].Value = ListObj[0].Rows[i]["productName"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtQty"].Value = ListObj[0].Rows[i]["qty"].ToString();
                    UnitComboFill(Convert.ToDecimal(ListObj[0].Rows[i]["productId"].ToString()), i, dgvPurchaseOrder.Rows[i].Cells["dgvcmbUnit"].ColumnIndex);
                    dgvPurchaseOrder.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["unitId"].ToString());
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtUnitConversionId"].Value = ListObj[0].Rows[i]["unitConversionId"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtUnitConversionRate"].Value = ListObj[0].Rows[i]["conversionRate"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtRate"].Value = ListObj[0].Rows[i]["rate"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtAmount"].Value = ListObj[0].Rows[i]["amount"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtProductName"].ReadOnly = true;
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtProductCode"].ReadOnly = true;
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtBarcode"].ReadOnly = true;
                }
                SerialNo();
                isAmountcalc = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("PO25:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #8
0
 /// <summary>
 /// Edit function
 /// </summary>
 public void EditFunction()
 {
     try
     {
         PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();
         PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll();
         SettingsBll BllSettings = new SettingsBll();
         infoPurchaseOrderMaster.PurchaseOrderMasterId = decPurchaseOrderMasterId;
         if (CheckCancelStatus(decPurchaseOrderMasterId))
         {
             infoPurchaseOrderMaster.Cancelled = true;
         }
         else
         {
             infoPurchaseOrderMaster.Cancelled = false;
         }
         infoPurchaseOrderMaster.Date = Convert.ToDateTime(txtDate.Text);
         infoPurchaseOrderMaster.DueDate = Convert.ToDateTime(txtDueDate.Text);
         infoPurchaseOrderMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
         infoPurchaseOrderMaster.SuffixPrefixId = Convert.ToDecimal(decPurchaseSuffixPrefixId);
         infoPurchaseOrderMaster.VoucherNo = strVoucherNo;
         infoPurchaseOrderMaster.VoucherTypeId = decPurchaseVoucherId;
         infoPurchaseOrderMaster.InvoiceNo = txtOrderNo.Text;
         infoPurchaseOrderMaster.UserId = PublicVariables._decCurrentUserId;
         infoPurchaseOrderMaster.EmployeeId = PublicVariables._decCurrentUserId;//by default current userid used as current employeeid
         infoPurchaseOrderMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
         infoPurchaseOrderMaster.Narration = txtNarration.Text.Trim();
         infoPurchaseOrderMaster.exchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         infoPurchaseOrderMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text);
         infoPurchaseOrderMaster.Extra1 = string.Empty;
         infoPurchaseOrderMaster.Extra2 = string.Empty;
         BllPurchaseOrder.PurchaseOrderMasterEdit(infoPurchaseOrderMaster);
         RemovePurchaseOrderDetails();
         EditPurchaseOrderDetails();
         Messages.UpdatedMessage();
         if (frmPurchaseOrderRegisterObj != null)
         {
             if (cbxPrintAfterSave.Checked)
             {
                 if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decPurchaseOrderMasterId);
                 }
                 else
                 {
                     Print(decPurchaseOrderMasterId);
                 }
             }
             this.Close();
             frmPurchaseOrderRegisterObj.GridFill();
         }
         if (frmPurchaseOrderReportObj != null)
         {
             if (cbxPrintAfterSave.Checked)
             {
                 if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decPurchaseOrderMasterId);
                 }
                 else
                 {
                     Print(decPurchaseOrderMasterId);
                 }
             }
             this.Close();
             frmPurchaseOrderReportObj.GridFill();
         }
         if (frmDayBookObj != null)
         {
             if (cbxPrintAfterSave.Checked)
             {
                 if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decPurchaseOrderMasterId);
                 }
                 else
                 {
                     Print(decPurchaseOrderMasterId);
                 }
             }
             this.Close();
         }
         if (objVoucherSearch != null)
         {
             if (cbxPrintAfterSave.Checked)
             {
                 if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decPurchaseOrderMasterId);
                 }
                 else
                 {
                     Print(decPurchaseOrderMasterId);
                 }
             }
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PO34:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #9
0
        /// <summary>
        /// Save Function
        /// </summary>
        public void SaveFunction()
        {
            try
            {
                PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();
                PurchaseOrderBll BllPurchaseOrder = new  PurchaseOrderBll();
                PurchaseOrderDetailsInfo infoPurchaseOrderDetails = new PurchaseOrderDetailsInfo();

                ProductInfo infoProduct = new ProductInfo();
                ProductCreationBll BllProductCreation = new ProductCreationBll();
                SettingsBll BllSettings = new SettingsBll();
                if (cbxCancel.Checked)
                {
                    infoPurchaseOrderMaster.Cancelled = true;
                }
                else
                {
                    infoPurchaseOrderMaster.Cancelled = false;
                }
                infoPurchaseOrderMaster.Date = Convert.ToDateTime(txtDate.Text);
                infoPurchaseOrderMaster.DueDate = Convert.ToDateTime(txtDueDate.Text);
                infoPurchaseOrderMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
                if (isAutomatic == true)
                {
                    infoPurchaseOrderMaster.SuffixPrefixId = decPurchaseSuffixPrefixId;
                    infoPurchaseOrderMaster.VoucherNo = strVoucherNo;
                }
                else
                {
                    infoPurchaseOrderMaster.SuffixPrefixId = 0;
                    infoPurchaseOrderMaster.VoucherNo = BllPurchaseOrder.VoucherNoMax(decPurchaseOrderTypeId);
                }
                infoPurchaseOrderMaster.VoucherTypeId = decPurchaseOrderTypeId;
                infoPurchaseOrderMaster.InvoiceNo = txtOrderNo.Text;
                infoPurchaseOrderMaster.UserId = PublicVariables._decCurrentUserId;
                infoPurchaseOrderMaster.EmployeeId = PublicVariables._decCurrentUserId;//by default current userid used as current employeeid
                infoPurchaseOrderMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                infoPurchaseOrderMaster.Narration = txtNarration.Text.Trim();
                infoPurchaseOrderMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text);
                infoPurchaseOrderMaster.exchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
                infoPurchaseOrderMaster.Extra1 = string.Empty;
                infoPurchaseOrderMaster.Extra2 = string.Empty;
                decPurchaseOrderMasterIdentity = Convert.ToDecimal(BllPurchaseOrder.PurchaseOrderMasterAdd(infoPurchaseOrderMaster));
                int inRowcount = dgvPurchaseOrder.Rows.Count;
                for (int inI = 0; inI < inRowcount - 1; inI++)
                {
                    infoPurchaseOrderDetails.PurchaseOrderMasterId = decPurchaseOrderMasterIdentity;
                    if (dgvPurchaseOrder.Rows[inI].Cells["dgvtxtProductCode"].Value != null && dgvPurchaseOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString() != "")
                    {
                        infoProduct = BllProductCreation.ProductViewByCode(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString());
                        infoPurchaseOrderDetails.ProductId = infoProduct.ProductId;
                    }
                    if (dgvPurchaseOrder.Rows[inI].Cells["dgvtxtQty"].Value != null && dgvPurchaseOrder.Rows[inI].Cells["dgvtxtQty"].Value.ToString() != "")
                    {
                        infoPurchaseOrderDetails.Qty = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtQty"].Value.ToString());
                    }
                    if (dgvPurchaseOrder.Rows[inI].Cells["dgvcmbUnit"].Value != null && dgvPurchaseOrder.Rows[inI].Cells["dgvcmbUnit"].Value.ToString() != "")
                    {
                        infoPurchaseOrderDetails.UnitId = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvcmbUnit"].Value);
                        infoPurchaseOrderDetails.UnitConversionId = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString());
                    }
                    infoPurchaseOrderDetails.Rate = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
                    infoPurchaseOrderDetails.Amount = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                    infoPurchaseOrderDetails.SlNo = Convert.ToInt32(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString());
                    infoPurchaseOrderDetails.Extra1 = string.Empty;
                    infoPurchaseOrderDetails.Extra2 = string.Empty;
                    BllPurchaseOrder.PurchaseOrderDetailsAdd(infoPurchaseOrderDetails);
                }
                Messages.SavedMessage();
                if (cbxPrintAfterSave.Checked)
                {
                    if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                    {
                        PrintForDotMatrix(decPurchaseOrderMasterIdentity);
                    }
                    else
                    {
                        Print(decPurchaseOrderMasterIdentity);
                    }
                }
                Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("PO35:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #10
0
        /// <summary>
        /// Function to fill the fields for edit or delete
        /// </summary>
        public void FillRegisterOrReport()
        {
            MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo();
            MaterialReceiptDetailsInfo infoMaterialReceiptDetails = new MaterialReceiptDetailsInfo();
            VoucherTypeBll BllVoucherType = new VoucherTypeBll();
            MaterialReceiptBll bllMaterialReceiptMaster = new MaterialReceiptBll();
            MaterialReceiptBll bllMaterialReceiptDetails = new MaterialReceiptBll();
            PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll();
            try
            {

                PurchaseOrderMasterInfo infoPurchaseOrder = new PurchaseOrderMasterInfo();
                decimal decTotal = 0;
                decimal decStatus = bllMaterialReceiptMaster.MaterialReceiptMasterReferenceCheck(decMaterialReceiptMasterId);
                if (decStatus == 0)
                {
                    cmbCashOrParty.Enabled = false;
                    cmbOrderNo.Enabled = false;
                    cmbcurrency.Enabled = false;
                    txtDate.Enabled = false;
                    cmbVoucherType.Enabled = false;
                }
                btnSave.Text = "Update";
                btnDelete.Enabled = true;
                txtReceiptNo.ReadOnly = true;
                infoMaterialReceiptMaster = bllMaterialReceiptMaster.MaterialReceiptMasterView(decMaterialReceiptMasterId);
                txtReceiptNo.Text = infoMaterialReceiptMaster.InvoiceNo;
                strVoucherNo = infoMaterialReceiptMaster.VoucherNo.ToString();
                decMaterialReceiptSuffixPrefixId = Convert.ToDecimal(infoMaterialReceiptMaster.SuffixPrefixId);
                decMaterialReceiptVoucherTypeId = Convert.ToDecimal(infoMaterialReceiptMaster.VoucherTypeId);
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decMaterialReceiptVoucherTypeId);
                decMaterialReceiptTypeId = decMaterialReceiptVoucherTypeId;
                txtDate.Text = infoMaterialReceiptMaster.Date.ToString("dd-MMM-yyyy");
                cmbCashOrParty.SelectedValue = infoMaterialReceiptMaster.LedgerId;
                if (infoMaterialReceiptMaster.OrderMasterId != 0)
                {
                    infoPurchaseOrder = BllPurchaseOrder.PurchaseOrderMasterView(Convert.ToDecimal(infoMaterialReceiptMaster.OrderMasterId.ToString()));
                    decPurchaseOrderVoucherTypeId = infoPurchaseOrder.VoucherTypeId;
                    cmbVoucherType.SelectedValue = decPurchaseOrderVoucherTypeId;
                    cmbOrderNo.SelectedValue = infoMaterialReceiptMaster.OrderMasterId.ToString();
                    decOrderNoWhileEditMode = infoMaterialReceiptMaster.OrderMasterId;
                }
                else
                {
                    cmbVoucherType.SelectedValue = 0;
                }
                txtTransportation.Text = infoMaterialReceiptMaster.TransportationCompany;
                txtNarration.Text = infoMaterialReceiptMaster.Narration;
                txtLRNo.Text = infoMaterialReceiptMaster.LrNo;
                CurrencyComboFill();
                cmbcurrency.SelectedValue = infoMaterialReceiptMaster.exchangeRateId;
                decTotal = Convert.ToDecimal(infoMaterialReceiptMaster.TotalAmount.ToString());
                decTotal = Math.Round(decTotal, PublicVariables._inNoOfDecimalPlaces);
                txtTotal.Text = Convert.ToString(decTotal);
                List<DataTable> ListObj = new List<DataTable>();
                ListObj = bllMaterialReceiptDetails.MaterialReceiptDetailsViewByMasterId(decMaterialReceiptMasterId);
                dgvProduct.Rows.Clear();
                for (int i = 0; i < ListObj[0].Rows.Count; i++)
                {
                    isAmountcalc = false;
                    isValueChange = false;
                    dgvProduct.Rows.Add();
                    dgvProduct.Rows[i].Cells["dgvtxtMaterialReceiptdetailsId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["materialReceiptDetailsId"].ToString());
                    decMaterialReceiptDetailId = Convert.ToDecimal(ListObj[0].Rows[i]["materialReceiptDetailsId"].ToString());
                    dgvProduct.Rows[i].Cells["dgvtxtSlNo"].Value = ListObj[0].Rows[i]["slno"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtProductCode"].Value = ListObj[0].Rows[i]["productCode"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtProductName"].Value = ListObj[0].Rows[i]["productName"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtQty"].Value = ListObj[0].Rows[i]["qty"].ToString();
                    dgvProduct.Rows[i].Cells["productId"].Value = ListObj[0].Rows[i]["productId"].ToString();
                    decimal decProductId = Convert.ToDecimal(ListObj[0].Rows[i]["productId"].ToString());
                    UnitComboFill(decProductId, i, dgvProduct.Rows[i].Cells["dgvcmbUnit"].ColumnIndex);
                    dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["unitId"].ToString());
                    DGVGodownComboFill();
                    dgvProduct.Rows[i].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["godownId"].ToString());
                    decGodownId = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvcmbGodown"].Value);
                    RackComboFill(decGodownId, i, dgvProduct.Rows[i].Cells["dgvCmbRack"].ColumnIndex);
                    if (Convert.ToDecimal(ListObj[0].Rows[i]["orderDetailsId"].ToString()) == 0)
                    {
                        dgvProduct.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = 0;
                    }
                    else
                    {
                        dgvProduct.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["orderDetailsId"].ToString());

                    }
                    dgvProduct.Rows[i].Cells["dgvCmbRack"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["rackId"].ToString());
                    BatchComboFill(decProductId, i, Convert.ToInt32(dgvProduct.Rows[i].Cells["dgvcmbBatch"].ColumnIndex));
                    dgvProduct.Rows[i].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["batchId"].ToString());
                    dgvProduct.Rows[i].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["unitConversionId"].ToString());
                    dgvProduct.Rows[i].Cells["dgvtxtBarcode"].Value = ListObj[0].Rows[i]["barcode"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = ListObj[0].Rows[i]["rate"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtAmount"].Value = ListObj[0].Rows[i]["amount"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtvouchertypeId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["voucherTypeId"].ToString());
                    dgvProduct.Rows[i].Cells["dgvtxtvoucherNo"].Value = ListObj[0].Rows[i]["voucherNo"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtinvoiceNo"].Value = ListObj[0].Rows[i]["invoiceNo"].ToString();
                    decAgainstVoucherTypeId = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtvouchertypeId"].Value.ToString());
                    strAgainstVoucherNo = dgvProduct.Rows[i].Cells["dgvtxtvoucherNo"].Value.ToString();
                    UnitConvertionBll bllUnitConvertion = new UnitConvertionBll();
                    List<DataTable> listObjUnitByProduct = new List<DataTable>();
                    listObjUnitByProduct = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(decProductId.ToString());
                    foreach (DataRow drUnitByProduct in listObjUnitByProduct[0].Rows)
                    {
                        if (dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                        {
                            dgvProduct.Rows[i].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                            dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());
                        }
                    }
                    decCurrentRate = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtRate"].Value.ToString());
                    decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value.ToString());
                    decimal decReference = bllMaterialReceiptMaster.MaterialReceiptDetailsReferenceCheck(decMaterialReceiptDetailId);
                    if (decReference == 1 || Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value.ToString())!=0)
                    {
                        dgvProduct.Rows[i].Cells["dgvtxtProductCode"].ReadOnly = true;
                        dgvProduct.Rows[i].Cells["dgvtxtProductName"].ReadOnly = true;
                        dgvProduct.Rows[i].Cells["dgvcmbUnit"].ReadOnly = true;
                        dgvProduct.Rows[i].Cells["dgvtxtBarcode"].ReadOnly = true;
                        dgvProduct.Rows[i].Cells["dgvCmbRack"].ReadOnly = true;
                        dgvProduct.Rows[i].Cells["dgvcmbGodown"].ReadOnly = true;
                        dgvProduct.Rows[i].Cells["dgvtxtRate"].ReadOnly = true;
                        dgvProduct.Rows[i].Cells["dgvcmbBatch"].ReadOnly = true;
                    }
                    if (cmbVoucherType.Text != "NA")
                    {
                        dgvProduct.Rows[i].Cells["dgvcmbUnit"].ReadOnly = true;
                    }

                }
                isAmountcalc = true;
                isValueChange = true;
                isDoAfterGridFill = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("MR16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #11
0
 /// <summary>
 /// Function to save purchase invoice
 /// </summary>
 public void Save()
 {
     decimal decPurchaseMasterId = 0;
     PurchaseMasterInfo infoPurchaseMaster = new PurchaseMasterInfo();
     PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll();
     PurchaseDetailsInfo infoPurchaseDetails = new PurchaseDetailsInfo();
     MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo();
     MaterialReceiptBll bllMaterialReceiptMaster = new MaterialReceiptBll();
     PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();
     PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll();
     StockPostingInfo infoStockPosting = new StockPostingInfo();
     StockPostingBll BllStockPosting = new StockPostingBll();
     //StockPostingSP spStockPosting = new StockPostingSP();
     LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
     LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
     PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo();
     //PartyBalanceSP spPartyBalance = new PartyBalanceSP();
     PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
     AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo();
     AditionalCostBll bllAdditionalCost = new AditionalCostBll();
     PurchaseBillTaxInfo infoPurchaseBillTax = new PurchaseBillTaxInfo();
     AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo();
     AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
     UnitConvertionBll bllUnitConvertion = new UnitConvertionBll();
     ExchangeRateBll BllExchangeRate = new ExchangeRateBll();
     try
     {
         /*-----------------------------------------Purchase Master Add----------------------------------------------------*/
         infoPurchaseMaster.AdditionalCost = Convert.ToDecimal(lblAdditionalCostAmount.Text);
         infoPurchaseMaster.BillDiscount = Convert.ToDecimal(txtBillDiscount.Text);
         infoPurchaseMaster.CreditPeriod = txtCreditPeriod.Text;
         infoPurchaseMaster.Date = Convert.ToDateTime(txtVoucherDate.Text);
         infoPurchaseMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         infoPurchaseMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
         infoPurchaseMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text);
         infoPurchaseMaster.InvoiceNo = txtVoucherNo.Text.Trim();
         if (isAutomatic)
         {
             infoPurchaseMaster.SuffixPrefixId = decPurchaseInvoiceSuffixPrefixId;
             infoPurchaseMaster.VoucherNo = strVoucherNo;
         }
         else
         {
             infoPurchaseMaster.SuffixPrefixId = 0;
             infoPurchaseMaster.VoucherNo = strVoucherNo;
         }
         infoPurchaseMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
         infoPurchaseMaster.LrNo = txtLRNo.Text;
         if (cmbPurchaseMode.Text == "Against MaterialReceipt")
         {
             infoPurchaseMaster.MaterialReceiptMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
         }
         else
         {
             infoPurchaseMaster.MaterialReceiptMasterId = 0;
         }
         infoPurchaseMaster.Narration = txtNarration.Text;
         infoPurchaseMaster.PurchaseAccount = Convert.ToDecimal(cmbPurchaseAccount.SelectedValue.ToString());
         if (cmbPurchaseMode.Text == "Against PurchaseOrder")
         {
             infoPurchaseMaster.PurchaseOrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
         }
         else
         {
             infoPurchaseMaster.PurchaseOrderMasterId = 0;
         }
         infoPurchaseMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text);
         infoPurchaseMaster.TotalTax = Convert.ToDecimal(lblTaxAmount.Text);
         infoPurchaseMaster.TransportationCompany = txtTransportationCompany.Text;
         infoPurchaseMaster.UserId = PublicVariables._decCurrentUserId;
         infoPurchaseMaster.VendorInvoiceDate = Convert.ToDateTime(txtInvoiceDate.Text);
         infoPurchaseMaster.VendorInvoiceNo = txtVendorInvoiceNo.Text;
         infoPurchaseMaster.VoucherTypeId = decPurchaseInvoiceVoucherTypeId;
         infoPurchaseMaster.Extra1 = string.Empty;
         infoPurchaseMaster.Extra2 = string.Empty;
         infoPurchaseMaster.ExtraDate = Convert.ToDateTime(DateTime.Now);
         decPurchaseMasterId = BllPurchaseInvoice.PurchaseMasterAdd(infoPurchaseMaster);
         infoPurchaseOrderMaster = BllPurchaseOrder.PurchaseOrderMasterView(infoPurchaseMaster.PurchaseOrderMasterId);
         infoMaterialReceiptMaster = bllMaterialReceiptMaster.MaterialReceiptMasterView(infoPurchaseMaster.MaterialReceiptMasterId);
         foreach (DataGridViewRow dgvrow in dgvProductDetails.Rows)
         {
             if (dgvrow.Cells["dgvtxtProductId"].Value != null)
             {
                 if (dgvrow.Cells["dgvtxtProductId"].Value.ToString() != string.Empty)
                 {
                     /*-----------------------------------------Purchase Details Add----------------------------------------------------*/
                     infoPurchaseDetails.Amount = Convert.ToDecimal(dgvrow.Cells["dgvtxtAmount"].Value.ToString());
                     infoPurchaseDetails.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value.ToString());
                     infoPurchaseDetails.Discount = Convert.ToDecimal(dgvrow.Cells["dgvtxtDiscount"].Value.ToString());
                     infoPurchaseDetails.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value.ToString());
                     infoPurchaseDetails.GrossAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtGrossValue"].Value.ToString());
                     infoPurchaseDetails.NetAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtNetValue"].Value.ToString());
                     infoPurchaseDetails.OrderDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseOrderDetailsId"].Value.ToString());
                     infoPurchaseDetails.ProductId = Convert.ToDecimal(dgvrow.Cells["dgvtxtProductId"].Value.ToString());
                     infoPurchaseDetails.PurchaseMasterId = decPurchaseMasterId;
                     infoPurchaseDetails.Qty = Convert.ToDecimal(dgvrow.Cells["dgvtxtQuantity"].Value.ToString());
                     infoPurchaseDetails.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value.ToString());
                     infoPurchaseDetails.Rate = Convert.ToDecimal(dgvrow.Cells["dgvtxtRate"].Value.ToString());
                     infoPurchaseDetails.ReceiptDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtMaterialReceiptDetailsId"].Value.ToString());
                     infoPurchaseDetails.SlNo = Convert.ToInt32(dgvrow.Cells["dgvtxtSlNo"].Value.ToString());
                     infoPurchaseDetails.TaxAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtTaxAmount"].Value.ToString());
                     infoPurchaseDetails.TaxId = Convert.ToDecimal(dgvrow.Cells["dgvcmbTax"].Value.ToString());
                     infoPurchaseDetails.UnitConversionId = Convert.ToDecimal(dgvrow.Cells["dgvtxtUnitConversionId"].Value.ToString());
                     infoPurchaseDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString());
                     infoPurchaseDetails.Extra1 = string.Empty;
                     infoPurchaseDetails.Extra2 = string.Empty;
                     infoPurchaseDetails.ExtraDate = Convert.ToDateTime(DateTime.Today);
                     BllPurchaseInvoice.PurchaseDetailsAdd(infoPurchaseDetails);
                     /*-----------------------------------------Stock Posting----------------------------------------------------*/
                     infoStockPosting.BatchId = infoPurchaseDetails.BatchId;
                     infoStockPosting.Date = infoPurchaseMaster.Date;
                     infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                     infoStockPosting.GodownId = infoPurchaseDetails.GodownId;
                     infoStockPosting.InwardQty = infoPurchaseDetails.Qty; /// spUnitConvertion.UnitConversionRateByUnitConversionId(infoPurchaseDetails.UnitConversionId);
                     infoStockPosting.OutwardQty = 0;
                     infoStockPosting.ProductId = infoPurchaseDetails.ProductId;
                     infoStockPosting.RackId = infoPurchaseDetails.RackId;
                     infoStockPosting.Rate = infoPurchaseDetails.Rate;
                     infoStockPosting.UnitId = infoPurchaseDetails.UnitId;
                     if (infoPurchaseDetails.OrderDetailsId != 0)
                     {
                         infoStockPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo;
                         infoStockPosting.VoucherNo = infoPurchaseMaster.VoucherNo;
                         infoStockPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId;
                         infoStockPosting.AgainstInvoiceNo = "NA";
                         infoStockPosting.AgainstVoucherNo = "NA";
                         infoStockPosting.AgainstVoucherTypeId = 0;
                     }
                     else if (infoPurchaseDetails.ReceiptDetailsId != 0)
                     {
                         infoStockPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo;
                         infoStockPosting.VoucherNo = infoPurchaseMaster.VoucherNo;
                         infoStockPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId;
                         infoStockPosting.AgainstInvoiceNo = "NA";
                         infoStockPosting.AgainstVoucherNo = "NA";
                         infoStockPosting.AgainstVoucherTypeId = 0;
                     }
                     else if (infoPurchaseDetails.OrderDetailsId == 0 && infoPurchaseDetails.ReceiptDetailsId == 0)
                     {
                         infoStockPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo;
                         infoStockPosting.VoucherNo = infoPurchaseMaster.VoucherNo;
                         infoStockPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId;
                         infoStockPosting.AgainstInvoiceNo = "NA";
                         infoStockPosting.AgainstVoucherNo = "NA";
                         infoStockPosting.AgainstVoucherTypeId = 0;
                     }
                     infoStockPosting.Extra1 = string.Empty;
                     infoStockPosting.Extra2 = string.Empty;
                     infoStockPosting.ExtraDate = Convert.ToDateTime(DateTime.Today);
                     BllStockPosting.StockPostingAdd(infoStockPosting);
                     if (infoPurchaseDetails.ReceiptDetailsId != 0)
                     {
                         infoStockPosting.InvoiceNo = infoMaterialReceiptMaster.InvoiceNo;
                         infoStockPosting.VoucherNo = infoMaterialReceiptMaster.VoucherNo;
                         infoStockPosting.VoucherTypeId = infoMaterialReceiptMaster.VoucherTypeId;
                         infoStockPosting.AgainstInvoiceNo = infoPurchaseMaster.InvoiceNo;
                         infoStockPosting.AgainstVoucherNo = infoPurchaseMaster.VoucherNo;
                         infoStockPosting.AgainstVoucherTypeId = infoPurchaseMaster.VoucherTypeId;
                         infoStockPosting.InwardQty = 0;
                         infoStockPosting.OutwardQty = infoPurchaseDetails.Qty;/// spUnitConvertion.UnitConversionRateByUnitConversionId(infoPurchaseDetails.UnitConversionId);
                         BllStockPosting.StockPostingAdd(infoStockPosting);
                     }
                 }
             }
         }
         /*-----------------------------------------Ledger Posting----------------------------------------------------*/
         infoLedgerPosting.Credit = Convert.ToDecimal(txtGrandTotal.Text) * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()));
         infoLedgerPosting.Debit = 0;
         infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate);
         infoLedgerPosting.DetailsId = 0;
         infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo;
         infoLedgerPosting.LedgerId = infoPurchaseMaster.LedgerId;
         infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo;
         infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId;
         infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
         infoLedgerPosting.ChequeDate = DateTime.Now;
         infoLedgerPosting.ChequeNo = string.Empty;
         infoLedgerPosting.Extra1 = string.Empty;
         infoLedgerPosting.Extra2 = string.Empty;
         infoLedgerPosting.ExtraDate = DateTime.Now;
         BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
         decimal decBilldiscount = Convert.ToDecimal(txtBillDiscount.Text.ToString());
         if (decBilldiscount > 0)
         {
             infoLedgerPosting.Credit = decBilldiscount * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()));
             infoLedgerPosting.Debit = 0;
             infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate);
             infoLedgerPosting.DetailsId = 0;
             infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo;
             infoLedgerPosting.LedgerId = 9;//ledger id of discount received
             infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo;
             infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId;
             infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
             infoLedgerPosting.ChequeDate = DateTime.Now;
             infoLedgerPosting.ChequeNo = string.Empty;
             infoLedgerPosting.Extra1 = string.Empty;
             infoLedgerPosting.Extra2 = string.Empty;
             infoLedgerPosting.ExtraDate = DateTime.Now;
             BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
         }
         infoLedgerPosting.Credit = 0;
         infoLedgerPosting.Debit = TotalNetAmount(); //* spExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()));
         infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate);
         infoLedgerPosting.DetailsId = 0;
         infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo;
         infoLedgerPosting.LedgerId = infoPurchaseMaster.PurchaseAccount;//ledger posting of purchase account
         infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo;
         infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId;
         infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
         infoLedgerPosting.ChequeDate = DateTime.Now;
         infoLedgerPosting.ChequeNo = string.Empty;
         infoLedgerPosting.Extra1 = string.Empty;
         infoLedgerPosting.Extra2 = string.Empty;
         infoLedgerPosting.ExtraDate = DateTime.Now;
         BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
         foreach (DataGridViewRow dgvrow in dgvAdditionalCost.Rows)
         {
             if (dgvrow.Cells["dgvcmbLedger"].Value != null)
             {
                 if (dgvrow.Cells["dgvcmbLedger"].Value.ToString() != string.Empty)
                 {
                     if (dgvrow.Cells["dgvtxtAdditionalCostAmount"].Value != null)
                     {
                         if (dgvrow.Cells["dgvtxtAdditionalCostAmount"].Value.ToString() != string.Empty)
                         {
                             /*-----------------------------------------Additional Cost Add----------------------------------------------------*/
                             infoAdditionalCost.Credit = 0;
                             infoAdditionalCost.Debit = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCostAmount"].Value.ToString());
                             infoAdditionalCost.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvcmbLedger"].Value.ToString());
                             infoAdditionalCost.VoucherNo = infoPurchaseMaster.VoucherNo;
                             infoAdditionalCost.VoucherTypeId = infoPurchaseMaster.VoucherTypeId;
                             infoAdditionalCost.Extra1 = string.Empty;
                             infoAdditionalCost.Extra2 = string.Empty;
                             infoAdditionalCost.ExtraDate = DateTime.Now;
                             bllAdditionalCost.AdditionalCostAdd(infoAdditionalCost);
                             /*-----------------------------------------Additional Cost Ledger Posting----------------------------------------------------*/
                             infoLedgerPosting.Credit = 0;
                             infoLedgerPosting.Debit = infoAdditionalCost.Debit * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()));
                             infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate);
                             infoLedgerPosting.DetailsId = 0;
                             infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo;
                             infoLedgerPosting.LedgerId = infoAdditionalCost.LedgerId;
                             infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo;
                             infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId;
                             infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                             infoLedgerPosting.ChequeDate = DateTime.Now;
                             infoLedgerPosting.ChequeNo = string.Empty;
                             infoLedgerPosting.Extra1 = string.Empty;
                             infoLedgerPosting.Extra2 = string.Empty;
                             infoLedgerPosting.ExtraDate = DateTime.Now;
                             BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                         }
                     }
                 }
             }
         }
         if (dgvTax.Visible)
         {
             foreach (DataGridViewRow dgvrow in dgvTax.Rows)
             {
                 if (dgvrow.Cells["dgvtxtTaxId"].Value != null)
                 {
                     if (dgvrow.Cells["dgvtxtTaxId"].Value.ToString() != string.Empty)
                     {
                         /*-----------------------------------------PurchaseBillTax Add----------------------------------------------------*/
                         infoPurchaseBillTax.PurchaseMasterId = decPurchaseMasterId;
                         infoPurchaseBillTax.TaxAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtTotalTax"].Value.ToString());
                         infoPurchaseBillTax.TaxId = Convert.ToDecimal(dgvrow.Cells["dgvtxtTaxId"].Value.ToString());
                         infoPurchaseBillTax.Extra1 = string.Empty;
                         infoPurchaseBillTax.Extra2 = string.Empty;
                         infoPurchaseBillTax.ExtraDate = DateTime.Now;
                         BllPurchaseInvoice.PurchaseBillTaxAdd(infoPurchaseBillTax);
                         /*-----------------------------------------Tax Ledger Posting----------------------------------------------------*/
                         infoLedgerPosting.Credit = 0;
                         infoLedgerPosting.Debit = infoPurchaseBillTax.TaxAmount * BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()));
                         infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate);
                         infoLedgerPosting.DetailsId = 0;
                         infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo;
                         infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvtxtLedgerId"].Value.ToString());
                         infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo;
                         infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId;
                         infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                         infoLedgerPosting.ChequeDate = DateTime.Now;
                         infoLedgerPosting.ChequeNo = string.Empty;
                         infoLedgerPosting.Extra1 = string.Empty;
                         infoLedgerPosting.Extra2 = string.Empty;
                         infoLedgerPosting.ExtraDate = DateTime.Now;
                         BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                     }
                 }
             }
         }
         /*-----------------------------------------PartyBalance Posting----------------------------------------------------*/
         infoAccountLedger = bllAccountLedger.AccountLedgerView(infoPurchaseMaster.LedgerId);
         if (infoAccountLedger.BillByBill == true)
         {
             infoPartyBalance.Credit = Convert.ToDecimal(txtGrandTotal.Text);
             infoPartyBalance.Debit = 0;
             if (txtCreditPeriod.Text != string.Empty)
             {
                 infoPartyBalance.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text);
             }
             infoPartyBalance.Date = Convert.ToDateTime(txtVoucherDate.Text);
             infoPartyBalance.ExchangeRateId = infoPurchaseMaster.ExchangeRateId;
             infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
             infoPartyBalance.LedgerId = infoPurchaseMaster.LedgerId;
             infoPartyBalance.ReferenceType = "NEW";
             infoPartyBalance.InvoiceNo = infoPurchaseMaster.InvoiceNo;
             infoPartyBalance.VoucherNo = infoPurchaseMaster.VoucherNo;
             infoPartyBalance.VoucherTypeId = infoPurchaseMaster.VoucherTypeId;
             infoPartyBalance.AgainstInvoiceNo = "NA";
             infoPartyBalance.AgainstVoucherNo = "NA";
             infoPartyBalance.AgainstVoucherTypeId = 0;
             infoPartyBalance.Extra1 = string.Empty;
             infoPartyBalance.Extra2 = string.Empty;
             infoPartyBalance.ExtraDate = DateTime.Now;
             BllPartyBalance.PartyBalanceAdd(infoPartyBalance);
         }
         Messages.SavedMessage();
         if (cbxPrintAfterSave.Checked)
         {
             if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
             {
                 PrintForDotMatrix(decPurchaseMasterId);
             }
             else
             {
                 Print(decPurchaseMasterId);
             }
         }
         Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show("PI38:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #12
0
 /// <summary>
 /// Function to fill the details while calling from register or report
 /// </summary>
 public void FillRegisterOrReport()
 {
     PurchaseMasterInfo infoPurchaseMaster = new PurchaseMasterInfo();
     PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll();
     PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();
     PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll();
     MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo();
     MaterialReceiptBll bllMaterialReceiptMaster = new MaterialReceiptBll();
     VoucherTypeBll BllVoucherType = new VoucherTypeBll();
     VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
     AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
     bool isPartyBalanceRef = false;
     try
     {
         isEditFill = true;
         btnSave.Text = "Update";
         btnDelete.Enabled = true;
         txtVoucherNo.ReadOnly = true;
         infoPurchaseMaster = BllPurchaseInvoice.PurchaseMasterView(decPurchaseMasterId);
         strVoucherNo = infoPurchaseMaster.VoucherNo;
         decPurchaseInvoiceVoucherTypeId = infoPurchaseMaster.VoucherTypeId;
         decPurchaseInvoiceSuffixPrefixId = infoPurchaseMaster.SuffixPrefixId;
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPurchaseInvoiceVoucherTypeId);
         infoVoucherType = BllVoucherType.VoucherTypeView(decPurchaseInvoiceVoucherTypeId);
         this.Text = infoVoucherType.VoucherTypeName;
         if (isAutomatic)
         {
             txtVoucherDate.Focus();
         }
         else
         {
             txtVoucherNo.Focus();
         }
         txtVoucherNo.Text = infoPurchaseMaster.InvoiceNo;
         txtVendorInvoiceNo.Text = infoPurchaseMaster.VendorInvoiceNo;
         dtpVoucherDate.Value = infoPurchaseMaster.Date;
         dtpInvoiceDate.Value = infoPurchaseMaster.VendorInvoiceDate;
         cmbCashOrParty.SelectedValue = infoPurchaseMaster.LedgerId;
         if (infoPurchaseMaster.PurchaseOrderMasterId == 0 && infoPurchaseMaster.MaterialReceiptMasterId == 0)
         {
             cmbPurchaseMode.SelectedItem = "NA";
         }
         else if (infoPurchaseMaster.PurchaseOrderMasterId != 0 && infoPurchaseMaster.MaterialReceiptMasterId == 0)
         {
             cmbPurchaseMode.SelectedItem = "Against PurchaseOrder";
             infoPurchaseOrderMaster = BllPurchaseOrder.PurchaseOrderMasterView(infoPurchaseMaster.PurchaseOrderMasterId);
             cmbVoucherType.SelectedValue = infoPurchaseOrderMaster.VoucherTypeId;
             OrderComboFill();
             cmbOrderNo.SelectedValue = infoPurchaseMaster.PurchaseOrderMasterId;
         }
         else if (infoPurchaseMaster.PurchaseOrderMasterId == 0 && infoPurchaseMaster.MaterialReceiptMasterId != 0)
         {
             cmbPurchaseMode.SelectedItem = "Against MaterialReceipt";
             infoMaterialReceiptMaster = bllMaterialReceiptMaster.MaterialReceiptMasterView(infoPurchaseMaster.MaterialReceiptMasterId);
             cmbVoucherType.SelectedValue = infoMaterialReceiptMaster.VoucherTypeId;
             OrderComboFill();
             cmbOrderNo.SelectedValue = infoPurchaseMaster.MaterialReceiptMasterId;
         }
         cmbPurchaseAccount.SelectedValue = infoPurchaseMaster.PurchaseAccount;
         txtCreditPeriod.Text = infoPurchaseMaster.CreditPeriod;
         cmbCurrency.SelectedValue = infoPurchaseMaster.ExchangeRateId;
         txtNarration.Text = infoPurchaseMaster.Narration;
         lblAdditionalCostAmount.Text = Math.Round(infoPurchaseMaster.AdditionalCost, PublicVariables._inNoOfDecimalPlaces).ToString();
         lblTaxAmount.Text = Math.Round(infoPurchaseMaster.TotalTax, PublicVariables._inNoOfDecimalPlaces).ToString();
         txtTotalAmount.Text = Math.Round(infoPurchaseMaster.TotalAmount, PublicVariables._inNoOfDecimalPlaces).ToString();
         txtBillDiscount.Text = Math.Round(infoPurchaseMaster.BillDiscount, PublicVariables._inNoOfDecimalPlaces).ToString();
         txtLRNo.Text = infoPurchaseMaster.LrNo;
         txtTransportationCompany.Text = infoPurchaseMaster.TransportationCompany;
         txtGrandTotal.Text = Math.Round(infoPurchaseMaster.GrandTotal, PublicVariables._inNoOfDecimalPlaces).ToString();
         PurchaseDetailsFill();
         TaxGridFill();
         AdditionalCostGridFill();
         isPartyBalanceRef = bllAccountLedger.PartyBalanceAgainstReferenceCheck(strVoucherNo, decPurchaseInvoiceVoucherTypeId);
         if (isPartyBalanceRef)
         {
             cmbCashOrParty.Enabled = false;
         }
         else
         {
             cmbCashOrParty.Enabled = true;
         }
         isEditFill = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PI55:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #13
0
 public void Delete()
 {
     PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll();
     AditionalCostBll bllAdditionalCost = new AditionalCostBll();
     AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
     StockPostingBll BllStockPosting = new StockPostingBll();
     // StockPostingSP spStockPosting = new StockPostingSP();
     LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
     PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll();
     MaterialReceiptBll bllMaterialReceiptMaster = new MaterialReceiptBll();
     PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();
     MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo();
     PurchaseMasterInfo infoPurchaseMaster = new PurchaseMasterInfo();
     /*---------------------------------Deleting previous stock posting, Ledger posting, partybalanceposting---------------------------------------*/
     infoPurchaseMaster = BllPurchaseInvoice.PurchaseMasterView(decPurchaseMasterId);
     if (infoPurchaseMaster.MaterialReceiptMasterId != 0)
     {
         infoMaterialReceiptMaster = bllMaterialReceiptMaster.MaterialReceiptMasterView(infoPurchaseMaster.MaterialReceiptMasterId);
         BllStockPosting.StockPostingDeleteForSalesInvoiceAgainstDeliveryNote
             (infoPurchaseMaster.VoucherTypeId, infoPurchaseMaster.VoucherNo,
             infoMaterialReceiptMaster.VoucherNo, infoMaterialReceiptMaster.VoucherTypeId);
     }
     BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType
             (0, "NA", infoPurchaseMaster.VoucherNo, infoPurchaseMaster.VoucherTypeId);
     //-------------------------------------------------
     decimal decPurchaseDetailsId = 0;
     decimal decPurchaseOrderMasterId = 0;
     decimal decMaterialReceiptMasterId = 0;
     decimal decAdditionalCostId = 0;
     decimal decPurchaseBillTaxId = 0;
     int inRef = 0;
     bool isRef = false;
     try
     {
         foreach (DataGridViewRow dgvrow in dgvProductDetails.Rows)
         {
             if (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value != null)
             {
                 if (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString() != string.Empty && dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString() != "0")
                 {
                     decPurchaseDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString());
                     inRef = BllPurchaseInvoice.PurchaseMasterReferenceCheck(decPurchaseMasterId, decPurchaseDetailsId);
                     if (inRef > 0 && !isRef)
                     {
                         isRef = true;
                     }
                 }
             }
         }
         if (!isRef)
         {
             isRef = bllAccountLedger.PartyBalanceAgainstReferenceCheck(strVoucherNo, decPurchaseInvoiceVoucherTypeId);
             if (!isRef)
             {
                 BllPurchaseInvoice.PurchaseMasterDelete(decPurchaseMasterId);
                 BllPurchaseInvoice.PurchaseDetailsDeleteByPurchaseMasterId(decPurchaseMasterId);
                 foreach (DataGridViewRow dgvrow in dgvAdditionalCost.Rows)
                 {
                     if (dgvrow.Cells["dgvtxtAdditionalCostId"].Value != null)
                     {
                         if (dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString() != string.Empty &&
                             dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString() != "0")
                         {
                             decAdditionalCostId = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString());
                             bllAdditionalCost.AdditionalCostDelete(decAdditionalCostId);
                         }
                     }
                 }
                 if (dgvTax.Visible)
                 {
                     foreach (DataGridViewRow dgvrow in dgvTax.Rows)
                     {
                         if (dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value != null)
                         {
                             if (dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString() != string.Empty &&
                                 dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString() != "0")
                             {
                                 decPurchaseBillTaxId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString());
                                 BllPurchaseInvoice.PurchaseBillTaxDelete(decPurchaseBillTaxId);
                             }
                         }
                     }
                 }
                 if (cmbPurchaseMode.Text == "Against PurchaseOrder")
                 {
                     decPurchaseOrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
                     infoPurchaseOrderMaster = BllPurchaseOrder.PurchaseOrderMasterView(decPurchaseOrderMasterId);
                 }
                 else if (cmbPurchaseMode.Text == "Against MaterialReceipt")
                 {
                     decMaterialReceiptMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
                     infoMaterialReceiptMaster = bllMaterialReceiptMaster.MaterialReceiptMasterView(decMaterialReceiptMasterId);
                 }
                 BllLedgerPosting.LedgerPostDelete(strVoucherNo, decPurchaseInvoiceVoucherTypeId);
                 if (infoPurchaseOrderMaster.PurchaseOrderMasterId != 0)
                 {
                     BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType
                         (decPurchaseInvoiceVoucherTypeId, strVoucherNo,
                         infoPurchaseOrderMaster.VoucherNo, infoPurchaseOrderMaster.VoucherTypeId);
                 }
                 else if (infoMaterialReceiptMaster.MaterialReceiptMasterId != 0)
                 {
                     BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType
                         (decPurchaseInvoiceVoucherTypeId, strVoucherNo,
                         infoMaterialReceiptMaster.VoucherNo, infoMaterialReceiptMaster.VoucherTypeId);
                 }
                 BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType
                           (0, "NA", strVoucherNo, decPurchaseInvoiceVoucherTypeId);
                 bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPurchaseInvoiceVoucherTypeId);
                 Messages.DeletedMessage();
                 Clear();
                 this.Close();
             }
             else
             {
                 Messages.InformationMessage("Cannot delete purchase invoice because there is a payment voucher against this invoice");
             }
         }
         else
         {
             Messages.InformationMessage("Cannot delete purchase invoice because reference exists");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PI41:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }