/// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         DataTable dtblPurchaseOrderRegister = new DataTable();
         PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
         if (txtOrderNo.Text.Trim() == string.Empty)
         {
             strInvoiceNo = string.Empty;
         }
         else
         {
             strInvoiceNo = txtOrderNo.Text;
         }
         if (cmbCashOrParty.SelectedIndex == 0 || cmbCashOrParty.SelectedIndex == -1)
         {
             decLedgerId = -1;
         }
         else
         {
             decLedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
         }
         if (rbtnAll.Checked)
         {
             strCondition = "All";
         }
         if (rbtnPendingOrder.Checked)
         {
             strCondition = "Pending";
         }
         if (rbtnOverdue.Checked)
         {
             strCondition = "Due";
         }
         if (rbtnCancelled.Checked)
         {
             strCondition = "Cancelled";
         }
         DateTime FromDate = this.dtpFromDate.Value;
         DateTime ToDate = this.dtpToDate.Value;
         dtblPurchaseOrderRegister = spPurchaseOrderMaster.PurchaseOrderMasterViewAll(strInvoiceNo, decLedgerId, FromDate, ToDate, strCondition);
         dgvPurchaseOrderRegister.DataSource = dtblPurchaseOrderRegister;
         if (dgvPurchaseOrderRegister.Columns.Count > 0)
         {
             dgvPurchaseOrderRegister.Columns["dgvtxtBillAmount"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("POREG2:" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #2
0
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         DataTable             dtblPurchaseOrderRegister = new DataTable();
         PurchaseOrderMasterSP spPurchaseOrderMaster     = new PurchaseOrderMasterSP();
         if (txtOrderNo.Text.Trim() == string.Empty)
         {
             strInvoiceNo = string.Empty;
         }
         else
         {
             strInvoiceNo = txtOrderNo.Text;
         }
         if (cmbCashOrParty.SelectedIndex == 0 || cmbCashOrParty.SelectedIndex == -1)
         {
             decLedgerId = -1;
         }
         else
         {
             decLedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
         }
         if (rbtnAll.Checked)
         {
             strCondition = "All";
         }
         if (rbtnPendingOrder.Checked)
         {
             strCondition = "Pending";
         }
         if (rbtnOverdue.Checked)
         {
             strCondition = "Due";
         }
         if (rbtnCancelled.Checked)
         {
             strCondition = "Cancelled";
         }
         DateTime FromDate = this.dtpFromDate.Value;
         DateTime ToDate   = this.dtpToDate.Value;
         dtblPurchaseOrderRegister           = spPurchaseOrderMaster.PurchaseOrderMasterViewAll(strInvoiceNo, decLedgerId, FromDate, ToDate, strCondition);
         dgvPurchaseOrderRegister.DataSource = dtblPurchaseOrderRegister;
         if (dgvPurchaseOrderRegister.Columns.Count > 0)
         {
             dgvPurchaseOrderRegister.Columns["dgvtxtBillAmount"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "POREG2:" + ex.Message;
     }
 }
Пример #3
0
 /// <summary>
 /// On 'Print' button click to print the data
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvPurchaseOrderReport.Rows.Count > 0)
         {
             PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
             DataSet   dsPurchaseOrderReport             = spPurchaseOrderMaster.PurchaseOrderReportPrinting(1, strInvoiceNo, decLedgerId, decVoucherTypeId, this.dtpFromDate.Value, this.dtpToDate.Value, strStatus);
             frmReport frmReport = new frmReport();
             frmReport.MdiParent = formMDI.MDIObj;
             frmReport.PurchaseOrderReportPrinting(dsPurchaseOrderReport, txtTotalAmount.Text);
         }
         else
         {
             Messages.InformationMessage("No data found");
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "PORP5:" + ex.Message;
     }
 }
Пример #4
0
        /// <summary>
        /// Clear function and voucherno generation based on settings
        /// </summary>
        public void Clear()
        {
            try
            {
                PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
                SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                SettingsSP spSettings = new SettingsSP();
                if (isAutomatic)
                {
                    strVoucherNo = spPurchaseOrderMaster.PurchaseOrderVoucherMasterMax(decPurchaseOrderTypeId).ToString();
                    if (strVoucherNo == string.Empty)
                    {
                        strVoucherNo = "0";
                    }
                    strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPurchaseOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                    if (strVoucherNo != spPurchaseOrderMaster.PurchaseOrderVoucherMasterMax(decPurchaseOrderTypeId).ToString())
                    {
                        strVoucherNo = spPurchaseOrderMaster.PurchaseOrderVoucherMasterMax(decPurchaseOrderTypeId).ToString();
                        strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPurchaseOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                        if (spPurchaseOrderMaster.PurchaseOrderVoucherMasterMax(decPurchaseOrderTypeId) == "0")
                        {
                            strVoucherNo = "0";
                            strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPurchaseOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
                        }
                    }
                    infoSuffixPrefix = spSuffisprefix.GetSuffixPrefixDetails(decPurchaseOrderTypeId, dtpDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    decPurchaseSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                    strOrderNo = strPrefix + strVoucherNo + strSuffix;
                    txtOrderNo.Text = strOrderNo;
                    txtOrderNo.ReadOnly = true;
                    txtDate.Focus();
                }
                else
                {
                    txtOrderNo.Text = string.Empty;
                    txtOrderNo.ReadOnly = false;
                    txtOrderNo.Focus();
                }
                dtpDate.Value = PublicVariables._dtCurrentDate;
                dtpDate.MinDate = PublicVariables._dtFromDate;
                dtpDate.MaxDate = PublicVariables._dtToDate;
                dtpDueDate.Value = PublicVariables._dtCurrentDate;
                this.txtDueDate.Text = this.dtpDueDate.Value.ToString("dd-MMM-yyyy");
                dtpDueDate.MinDate = PublicVariables._dtFromDate;
                dtpDueDate.MaxDate = PublicVariables._dtToDate;
                txtDueDays.Text = "0";
                CashOrPartyComboFill();
                if (!ShowProductCode())
                {
                    this.dgvPurchaseOrder.Columns["dgvtxtProductCode"].Visible = false;
                }
                if (!ShowBarcode())
                {
                    this.dgvPurchaseOrder.Columns["dgvtxtBarcode"].Visible = false;
                }
                if (spSettings.SettingsStatusCheck("ShowUnit") == "Yes")
                {
                    dgvPurchaseOrder.Columns["dgvcmbUnit"].Visible = true;
                }
                else
                {
                    dgvPurchaseOrder.Columns["dgvcmbUnit"].Visible = false;
                }
                if (PrintAfetrSave())
                {
                    cbxPrintAfterSave.Checked = true;
                }
                else
                {
                    cbxPrintAfterSave.Checked = false;
                }
                txtNarration.Text = string.Empty;

                btnSave.Text = "Save";
                btnDelete.Enabled = false;
                cbxCancel.Enabled = true;
                cbxCancel.Checked = false;
                dgvPurchaseOrder.Rows.Clear();
                txtTotalAmount.Text = string.Empty;
            }
            catch (Exception ex)
            {
                MessageBox.Show("PO28:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #5
0
 /// <summary>
 /// Fill function to updation
 /// </summary>
 /// <param name="isPending"></param>
 public void FillRegisterOrReport(bool isPending)
 {
     try
     {
         PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();
         PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
         VoucherTypeSP spVoucherType = new VoucherTypeSP();
         PurchaseOrderDetailsSP spPurchaseOrderDetails = new PurchaseOrderDetailsSP();
         btnSave.Text = "Update";
         btnDelete.Enabled = true;
         txtOrderNo.ReadOnly = true;
         infoPurchaseOrderMaster = spPurchaseOrderMaster.PurchaseOrderMasterView(decPurchaseOrderMasterId);
         txtOrderNo.Text = infoPurchaseOrderMaster.InvoiceNo;
         strVoucherNo = infoPurchaseOrderMaster.VoucherNo.ToString();
         decPurchaseSuffixPrefixId = Convert.ToDecimal(infoPurchaseOrderMaster.SuffixPrefixId);
         decPurchaseVoucherId = Convert.ToDecimal(infoPurchaseOrderMaster.VoucherTypeId);
         isAutomatic = spVoucherType.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();
         DataTable dtbl = new DataTable();
         if (isPending)
         {
             dtbl = spPurchaseOrderDetails.PurchaseOrderDetailsViewWithRemaining(decPurchaseOrderMasterId);
         }
         else
         {
             dtbl = spPurchaseOrderDetails.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 < dtbl.Rows.Count; i++)
         {
             isAmountcalc = false;
             dgvPurchaseOrder.Rows.Add();
             dgvPurchaseOrder.Rows[i].HeaderCell.Value = string.Empty;
             dgvPurchaseOrder.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = Convert.ToDecimal(dtbl.Rows[i]["purchaseOrderDetailsId"].ToString());
             decPurchaseOrderDetailId = Convert.ToDecimal(dtbl.Rows[i]["purchaseOrderDetailsId"].ToString());
             //dgvPurchaseOrder.Rows[i].Cells["dgvtxtSlNo"].Value = dtbl.Rows[i]["slNo"].ToString();
             dgvPurchaseOrder.Rows[i].Cells["dgvtxtProductId"].Value = dtbl.Rows[i]["productId"].ToString();
             dgvPurchaseOrder.Rows[i].Cells["dgvtxtProductCode"].Value = dtbl.Rows[i]["productCode"].ToString();
             dgvPurchaseOrder.Rows[i].Cells["dgvtxtProductName"].Value = dtbl.Rows[i]["productName"].ToString();
             dgvPurchaseOrder.Rows[i].Cells["dgvtxtQty"].Value = dtbl.Rows[i]["qty"].ToString();
             UnitComboFill(Convert.ToDecimal(dtbl.Rows[i]["productId"].ToString()), i, dgvPurchaseOrder.Rows[i].Cells["dgvcmbUnit"].ColumnIndex);
             dgvPurchaseOrder.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(dtbl.Rows[i]["unitId"].ToString());
             dgvPurchaseOrder.Rows[i].Cells["dgvtxtUnitConversionId"].Value = dtbl.Rows[i]["unitConversionId"].ToString();
             dgvPurchaseOrder.Rows[i].Cells["dgvtxtUnitConversionRate"].Value = dtbl.Rows[i]["conversionRate"].ToString();
             dgvPurchaseOrder.Rows[i].Cells["dgvtxtRate"].Value = dtbl.Rows[i]["rate"].ToString();
             dgvPurchaseOrder.Rows[i].Cells["dgvtxtAmount"].Value = dtbl.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);
     }
 }
Пример #6
0
        /// <summary>
        /// TO get the Due days 
        /// </summary>
        public void DueDays()
        {
            try
            {
                PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
                txtDueDays.Text = spPurchaseOrderMaster.DueDays(dtpDate.Value, dtpDueDate.Value).ToString();

            }
            catch (Exception ex)
            {
                MessageBox.Show("PO18:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #7
0
 /// <summary>
 /// On 'Print' button click to print the data
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvPurchaseOrderReport.Rows.Count > 0)
         {
             PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
             DataSet dsPurchaseOrderReport = spPurchaseOrderMaster.PurchaseOrderReportPrinting(1, strInvoiceNo, decLedgerId, decVoucherTypeId, this.dtpFromDate.Value, this.dtpToDate.Value, strStatus);
             frmReport frmReport = new frmReport();
             frmReport.MdiParent = formMDI.MDIObj;
             frmReport.PurchaseOrderReportPrinting(dsPurchaseOrderReport, txtTotalAmount.Text);
         }
         else
         {
             Messages.InformationMessage("No data found");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PORP:5" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #8
0
        /// <summary>
        /// Showing Reminder If Any one have
        /// </summary>
        public void ShowReminderIfAny()
        {
            try
            {
                string     Purchasereminder    = string.Empty;
                string     Salesreminder       = string.Empty;
                string     Personalreminder    = string.Empty;
                string     NegativeStkreminder = string.Empty;
                string     MinStkreminder      = string.Empty;
                string     MaxStkreminder      = string.Empty;
                string     ReordrStkreminder   = string.Empty;
                string     ShortExpiryReminder = string.Empty;
                DataTable  dtbl       = new DataTable();
                ReminderSP SpReminder = new ReminderSP();
                if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmOverduePurchaseOrder", "View"))
                {
                    PurchaseOrderMasterSP SpPurchaseOrderMaster = new PurchaseOrderMasterSP();
                    dtbl = SpPurchaseOrderMaster.PurchaseOrderOverDueReminder(PublicVariables._dtFromDate, PublicVariables._dtToDate, "Due", PublicVariables._dtCurrentDate, "All");
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                        {
                            Purchasereminder = Purchasereminder + "1 Overdue purchase order\n\n";
                        }
                        else
                        {
                            Purchasereminder = Purchasereminder + dtbl.Rows.Count + " Overdue purchase orders\n\n";
                        }
                    }
                }
                if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmOverdueSalesOrder", "View"))
                {
                    SalesOrderMasterSP SpSalesOrderMaster = new SalesOrderMasterSP();
                    dtbl = SpSalesOrderMaster.SalesOrderOverDueReminder(PublicVariables._dtFromDate, PublicVariables._dtToDate, "Due", PublicVariables._dtCurrentDate, "All");
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                        {
                            Salesreminder = Salesreminder + "1 Overdue sales order\n\n";
                        }
                        else
                        {
                            Salesreminder = Salesreminder + dtbl.Rows.Count + " Overdue sales orders\n\n";
                        }
                    }
                }
                if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmPersonalReminder", "Delete") ||
                    CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmPersonalReminder", "Update") ||
                    CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmPersonalReminder", "Save"))
                {
                    string FromDate = Convert.ToString(PublicVariables._dtCurrentDate);
                    string ToDate   = Convert.ToString(PublicVariables._dtCurrentDate);
                    dtbl = SpReminder.ReminderSearch(FromDate, ToDate);
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                        {
                            Personalreminder = Personalreminder + "1 personal reminder \n\n";
                        }
                        else
                        {
                            Personalreminder = Personalreminder + dtbl.Rows.Count + " Personal reminders\n\n";
                        }
                    }
                }
                if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmShortExpiry", "View"))
                {
                    dtbl = SpReminder.ShortExpiryReminder(0, 0, 0, 0, 0, 0, 0, 0);
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                        {
                            ShortExpiryReminder = ShortExpiryReminder + "1 Product batch is going to expire";
                        }
                        else
                        {
                            ShortExpiryReminder = ShortExpiryReminder + dtbl.Rows.Count + " Product batches going to expire";
                        }
                    }
                }
                //frmStock
                if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmStock", "View"))
                {
                    dtbl = SpReminder.StockSearch(0, 0, 0, 0, 0, 0, 0, 0, "Negative Stock");
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                        {
                            NegativeStkreminder = NegativeStkreminder + "1 Negative stock product \n\n";
                        }
                        else
                        {
                            NegativeStkreminder = NegativeStkreminder + dtbl.Rows.Count + " Negative stock products\n\n";
                        }
                    }

                    dtbl = SpReminder.StockSearch(0, 0, 0, 0, 0, 0, 0, 0, "Minimum Level");
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                        {
                            MinStkreminder = MinStkreminder + "1 Minimum stock product \n\n";
                        }
                        else
                        {
                            MinStkreminder = MinStkreminder + dtbl.Rows.Count + "  Minimum stock products \n\n";
                        }
                    }

                    dtbl = SpReminder.StockSearch(0, 0, 0, 0, 0, 0, 0, 0, "Maximum Level");
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                        {
                            MaxStkreminder = MaxStkreminder + "1 Maximum stock product \n\n";
                        }
                        else
                        {
                            MaxStkreminder = MaxStkreminder + dtbl.Rows.Count + "  Maximum stock products \n\n";
                        }
                    }

                    dtbl = SpReminder.StockSearch(0, 0, 0, 0, 0, 0, 0, 0, "Reorder Level");
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                        {
                            ReordrStkreminder = ReordrStkreminder + "1 Reorder Level product \n\n";
                        }
                        else
                        {
                            ReordrStkreminder = ReordrStkreminder + dtbl.Rows.Count + "  Reorder Level products \n\n";
                        }
                    }
                }
                if (Salesreminder.Trim() != string.Empty || Purchasereminder.Trim() != string.Empty || Personalreminder.Trim() != string.Empty || NegativeStkreminder.Trim() != string.Empty || MinStkreminder.Trim() != string.Empty || MaxStkreminder.Trim() != string.Empty || ReordrStkreminder.Trim() != string.Empty)
                {
                    frmReminderPopUp frmReminder = new frmReminderPopUp();
                    frmReminderPopUp isOpen      = Application.OpenForms["frmReminderPopUp"] as frmReminderPopUp;
                    if (isOpen == null)
                    {
                        frmReminder.WindowState = FormWindowState.Normal;
                        frmReminder.MdiParent   = formMDI.MDIObj;
                        frmReminder.BringToFront();
                        frmReminder.ChangeLabel(Salesreminder, Purchasereminder, Personalreminder, ShortExpiryReminder, NegativeStkreminder, MinStkreminder, MaxStkreminder, ReordrStkreminder);
                    }
                }
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "CCD 13: " + ex.Message;
            }
        }
Пример #9
0
 /// <summary>
 /// Function to fill the details while calling from register or report
 /// </summary>
 public void FillRegisterOrReport()
 {
     PurchaseMasterInfo infoPurchaseMaster = new PurchaseMasterInfo();
     PurchaseMasterSP spPurchaseMaster = new PurchaseMasterSP();
     PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();
     PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
     MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo();
     MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP();
     VoucherTypeSP spVoucherType = new VoucherTypeSP();
     VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
     AccountLedgerSP spAccountLedger = new AccountLedgerSP();
     bool isPartyBalanceRef = false;
     try
     {
         isEditFill = true;
         btnSave.Text = "Update";
         btnDelete.Enabled = true;
         txtVoucherNo.ReadOnly = true;
         infoPurchaseMaster = spPurchaseMaster.PurchaseMasterView(decPurchaseMasterId);
         strVoucherNo = infoPurchaseMaster.VoucherNo;
         decPurchaseInvoiceVoucherTypeId = infoPurchaseMaster.VoucherTypeId;
         decPurchaseInvoiceSuffixPrefixId = infoPurchaseMaster.SuffixPrefixId;
         isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decPurchaseInvoiceVoucherTypeId);
         infoVoucherType = spVoucherType.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 = spPurchaseOrderMaster.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 = spMaterialReceiptMaster.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 = spAccountLedger.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);
     }
 }
