Пример #1
0
 /// <summary>
 /// Function to call the save or edit function and also checking invalid entries 
 /// </summary>
 public void SaveOrEdit()
 {
     SalesQuotationMasterSP SpSalesQuotationMaster = new SalesQuotationMasterSP();
     try
     {
         int InRow = dgvProduct.RowCount;
         dgvProduct.ClearSelection();
         if (txtQuotationNo.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Please enter QuotationNo");
             txtQuotationNo.Focus();
         }
         else if (SpSalesQuotationMaster.CheckSalesQuotationNumberExistance(txtQuotationNo.Text.Trim(), decsalesQuotationTypeId) == true && btnSave.Text == "Save")
         {
             Messages.InformationMessage("Quotation number already  exist");
         }
         else if (cmbCashOrParty.SelectedValue == null)
         {
             Messages.InformationMessage(" please select cash Or Party");
             cmbCashOrParty.Focus();
         }
         else if (cmbSalesman.SelectedValue == null)
         {
             Messages.InformationMessage("Please select any salesman ");
             cmbSalesman.Focus();
         }
         else if (txtSalesQuotationDate.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Select date between financial year");
         }
         else if (cmbPricinglevel.SelectedValue == null)
         {
             Messages.InformationMessage("please select pricing level");
         }
         else if (InRow - 1 == 0)
         {
             Messages.InformationMessage("Can't save SalesQuotation without atleast one product with complete details");
         }
         else
         {
             if (RemoveIncompleteRowFromTheGrid())
             {
                 if (dgvProduct.Rows[0].Cells["dgvtxtProductName"].Value == null && dgvProduct.Rows[0].Cells["dgvtxtProductCode"].Value == null && dgvProduct.Rows[0].Cells["dgvcmbBatch"].Value == null)
                 {
                     MessageBox.Show("Can't save salesQuotation  without atleast one product with complete details", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     dgvProduct.ClearSelection();
                     dgvProduct.Focus();
                 }
                 else
                 {
                     if (btnSave.Text == "Save")
                     {
                         if (dgvProduct.Rows[0].Cells["dgvtxtProductName"].Value == null)
                         {
                             MessageBox.Show("Can't save salesQuotation without atleast one product with complete details", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                             dgvProduct.ClearSelection();
                             dgvProduct.Focus();
                         }
                         {
                             if (PublicVariables.isMessageAdd)
                             {
                                 if (Messages.SaveMessage())
                                 {
                                     SaveFunction();
                                 }
                             }
                             else
                             {
                                 SaveFunction();
                             }
                         }
                     }
                     if (btnSave.Text == "Update")
                     {
                         if (dgvProduct.Rows[0].Cells["dgvtxtProductName"].Value == null)
                         {
                             MessageBox.Show("Can't edit salesQuotation without atleast one product with complete details", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                             dgvProduct.ClearSelection();
                             dgvProduct.Focus();
                         }
                         else
                         {
                             if (PublicVariables.isMessageEdit)
                             {
                                 if (Messages.UpdateMessage())
                                 {
                                     EditFunction();
                                 }
                             }
                             else
                             {
                                 EditFunction();
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SQ:37" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }