Exemple #1
0
 /// <summary>
 /// Fill controls on datagridview cell double click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvBrand_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex != -1)
         {
             BrandInfo infoBrand = new BrandInfo();
             BrandSP   spBrand   = new BrandSP();
             strBrandName = dgvBrand.CurrentRow.Cells["Column1"].Value.ToString();
             if (strBrandName != "NA")
             {
                 decBrandId           = Convert.ToDecimal(dgvBrand.Rows[e.RowIndex].Cells["dgvtxtBrandid"].Value.ToString());
                 infoBrand            = spBrand.BrandView(decBrandId);
                 txtBrandName.Text    = infoBrand.BrandName;
                 txtManufacturer.Text = infoBrand.Manufacturer;
                 txtNarration.Text    = infoBrand.Narration;
                 btnSave.Text         = "Update";
                 txtBrandName.Focus();
                 btnDelete.Enabled = true;
                 strBrandName      = infoBrand.BrandName;
             }
             else
             {
                 Messages.WarningMessage("NA Brand cannot update or delete");
                 Clear();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("BR19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #2
0
 /// <summary>
 /// Function to save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         BrandSP   spBrand   = new BrandSP();
         BrandInfo infoBrand = new BrandInfo();
         infoBrand.BrandName    = txtBrandName.Text.Trim();
         infoBrand.Narration    = txtNarration.Text.Trim();;
         infoBrand.Manufacturer = txtManufacturer.Text.Trim();
         infoBrand.ExtraDate    = DateTime.Now;
         infoBrand.Extra1       = string.Empty;
         infoBrand.Extra2       = string.Empty;
         if (spBrand.BrandCheckIfExist(txtBrandName.Text.Trim(), 0) == false)
         {
             decIdentity = spBrand.BrandAdd(infoBrand);
             Messages.SavedMessage();
             Clear();
         }
         else
         {
             Messages.InformationMessage("Brand name already exist");
             txtBrandName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("BR2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #3
0
 /// <summary>
 /// Function to edit
 /// </summary>
 public void EditFunction()
 {
     try
     {
         BrandSP   spBrand   = new BrandSP();
         BrandInfo infoBrand = new BrandInfo();
         infoBrand.BrandName    = txtBrandName.Text.Trim();
         infoBrand.Narration    = txtNarration.Text.Trim();
         infoBrand.Manufacturer = txtManufacturer.Text.Trim();
         infoBrand.Extra1       = string.Empty;
         infoBrand.Extra2       = string.Empty;
         infoBrand.ExtraDate    = DateTime.Now;
         infoBrand.BrandId      = decBrandId;
         if (txtBrandName.Text != strBrandName)
         {
             if (CheckExistenceOfBrandName() == false)
             {
                 if (spBrand.BrandEdit(infoBrand))
                 {
                     Messages.UpdatedMessage();
                     Clear();
                     txtBrandName.Focus();
                 }
                 else if (infoBrand.BrandId == 1)
                 {
                     Messages.InformationMessage("Cannot update");
                     Clear();
                     txtBrandName.Focus();
                 }
             }
             else
             {
                 Messages.InformationMessage("Brand name already exists");
                 txtBrandName.Focus();
             }
         }
         else if (infoBrand.BrandId == 1)
         {
             Messages.InformationMessage("Cannot update");
             Clear();
             txtBrandName.Focus();
         }
         else
         {
             if (spBrand.BrandEdit(infoBrand))
             {
                 Messages.UpdatedMessage();
                 Clear();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("BR3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #4
0
 /// <summary>
 /// Function to fill datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         BrandSP   spBrand   = new BrandSP();
         DataTable dtblBrand = new DataTable();
         dtblBrand           = spBrand.BrandSearch(txtBrandNameSearch.Text.Trim());
         dgvBrand.DataSource = dtblBrand;
     }
     catch (Exception ex)
     {
         MessageBox.Show("BR7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill the barnd combobox
 /// </summary>
 public void BrandComboFill()
 {
     try
     {
         DataTable dtbl    = new DataTable();
         BrandSP   spBrand = new BrandSP();
         dtbl = spBrand.BrandViewAll();
         DataRow dr = dtbl.NewRow();
         dr["brandName"] = "All";
         dr["brandId"]   = 0;
         dtbl.Rows.InsertAt(dr, 0);
         cmbBrand.DataSource    = dtbl;
         cmbBrand.DisplayMember = "brandName";
         cmbBrand.ValueMember   = "brandId";
     }
     catch (Exception ex)
     {
         MessageBox.Show("SER:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #6
0
 /// <summary>
 /// Function to delete
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         BrandSP spBrand = new BrandSP();
         if (spBrand.BrandDeleteCheckExistence(decBrandId) <= 0)
         {
             Messages.ReferenceExistsMessage();
         }
         else
         {
             Clear();
             btnSave.Text = "Save";
             Messages.DeletedMessage();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("BR6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #7
0
        /// <summary>
        /// Function to check existence of brand name
        /// </summary>
        /// <returns></returns>
        public bool CheckExistenceOfBrandName()
        {
            bool isExist = false;

            try
            {
                BrandSP spBrand = new BrandSP();
                isExist = spBrand.BrandCheckIfExist(txtBrandName.Text.Trim(), 0);
                if (isExist)
                {
                    string strBrandNames = txtBrandName.Text.Trim();
                    if (strBrandNames.ToLower() == strBrandName.ToLower())
                    {
                        isExist = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("BR8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(isExist);
        }