Пример #10
0
 /// <summary>
 /// Save Function
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();
         PurchaseOrderDetailsSP spPurchaseOrderDetails = new PurchaseOrderDetailsSP();
         PurchaseOrderDetailsInfo infoPurchaseOrderDetails = new PurchaseOrderDetailsInfo();
         PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
         ProductInfo infoProduct = new ProductInfo();
         ProductSP spProduct = new ProductSP();
         SettingsSP spSettings = new SettingsSP();
         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 = spPurchaseOrderMaster.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(spPurchaseOrderMaster.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 = spProduct.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;
             spPurchaseOrderDetails.PurchaseOrderDetailsAdd(infoPurchaseOrderDetails);
         }
         Messages.SavedMessage();
         if (cbxPrintAfterSave.Checked)
         {
             if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
             {
                 PrintForDotMatrix(decPurchaseOrderMasterIdentity);
             }
             else
             {
                 Print(decPurchaseOrderMasterIdentity);
             }
         }
         Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show("PO35:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #11
0
 /// <summary>
 /// Edit function
 /// </summary>
 public void EditFunction()
 {
     try
     {
         PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();
         PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
         SettingsSP spSettings = new SettingsSP();
         infoPurchaseOrderMaster.PurchaseOrderMasterId = decPurchaseOrderMasterId;
         if (CheckCancelStatus(decPurchaseOrderMasterId))
         {
             //isCheck = true;
             //cbxCancel.Checked = true;
             //cbxCancel.Enabled = false;
             //isCheck = false;
             infoPurchaseOrderMaster.Cancelled = true;
         }
         else
         {
             //isCheck = true;
             //cbxCancel.Enabled = true;
             ////  cbxCancel.Checked = false;
             //isCheck = false;
             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;
         spPurchaseOrderMaster.PurchaseOrderMasterEdit(infoPurchaseOrderMaster);
         RemovePurchaseOrderDetails();
         EditPurchaseOrderDetails();
         Messages.UpdatedMessage();
         if (frmPurchaseOrderRegisterObj != null)
         {
             if (cbxPrintAfterSave.Checked)
             {
                 if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decPurchaseOrderMasterId);
                 }
                 else
                 {
                     Print(decPurchaseOrderMasterId);
                 }
             }
             this.Close();
             frmPurchaseOrderRegisterObj.GridFill();
         }
         if (frmPurchaseOrderReportObj != null)
         {
             if (cbxPrintAfterSave.Checked)
             {
                 if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decPurchaseOrderMasterId);
                 }
                 else
                 {
                     Print(decPurchaseOrderMasterId);
                 }
             }
             this.Close();
             frmPurchaseOrderReportObj.GridFill();
         }
         if (frmDayBookObj != null)
         {
             if (cbxPrintAfterSave.Checked)
             {
                 if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decPurchaseOrderMasterId);
                 }
                 else
                 {
                     Print(decPurchaseOrderMasterId);
                 }
             }
             this.Close();
         }
         if (objVoucherSearch != null)
         {
             if (cbxPrintAfterSave.Checked)
             {
                 if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decPurchaseOrderMasterId);
                 }
                 else
                 {
                     Print(decPurchaseOrderMasterId);
                 }
             }
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PO34:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #12
0
 /// <summary>
 /// Save or edit function , to check invalid entries
 /// </summary>
 public void SaveOrEdit()
 {
     try
     {
         PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
         dgvPurchaseOrder.ClearSelection();
         int inRow = dgvPurchaseOrder.RowCount;
         if (txtOrderNo.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter voucher number");
             txtOrderNo.Focus();
         }
         else if (spPurchaseOrderMaster.PurchaseOrderNumberCheckExistence(txtOrderNo.Text.Trim(), 0, decPurchaseOrderTypeId) == true && btnSave.Text == "Save")
         {
             Messages.InformationMessage("Order number already exist");
             txtOrderNo.Focus();
         }
         else if (txtDate.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Select a date in between financial year");
             txtDate.Focus();
         }
         else if (cmbCashOrParty.SelectedValue == null)
         {
             Messages.InformationMessage("Select Cash/Party");
             cmbCashOrParty.Focus();
         }
         else if (txtDueDate.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Select due date");
             txtDueDate.Focus();
         }
         else if (txtDueDays.Text.Contains("-") && txtDueDays.Text != string.Empty)
         {
             Messages.InformationMessage("Due date should not be greater than order date");
             txtDueDate.Focus();
         }
         else if (inRow - 1 == 0)
         {
             Messages.InformationMessage("Can't save purchase order without atleast one product with complete details");
         }
         else
         {
             if (RemoveIncompleteRowsFromGrid())
             {
                 if (dgvPurchaseOrder.Rows[0].Cells["dgvtxtProductName"].Value == null && dgvPurchaseOrder.Rows[0].Cells["dgvtxtProductCode"].Value == null)
                 {
                     MessageBox.Show("Can't save purchase order without atleast one product with complete details", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     dgvPurchaseOrder.ClearSelection();
                     dgvPurchaseOrder.Focus();
                 }
                 else
                 {
                     if (btnSave.Text == "Save")
                     {
                         if (dgvPurchaseOrder.Rows[0].Cells["dgvtxtProductName"].Value == null)
                         {
                             MessageBox.Show("Can't save purchase order without atleast one product with complete details", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                             dgvPurchaseOrder.ClearSelection();
                             dgvPurchaseOrder.Focus();
                         }
                         else
                         {
                             if (PublicVariables.isMessageAdd)
                             {
                                 if (Messages.SaveMessage())
                                 {
                                     SaveFunction();
                                 }
                             }
                             else
                             {
                                 SaveFunction();
                             }
                         }
                     }
                     if (btnSave.Text == "Update")
                     {
                         if (dgvPurchaseOrder.Rows[0].Cells["dgvtxtProductName"].Value == null)
                         {
                             MessageBox.Show("Can't Edit purchase order without atleast one product with complete details", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                             dgvPurchaseOrder.ClearSelection();
                             dgvPurchaseOrder.Focus();
                         }
                         else
                         {
                             if (PublicVariables.isMessageEdit)
                             {
                                 if (Messages.UpdateMessage())
                                 {
                                     EditFunction();
                                 }
                             }
                             else
                             {
                                 EditFunction();
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PO32:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #13
0
        /// <summary>
        /// Function to fill the fields for edit or delete
        /// </summary>
        public void FillRegisterOrReport()
        {
            MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo();
            MaterialReceiptDetailsInfo infoMaterialReceiptDetails = new MaterialReceiptDetailsInfo();
            VoucherTypeSP spVoucherType = new VoucherTypeSP();
            MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP();
            MaterialReceiptDetailsSP spMaterialReceiptDetails = new MaterialReceiptDetailsSP();
            PurchaseOrderMasterSP SPPurchaseOrderMaster = new PurchaseOrderMasterSP();
            try
            {
                PurchaseOrderMasterSP spPurchaseOrder = new PurchaseOrderMasterSP();
                PurchaseOrderMasterInfo infoPurchaseOrder = new PurchaseOrderMasterInfo();
                decimal decTotal = 0;
                decimal decStatus = spMaterialReceiptMaster.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 = spMaterialReceiptMaster.MaterialReceiptMasterView(decMaterialReceiptMasterId);
                txtReceiptNo.Text = infoMaterialReceiptMaster.InvoiceNo;
                strVoucherNo = infoMaterialReceiptMaster.VoucherNo.ToString();
                decMaterialReceiptSuffixPrefixId = Convert.ToDecimal(infoMaterialReceiptMaster.SuffixPrefixId);
                decMaterialReceiptVoucherTypeId = Convert.ToDecimal(infoMaterialReceiptMaster.VoucherTypeId);
                isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decMaterialReceiptVoucherTypeId);
                decMaterialReceiptTypeId = decMaterialReceiptVoucherTypeId;
                txtDate.Text = infoMaterialReceiptMaster.Date.ToString("dd-MMM-yyyy");
                cmbCashOrParty.SelectedValue = infoMaterialReceiptMaster.LedgerId;
                if (infoMaterialReceiptMaster.OrderMasterId != 0)
                {
                    infoPurchaseOrder = SPPurchaseOrderMaster.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);
                DataTable dtbl = new DataTable();
                dtbl = spMaterialReceiptDetails.MaterialReceiptDetailsViewByMasterId(decMaterialReceiptMasterId);
                dgvProduct.Rows.Clear();
                for (int i = 0; i < dtbl.Rows.Count; i++)
                {
                    isAmountcalc = false;
                    isValueChange = false;
                    dgvProduct.Rows.Add();
                    dgvProduct.Rows[i].Cells["dgvtxtMaterialReceiptdetailsId"].Value = Convert.ToDecimal(dtbl.Rows[i]["materialReceiptDetailsId"].ToString());
                    decMaterialReceiptDetailId = Convert.ToDecimal(dtbl.Rows[i]["materialReceiptDetailsId"].ToString());
                    dgvProduct.Rows[i].Cells["dgvtxtSlNo"].Value = dtbl.Rows[i]["slno"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtProductCode"].Value = dtbl.Rows[i]["productCode"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtProductName"].Value = dtbl.Rows[i]["productName"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtQty"].Value = dtbl.Rows[i]["qty"].ToString();
                    dgvProduct.Rows[i].Cells["productId"].Value = dtbl.Rows[i]["productId"].ToString();
                    decimal decProductId = Convert.ToDecimal(dtbl.Rows[i]["productId"].ToString());
                    UnitComboFill(decProductId, i, dgvProduct.Rows[i].Cells["dgvcmbUnit"].ColumnIndex);
                    dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(dtbl.Rows[i]["unitId"].ToString());
                    DGVGodownComboFill();
                    dgvProduct.Rows[i].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(dtbl.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(dtbl.Rows[i]["orderDetailsId"].ToString()) == 0)
                    {
                        dgvProduct.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = 0;
                    }
                    else
                    {
                        dgvProduct.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = Convert.ToDecimal(dtbl.Rows[i]["orderDetailsId"].ToString());

                    }
                    dgvProduct.Rows[i].Cells["dgvCmbRack"].Value = Convert.ToDecimal(dtbl.Rows[i]["rackId"].ToString());
                    BatchComboFill(decProductId, i, Convert.ToInt32(dgvProduct.Rows[i].Cells["dgvcmbBatch"].ColumnIndex));
                    dgvProduct.Rows[i].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(dtbl.Rows[i]["batchId"].ToString());
                    dgvProduct.Rows[i].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(dtbl.Rows[i]["unitConversionId"].ToString());
                    dgvProduct.Rows[i].Cells["dgvtxtBarcode"].Value = dtbl.Rows[i]["barcode"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = dtbl.Rows[i]["rate"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtAmount"].Value = dtbl.Rows[i]["amount"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtvouchertypeId"].Value = Convert.ToDecimal(dtbl.Rows[i]["voucherTypeId"].ToString());
                    dgvProduct.Rows[i].Cells["dgvtxtvoucherNo"].Value = dtbl.Rows[i]["voucherNo"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtinvoiceNo"].Value = dtbl.Rows[i]["invoiceNo"].ToString();
                    decAgainstVoucherTypeId = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtvouchertypeId"].Value.ToString());
                    strAgainstVoucherNo = dgvProduct.Rows[i].Cells["dgvtxtvoucherNo"].Value.ToString();
                    UnitConvertionSP SpUnitConvertion = new UnitConvertionSP();
                    DataTable dtblUnitByProduct = new DataTable();
                    dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(decProductId.ToString());
                    foreach (DataRow drUnitByProduct in dtblUnitByProduct.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 = spMaterialReceiptMaster.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);
            }
        }
Пример #14
0
 /// <summary>
 /// On cellLeave of dgvProduct
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvProduct_CellLeave(object sender, DataGridViewCellEventArgs e)
 {
     BatchSP spbatch = new BatchSP();
     PurchaseOrderMasterSP SPPurchaseOrderMaster = new PurchaseOrderMasterSP();
     StockPostingSP spStockPosting = new StockPostingSP();
     try
     {
         if (isValueChange)
         {
             string strBarcode = string.Empty;
             string strProductCode = string.Empty;
             if (e.RowIndex > -1 && e.ColumnIndex > -1)
             {
                 CheckInvalidEntries(e);
                 if (e.ColumnIndex == dgvProduct.Columns["dgvcmbBatch"].Index)
                 {
                     if (dgvProduct.Rows[e.RowIndex].Cells["productId"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["productId"].Value.ToString() != string.Empty)
                     {
                         if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty)
                         {
                             if (Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value) != string.Empty &&
                                Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value) != "0")
                             {
                                 decBatchId = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value);
                                 strProductCode = dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString();
                                 strBarcode = spbatch.ProductBatchBarcodeViewByBatchId(decBatchId);
                                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = strBarcode;
                                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value = strProductCode;
                             }
                         }
                     }
                 }
                 else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbUnit")
                 {
                     if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() != string.Empty)
                     {
                         UnitConvertionSP SpUnitConvertion = new UnitConvertionSP();
                         DataTable dtblUnitByProduct = new DataTable();
                         dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["productId"].Value.ToString());
                         foreach (DataRow drUnitByProduct in dtblUnitByProduct.Rows)
                         {
                             if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                             {
                                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());
                                 if (isDoAfterGridFill)
                                 {
                                     decimal decNewConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString());
                                     decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate;
                                     dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decNewRate, 2);
                                     NewAmountCalculation("dgvtxtQty", e.RowIndex);
                                     CalculateTotalAmount();
                                 }
                             }
                         }
                         CheckInvalidEntries(e);
                     }
                 }
                 else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbGodown")
                 {
                     if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbGodown"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbGodown"].Value.ToString() != string.Empty)
                     {
                         decGodownId = Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvcmbGodown"].Value);
                         RackComboFill(decGodownId, e.RowIndex, dgvProduct.Rows[e.RowIndex].Cells["dgvCmbRack"].ColumnIndex);
                         DataTable dtbl = new DataTable();
                         RackSP spRack = new RackSP();
                         dtbl = spRack.RackNamesCorrespondingToGodownId(decGodownId);
                         dgvProduct.Rows[e.RowIndex].Cells["dgvCmbRack"].Value = Convert.ToDecimal(dtbl.Rows[0]["rackId"].ToString());
                     }
                     CheckInvalidEntries(e);
                 }
                 else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvCmbCurrency" && isAmountcalc)
                 {
                     ExchangeRateSP spExchangeRate = new ExchangeRateSP();
                     if (dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value != null && Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value) != string.Empty)
                     {
                         dgvProduct.Rows[e.RowIndex].Cells["dgvtxtExchangeRate"].Value = spExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value)));
                     }
                     else
                     {
                         dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value = SPPurchaseOrderMaster.ExchangeRateIdByCurrencyId(PublicVariables._decCurrencyId);
                         dgvProduct.Rows[e.RowIndex].Cells["dgvtxtExchangeRate"].Value = spExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(Convert.ToString(dgvProduct.Rows[e.RowIndex].Cells["dgvCmbCurrency"].Value)));
                     }
                     CheckInvalidEntries(e);
                 }
                 //----------while changing Qty,corresponding change in amount--------
                 else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtQty" && isAmountcalc)
                 {
                     if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value != null)
                     {
                         if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductName"].Value.ToString() != string.Empty)
                         {
                             NewAmountCalculation("dgvtxtQty", e.RowIndex);
                             CalculateTotalAmount();
                         }
                     }
                     CheckInvalidEntries(e);
                 }
                 //---------------while changing Qty,corresponding change in amount----
                 else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtRate" && isAmountcalc)
                 {
                     NewAmountCalculation("dgvtxtRate", e.RowIndex);
                     CalculateTotalAmount();
                     CheckInvalidEntries(e);
                 }
                 //----while changing amount ,corresponding chnage in total amount-------
                 else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtAmount" && isAmountcalc)
                 {
                     if (cmbcurrency.Text != string.Empty)
                     {
                         CalculateTotalAmount();
                     }
                 }
                 //}
             }
         }
         CheckInvalidEntries(e);
     }
     catch (Exception ex)
     {
         MessageBox.Show("MR72:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #15
0
 /// <summary>
 /// Function to edit purchase invoice
 /// </summary>
 public void Edit()
 {
     PurchaseMasterInfo infoPurchaseMaster = new PurchaseMasterInfo();
     PurchaseMasterSP spPurchaseMaster = new PurchaseMasterSP();
     PurchaseDetailsInfo infoPurchaseDetails = new PurchaseDetailsInfo();
     PurchaseDetailsSP spPurchaseDetails = new PurchaseDetailsSP();
     MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo();
     MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP();
     PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();
     PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
     StockPostingInfo infoStockPosting = new StockPostingInfo();
     StockPostingSP spStockPosting = new StockPostingSP();
     LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
     LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
     PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo();
     PartyBalanceSP spPartyBalance = new PartyBalanceSP();
     AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo();
     AdditionalCostSP spAdditionalCost = new AdditionalCostSP();
     PurchaseBillTaxInfo infoPurchaseBillTax = new PurchaseBillTaxInfo();
     PurchaseBillTaxSP spPurchaseBillTax = new PurchaseBillTaxSP();
     AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo();
     AccountLedgerSP spAccountLedger = new AccountLedgerSP();
     UnitConvertionSP spUnitConvertion = new UnitConvertionSP();
     ExchangeRateSP spExchangeRate = new ExchangeRateSP();
     /*---------------------------------Deleting previous stock posting, Ledger posting, partybalanceposting---------------------------------------*/
     infoPurchaseMaster = spPurchaseMaster.PurchaseMasterView(decPurchaseMasterId);
     if (infoPurchaseMaster.MaterialReceiptMasterId != 0)
     {
         infoMaterialReceiptMaster = spMaterialReceiptMaster.MaterialReceiptMasterView(infoPurchaseMaster.MaterialReceiptMasterId);
         spStockPosting.StockPostingDeleteForSalesInvoiceAgainstDeliveryNote
             (infoPurchaseMaster.VoucherTypeId, infoPurchaseMaster.VoucherNo,
             infoMaterialReceiptMaster.VoucherNo, infoMaterialReceiptMaster.VoucherTypeId);
     }
     spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType
             (0, "NA", infoPurchaseMaster.VoucherNo, infoPurchaseMaster.VoucherTypeId);
     try
     {
         RemoveDelete();
         /*-----------------------------------------Purchase Master Edit----------------------------------------------------*/
         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;
         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);
         infoPurchaseMaster.PurchaseMasterId = decPurchaseMasterId;
         spPurchaseMaster.PurchaseMasterEdit(infoPurchaseMaster);
         infoPurchaseOrderMaster = spPurchaseOrderMaster.PurchaseOrderMasterView(infoPurchaseMaster.PurchaseOrderMasterId);
         infoMaterialReceiptMaster = spMaterialReceiptMaster.MaterialReceiptMasterView(infoPurchaseMaster.MaterialReceiptMasterId);
         spLedgerPosting.LedgerPostDelete(strVoucherNo, decPurchaseInvoiceVoucherTypeId);
         spAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPurchaseInvoiceVoucherTypeId);
         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);
                     if (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value != null)
                     {
                         if (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString() == "0" || dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString() == string.Empty)
                         {
                             spPurchaseDetails.PurchaseDetailsAdd(infoPurchaseDetails);
                         }
                         else
                         {
                             infoPurchaseDetails.PurchaseDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString());
                             spPurchaseDetails.PurchaseDetailsEdit(infoPurchaseDetails);
                         }
                     }
                     else
                     {
                         spPurchaseDetails.PurchaseDetailsAdd(infoPurchaseDetails);
                     }
                     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);
                     spStockPosting.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);
                         spStockPosting.StockPostingAdd(infoStockPosting);
                     }
                 }
             }
         }
         /*-----------------------------------------Ledger Posting----------------------------------------------------*/
         infoLedgerPosting.Credit = Convert.ToDecimal(txtGrandTotal.Text) * spExchangeRate.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;
         spLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
         decimal DecBillDiscount = Convert.ToDecimal(txtBillDiscount.Text.Trim().ToString());
         if (DecBillDiscount > 0)
         {
             infoLedgerPosting.Credit = DecBillDiscount * spExchangeRate.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 ledger
             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;
             spLedgerPosting.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;
         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;
         spLedgerPosting.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;
                             if (dgvrow.Cells["dgvtxtAdditionalCostId"].Value != null)
                             {
                                 if (dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString() != string.Empty && dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString() != string.Empty)
                                 {
                                     infoAdditionalCost.AdditionalCostId = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString());
                                     spAdditionalCost.AdditionalCostEdit(infoAdditionalCost);
                                 }
                                 else
                                 {
                                     spAdditionalCost.AdditionalCostAdd(infoAdditionalCost);
                                 }
                             }
                             else
                             {
                                 spAdditionalCost.AdditionalCostAdd(infoAdditionalCost);
                             }
                             /*-----------------------------------------Additional Cost Ledger Posting----------------------------------------------------*/
                             infoLedgerPosting.Credit = 0;
                             infoLedgerPosting.Debit = infoAdditionalCost.Debit * spExchangeRate.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;
                             spLedgerPosting.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;
                         if (dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value != null)
                         {
                             if (dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString() != string.Empty && dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString() != "0")
                             {
                                 infoPurchaseBillTax.PurchaseBillTaxId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString());
                                 spPurchaseBillTax.PurchaseBillTaxEdit(infoPurchaseBillTax);
                             }
                             else
                             {
                                 spPurchaseBillTax.PurchaseBillTaxAdd(infoPurchaseBillTax);
                             }
                         }
                         else
                         {
                             spPurchaseBillTax.PurchaseBillTaxAdd(infoPurchaseBillTax);
                         }
                         /*-----------------------------------------Tax Ledger Posting----------------------------------------------------*/
                         infoLedgerPosting.Credit = 0;
                         infoLedgerPosting.Debit = infoPurchaseBillTax.TaxAmount * spExchangeRate.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;
                         spLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                     }
                 }
             }
         }
         /*-----------------------------------------PartyBalance Posting----------------------------------------------------*/
         infoAccountLedger = spAccountLedger.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;
             spPartyBalance.PartyBalanceAdd(infoPartyBalance);
         }
         Messages.UpdatedMessage();
         if (cbxPrintAfterSave.Checked)
         {
             if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
             {
                 PrintForDotMatrix(decPurchaseMasterId);
             }
             else
             {
                 Print(decPurchaseMasterId);
             }
         }
         Clear();
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("PI39:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #16
0
 public void Delete()
 {
     PurchaseMasterSP spPurchaseMaster = new PurchaseMasterSP();
     PurchaseDetailsSP spPurchaseDetails = new PurchaseDetailsSP();
     PurchaseBillTaxSP spPurchaseBillTax = new PurchaseBillTaxSP();
     AdditionalCostSP spAdditionalCost = new AdditionalCostSP();
     AccountLedgerSP spAccountLedger = new AccountLedgerSP();
     StockPostingSP spStockPosting = new StockPostingSP();
     LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
     PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
     MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP();
     PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();
     MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo();
     PurchaseMasterInfo infoPurchaseMaster = new PurchaseMasterInfo();
     /*---------------------------------Deleting previous stock posting, Ledger posting, partybalanceposting---------------------------------------*/
     infoPurchaseMaster = spPurchaseMaster.PurchaseMasterView(decPurchaseMasterId);
     if (infoPurchaseMaster.MaterialReceiptMasterId != 0)
     {
         infoMaterialReceiptMaster = spMaterialReceiptMaster.MaterialReceiptMasterView(infoPurchaseMaster.MaterialReceiptMasterId);
         spStockPosting.StockPostingDeleteForSalesInvoiceAgainstDeliveryNote
             (infoPurchaseMaster.VoucherTypeId, infoPurchaseMaster.VoucherNo,
             infoMaterialReceiptMaster.VoucherNo, infoMaterialReceiptMaster.VoucherTypeId);
     }
     spStockPosting.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 = spPurchaseMaster.PurchaseMasterReferenceCheck(decPurchaseMasterId, decPurchaseDetailsId);
                     if (inRef > 0 && !isRef)
                     {
                         isRef = true;
                     }
                 }
             }
         }
         if (!isRef)
         {
             isRef = spAccountLedger.PartyBalanceAgainstReferenceCheck(strVoucherNo, decPurchaseInvoiceVoucherTypeId);
             if (!isRef)
             {
                 spPurchaseMaster.PurchaseMasterDelete(decPurchaseMasterId);
                 spPurchaseDetails.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());
                             spAdditionalCost.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());
                                 spPurchaseBillTax.PurchaseBillTaxDelete(decPurchaseBillTaxId);
                             }
                         }
                     }
                 }
                 if (cmbPurchaseMode.Text == "Against PurchaseOrder")
                 {
                     decPurchaseOrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
                     infoPurchaseOrderMaster = spPurchaseOrderMaster.PurchaseOrderMasterView(decPurchaseOrderMasterId);
                 }
                 else if (cmbPurchaseMode.Text == "Against MaterialReceipt")
                 {
                     decMaterialReceiptMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
                     infoMaterialReceiptMaster = spMaterialReceiptMaster.MaterialReceiptMasterView(decMaterialReceiptMasterId);
                 }
                 spLedgerPosting.LedgerPostDelete(strVoucherNo, decPurchaseInvoiceVoucherTypeId);
                 if (infoPurchaseOrderMaster.PurchaseOrderMasterId != 0)
                 {
                     spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType
                         (decPurchaseInvoiceVoucherTypeId, strVoucherNo,
                         infoPurchaseOrderMaster.VoucherNo, infoPurchaseOrderMaster.VoucherTypeId);
                 }
                 else if (infoMaterialReceiptMaster.MaterialReceiptMasterId != 0)
                 {
                     spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType
                         (decPurchaseInvoiceVoucherTypeId, strVoucherNo,
                         infoMaterialReceiptMaster.VoucherNo, infoMaterialReceiptMaster.VoucherTypeId);
                 }
                 spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType
                         (0, "NA", strVoucherNo, decPurchaseInvoiceVoucherTypeId);
                 spAccountLedger.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);
     }
 }
Пример #17
0
 /// <summary>
 /// To checking the cancelled status and checking to other forms opend or not
 /// </summary>
 public void PurchaseOrderCancel()
 {
     try
     {
         PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
         spPurchaseOrderMaster.PurchaseOrderCancel(decPurchaseOrderMasterId);
         Messages.InformationMessage("Cancelled successfully");
         if (frmPurchaseOrderRegisterObj != null)
         {
             this.Close();
             frmPurchaseOrderRegisterObj.GridFill();
         }
         if (frmPurchaseOrderReportObj != null)
         {
             this.Close();
             frmPurchaseOrderReportObj.GridFill();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PO12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #18
0
        /// <summary>
        /// Function to fill gridview
        /// </summary>
        public void GridFill()
        {
            try
            {
                PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
                if (txtVoucherNo.Text.Trim() == string.Empty)
                {
                    strInvoiceNo = "-1";
                }
                else
                {
                    strInvoiceNo = txtVoucherNo.Text;
                }
                if (cmbCashOrParty.SelectedIndex == 0 || cmbCashOrParty.SelectedIndex == -1)
                {
                    decLedgerId = -1;
                }
                else
                {
                    decLedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
                }
                if (cmbVoucherType.SelectedIndex == 0 || cmbVoucherType.SelectedIndex == -1)
                {
                    decVoucherTypeId = -1;
                }
                else
                {
                    decVoucherTypeId = Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString());
                }

                if (cmbStatus.SelectedIndex == 0 || cmbStatus.SelectedIndex == -1)
                {
                    strStatus = "All";
                }
                else
                {
                    strStatus = cmbStatus.SelectedItem.ToString();
                }
                DateTime FromDate = this.dtpFromDate.Value;
                DateTime ToDate   = this.dtpToDate.Value;
                dtblPurchaseOrderRegister = spPurchaseOrderMaster.PurchaseOrdeReportViewAll(strInvoiceNo, decLedgerId, decVoucherTypeId, FromDate, ToDate, strStatus);

                if (dtblPurchaseOrderRegister.Rows.Count > 0)
                {
                    decimal decTotal = 0;
                    for (int i = 0; i < dtblPurchaseOrderRegister.Rows.Count; i++)
                    {
                        if (dtblPurchaseOrderRegister.Rows[i]["totalAmount"].ToString() != null)
                        {
                            decTotal = decTotal + Convert.ToDecimal(dtblPurchaseOrderRegister.Rows[i]["totalAmount"].ToString());
                        }
                    }
                    decTotal            = Math.Round(decTotal, 2);
                    txtTotalAmount.Text = decTotal.ToString();
                }
                else
                {
                    txtTotalAmount.Text = "0.00";
                }
                dgvPurchaseOrderReport.DataSource = dtblPurchaseOrderRegister;
                if (dgvPurchaseOrderReport.Columns.Count > 0)
                {
                    dgvPurchaseOrderReport.Columns["dgvtxtTotalAmount"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                }
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "PORP4:" + ex.Message;
            }
        }
Пример #19
0
 /// <summary>
 /// Check CancelStatus
 /// </summary>
 /// <param name="decId"></param>
 /// <returns></returns>
 public bool CheckCancelStatus(decimal decId)
 {
     bool isCancelled = false;
     try
     {
         PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
         isCancelled = spPurchaseOrderMaster.PurchaseOrderCancelCheckStatus(decId);
     }
     catch (Exception ex)
     {
         MessageBox.Show("PO13:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return isCancelled;
 }
Пример #20
0
 /// <summary>
 /// Print function
 /// </summary>
 /// <param name="decMasterId"></param>
 public void Print(decimal decMasterId)
 {
     try
     {
         PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
         DataSet dsPurchaseOrder = spPurchaseOrderMaster.PurchaseOrderPrinting(decMasterId);
         frmReport frmReport = new frmReport();
         frmReport.MdiParent = formMDI.MDIObj;
         frmReport.PurchaseOrderPrinting(dsPurchaseOrder);
     }
     catch (Exception ex)
     {
         MessageBox.Show("PO14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #21
0
 /// <summary>
 /// Delete function
 /// </summary>
 public void Delete()
 {
     StockPostingSP spStockPosting = new StockPostingSP();
     PurchaseOrderDetailsSP spPurchaseOrderDetails = new PurchaseOrderDetailsSP();
     PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
     try
     {
         decimal decResult1 = 0;
         for (int inI = 0; inI < dgvPurchaseOrder.Rows.Count - 1; inI++)
         {
             if (Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtPurchaseOrderDetailsId"].Value) != 0)
             {
                 decResult1 = spPurchaseOrderDetails.PurchaseOrderDetailsDelete(Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtPurchaseOrderDetailsId"].Value));
             }
         }
         decimal decResult2 = spPurchaseOrderMaster.PurchaseOrderMasterDelete(decPurchaseOrderMasterId);
         if (decResult1 > 0 && decResult2 > 0)
         {
             Messages.DeletedMessage();
             if (frmPurchaseOrderRegisterObj != null)
             {
                 this.Close();
                 frmPurchaseOrderRegisterObj.GridFill();
             }
             if (frmPurchaseOrderReportObj != null)
             {
                 this.Close();
                 frmPurchaseOrderReportObj.GridFill();
             }
             if (objVoucherSearch != null)
             {
                 this.Close();
                 objVoucherSearch.GridFill();
             }
             if (frmDayBookObj != null)
             {
                 this.Close();
             }
         }
         else
         {
             Messages.ReferenceExistsMessage();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PO16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #22
0
        /// <summary>
        /// Showing Reminder If Any one have
        /// </summary>
        public void ShowReminderIfAny()
        {
            try
            {
                string Purchasereminder = string.Empty;
                string Salesreminder = string.Empty;
                string Personalreminder = string.Empty;
                string NegativeStkreminder = string.Empty;
                string MinStkreminder = string.Empty;
                string MaxStkreminder = string.Empty;
                string ReordrStkreminder = string.Empty;
                string ShortExpiryReminder = string.Empty;
                DataTable dtbl = new DataTable();
                ReminderSP SpReminder = new ReminderSP();
                if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmOverduePurchaseOrder", "View"))
                {
                    PurchaseOrderMasterSP SpPurchaseOrderMaster = new PurchaseOrderMasterSP();
                    dtbl = SpPurchaseOrderMaster.PurchaseOrderOverDueReminder(PublicVariables._dtFromDate, PublicVariables._dtToDate, "Due", PublicVariables._dtCurrentDate, "All");
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                            Purchasereminder = Purchasereminder + "1 Overdue purchase order\n\n";
                        else
                            Purchasereminder = Purchasereminder + dtbl.Rows.Count + " Overdue purchase orders\n\n";
                    }
                }
                if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmOverdueSalesOrder", "View"))
                {
                    SalesOrderMasterSP SpSalesOrderMaster = new SalesOrderMasterSP();
                    dtbl = SpSalesOrderMaster.SalesOrderOverDueReminder(PublicVariables._dtFromDate, PublicVariables._dtToDate, "Due", PublicVariables._dtCurrentDate, "All");
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                            Salesreminder = Salesreminder + "1 Overdue sales order\n\n";
                        else
                            Salesreminder = Salesreminder + dtbl.Rows.Count + " Overdue sales orders\n\n";
                    }
                }
                if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmPersonalReminder", "Delete") ||
                    CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmPersonalReminder", "Update") ||
                    CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmPersonalReminder", "Save"))
                {
                    string FromDate = Convert.ToString(PublicVariables._dtCurrentDate);
                    string ToDate = Convert.ToString(PublicVariables._dtCurrentDate);
                    dtbl = SpReminder.ReminderSearch(FromDate, ToDate);
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                            Personalreminder = Personalreminder + "1 personal reminder \n\n";
                        else
                            Personalreminder = Personalreminder + dtbl.Rows.Count + " Personal reminders\n\n";
                    }
                }
                if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmShortExpiry", "View"))
                {
                    dtbl = SpReminder.ShortExpiryReminder(0, 0, 0, 0, 0, 0, 0, 0);
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                            ShortExpiryReminder = ShortExpiryReminder + "1 Product batch is going to expire";
                        else
                            ShortExpiryReminder = ShortExpiryReminder + dtbl.Rows.Count + " Product batches going to expire";
                    }
                }
                //frmStock
                if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmStock", "View"))
                {
                    dtbl = SpReminder.StockSearch(0, 0, 0, 0, 0, 0, 0, 0, "Negative Stock");
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                            NegativeStkreminder = NegativeStkreminder + "1 Negative stock product \n\n";
                        else
                            NegativeStkreminder = NegativeStkreminder + dtbl.Rows.Count + " Negative stock products\n\n";
                    }

                    dtbl = SpReminder.StockSearch(0, 0, 0, 0, 0, 0, 0, 0, "Minimum Level");
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                            MinStkreminder = MinStkreminder + "1 Minimum stock product \n\n";
                        else
                            MinStkreminder = MinStkreminder + dtbl.Rows.Count + "  Minimum stock products \n\n";
                    }

                    dtbl = SpReminder.StockSearch(0, 0, 0, 0, 0, 0, 0, 0, "Maximum Level");
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                            MaxStkreminder = MaxStkreminder + "1 Maximum stock product \n\n";
                        else
                            MaxStkreminder = MaxStkreminder + dtbl.Rows.Count + "  Maximum stock products \n\n";
                    }

                    dtbl = SpReminder.StockSearch(0, 0, 0, 0, 0, 0, 0, 0, "Reorder Level");
                    if (dtbl.Rows.Count > 0)
                    {
                        if (dtbl.Rows.Count == 1)
                            ReordrStkreminder = ReordrStkreminder + "1 Reorder Level product \n\n";
                        else
                            ReordrStkreminder = ReordrStkreminder + dtbl.Rows.Count + "  Reorder Level products \n\n";
                    }
                }
                if (Salesreminder.Trim() != string.Empty || Purchasereminder.Trim() != string.Empty || Personalreminder.Trim() != string.Empty || NegativeStkreminder.Trim() != string.Empty || MinStkreminder.Trim() != string.Empty || MaxStkreminder.Trim() != string.Empty || ReordrStkreminder.Trim() != string.Empty)
                {
                    frmReminderPopUp frmReminder = new frmReminderPopUp();
                    frmReminderPopUp isOpen = Application.OpenForms["frmReminderPopUp"] as frmReminderPopUp;
                    if (isOpen == null)
                    {
                        frmReminder.WindowState = FormWindowState.Normal;
                        frmReminder.MdiParent = formMDI.MDIObj;
                        frmReminder.BringToFront();
                        frmReminder.ChangeLabel(Salesreminder, Purchasereminder, Personalreminder, ShortExpiryReminder, NegativeStkreminder, MinStkreminder, MaxStkreminder, ReordrStkreminder);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("CCD : 13 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #23
0
 /// <summary>
 /// Function to fill gridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP();
         if (txtVoucherNo.Text.Trim() == string.Empty)
         {
             strInvoiceNo = "-1";
         }
         else
         {
             strInvoiceNo = txtVoucherNo.Text;
         }
         if (cmbCashOrParty.SelectedIndex == 0 || cmbCashOrParty.SelectedIndex == -1)
         {
             decLedgerId = -1;
         }
         else
         {
             decLedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
         }
         if (cmbVoucherType.SelectedIndex == 0 || cmbVoucherType.SelectedIndex == -1)
         {
             decVoucherTypeId = -1;
         }
         else
         {
             decVoucherTypeId = Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString());
         }
        
         if (cmbStatus.SelectedIndex == 0 || cmbStatus.SelectedIndex == -1)
         {
             strStatus = "All";
         }
         else
         {
              strStatus = cmbStatus.SelectedItem.ToString();
         }
         DateTime FromDate = this.dtpFromDate.Value;
         DateTime ToDate = this.dtpToDate.Value;
         dtblPurchaseOrderRegister = spPurchaseOrderMaster.PurchaseOrdeReportViewAll(strInvoiceNo, decLedgerId, decVoucherTypeId, FromDate, ToDate, strStatus);
    
         if (dtblPurchaseOrderRegister.Rows.Count > 0)
         {
             decimal decTotal = 0;
             for (int i = 0; i < dtblPurchaseOrderRegister.Rows.Count; i++)
             {
                 if (dtblPurchaseOrderRegister.Rows[i]["totalAmount"].ToString() != null)
                 {
                     decTotal = decTotal + Convert.ToDecimal(dtblPurchaseOrderRegister.Rows[i]["totalAmount"].ToString());
                 }
             }
             decTotal = Math.Round(decTotal, 2);
             txtTotalAmount.Text = decTotal.ToString();
         }
         else
         {
             txtTotalAmount.Text = "0.00";
         }
         dgvPurchaseOrderReport.DataSource = dtblPurchaseOrderRegister;
         if (dgvPurchaseOrderReport.Columns.Count > 0)
         {
             dgvPurchaseOrderReport.Columns["dgvtxtTotalAmount"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PORP:4" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }