コード例 #1
0
 /// <summary>
 /// Function for save or update
 /// </summary>
 public void SaveOrEdit()
 {
     try
     {
         ProductCreationBll BllProductCreation = new ProductCreationBll();
         if (txtName.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter product name");
             txtName.Focus();
         }
         else if (txtProductCode.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter prouct code");
             txtProductCode.Focus();
         }
         else if (cmbGroup.SelectedIndex == -1)
         {
             Messages.InformationMessage("Select group");
             cmbGroup.Focus();
         }
         else if (cmbUnit.SelectedIndex == -1)
         {
             Messages.InformationMessage(" Select unit");
             cmbUnit.Focus();
         }
         else if (cmbTaxApplicableOn.SelectedIndex == -1 && cmbTax.SelectedIndex != 0)
         {
             Messages.InformationMessage("Select tax applicable on");
             cmbTaxApplicableOn.Focus();
         }
         else if (Convert.ToDecimal(txtMaximumStock.Text.ToString()) < Convert.ToDecimal(txtMinimumStock.Text.ToString()))
         {
             Messages.InformationMessage("maximum stock should be greater than Minimum  stock");
             txtMinimumStock.Focus();
         }
         else
         {
             if (btnSave.Text == "Save")
             {
                 if (BllProductCreation.ProductCodeCheckExistence(txtProductCode.Text.Trim(), 0) == false)
                 {
                     if (PublicVariables.isMessageAdd)
                     {
                         if (Messages.SaveMessage())
                         {
                             SaveFunction();
                         }
                     }
                     else
                     {
                         SaveFunction();
                     }
                 }
                 else
                 {
                     Messages.InformationMessage("Product code already exist");
                     txtProductCode.Focus();
                 }
             }
             else
             {
                 if (BllProductCreation.ProductCodeCheckExistence(txtProductCode.Text.Trim(), decProductIdForEdit) == false)
                 {
                     EditFunction();
                 }
                 else
                 {
                     Messages.InformationMessage("Product code already exist");
                     txtProductCode.Focus();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC:62" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
コード例 #2
0
 /// <summary>
 /// Function to check whether ProductCode exist
 /// </summary>
 /// <returns></returns>
 public bool CheckAlreadyExist()
 {
     bool isOk = true;
     try
     {
         ProductCreationBll BllProductCreation = new ProductCreationBll();
         int inCompleteRow = 0;
         int inCurrentindex = 0;
         string strMessage = "Row";
         foreach (DataGridViewRow dgvRow in dgvMultipleProductCreation.Rows)
         {
             if (dgvRow.Cells["dgvtxtProductCode"].Value != null)
             {
                 string ProductCode = dgvRow.Cells["dgvtxtProductCode"].Value.ToString();
                 if (BllProductCreation.ProductCodeCheckExistence(ProductCode, 0))
                 {
                     isOk = false;
                     if (inCompleteRow == 0)
                     {
                         strMessage = strMessage + Convert.ToString(dgvRow.Index + 1);
                         inCurrentindex = dgvRow.Index;
                         inCompleteRow++;
                     }
                     else
                     {
                         strMessage = strMessage + ", " + Convert.ToString(dgvRow.Index + 1);
                     }
                 }
             }
         }
         if (!isOk)
         {
             strMessage = strMessage + " contains already exisitng productcode. Do you want to continue?";
             if (MessageBox.Show(strMessage, "OpenMiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
             {
                 isOk = true;
                 for (int inK = 0; inK < dgvMultipleProductCreation.Rows.Count; inK++)
                 {
                     if (dgvMultipleProductCreation.Rows[inK].Cells["dgvtxtProductCode"].Value != null)
                     {
                         string strProductCode = dgvMultipleProductCreation.Rows[inK].Cells["dgvtxtProductCode"].Value.ToString().Trim();
                         if (BllProductCreation.ProductCodeCheckExistence(strProductCode, 0) == true)
                         {
                             if (!dgvMultipleProductCreation.Rows[inK].IsNewRow)
                             {
                                 dgvMultipleProductCreation.Rows.RemoveAt(inK);
                                 inK--;
                             }
                         }
                     }
                 }
             }
             else
             {
                 dgvMultipleProductCreation.Rows[inCurrentindex].Cells["dgvtxtProductCode"].Selected = true;
                 dgvMultipleProductCreation.CurrentCell = dgvMultipleProductCreation.Rows[inCurrentindex].Cells["dgvtxtProductCode"];
                 dgvMultipleProductCreation.Focus();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MPC19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return isOk;
 }