/// <summary>
 /// Functin to save and update batch
 /// </summary>
 public void SaveOrEdit()
 {
     try
     {
         if (txtBatchName.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter batch name");
             txtBatchName.Focus();
         }
         else if (cmbProduct.SelectedIndex == -1)
         {
             Messages.InformationMessage("Select product");
             cmbProduct.Focus();
         }
         else
         {
             BatchBll BllBatch = new BatchBll();
             BatchInfo infoBatch = new BatchInfo();
             infoBatch.BatchNo = txtBatchName.Text.Trim();
             infoBatch.ProductId = Convert.ToDecimal(cmbProduct.SelectedValue.ToString());
             infoBatch.ManufacturingDate = Convert.ToDateTime(txtMfgDate.Text);
             infoBatch.ExpiryDate = Convert.ToDateTime(txtExpiryDate.Text);
             infoBatch.narration = txtNarration.Text.Trim();
             infoBatch.Extra1 = string.Empty;
             infoBatch.Extra2 = string.Empty;
             Int32 inBarcode = BllBatch.AutomaticBarcodeGeneration();
             infoBatch.barcode = Convert.ToString(inBarcode);
             if (btnSave.Text == "Save")
             {
                 if (Messages.SaveConfirmation())
                 {
                     if (BllBatch.BatchNameAndProductNameCheckExistence(txtBatchName.Text.Trim(), Convert.ToDecimal(cmbProduct.SelectedValue.ToString()), 0) == false)
                     {
                         if (dtpMfgDate.Value <= dtpExpiryDate.Value)
                         {
                             BllBatch.BatchAddParticularFields(infoBatch);
                             Messages.SavedMessage();
                             Clear();
                         }
                         else
                         {
                             Messages.InformationMessage(" Can't save batch with mfg date greater than expiry date");
                             txtMfgDate.Select();
                         }
                     }
                     else
                     {
                         Messages.InformationMessage(" Already exist");
                         txtBatchName.Focus();
                     }
                 }
             }
             else
             {
                 if (Messages.UpdateConfirmation())
                 {
                     infoBatch.BatchId = decId;
                     if (BllBatch.BatchNameAndProductNameCheckExistence(txtBatchName.Text.Trim(), Convert.ToDecimal(cmbProduct.SelectedValue.ToString()), decBatchId) == false)
                     {
                         BllBatch.BatchEdit(infoBatch);
                         Messages.UpdatedMessage();
                         SearchClear();
                         Clear();
                     }
                     else
                     {
                         Messages.InformationMessage("Already exists");
                         txtBatchName.Focus();
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("B1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }