Ejemplo n.º 1
0
 private void BtnInsertUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (DropDownItemName.SelectedIndex <= 0)
         {
             messageShow.singlemsgtext("Please select the Item Name.");
             DropDownItemName.Focus();
             return;
         }
         if (DropDownProductName.SelectedIndex <= 0)
         {
             messageShow.singlemsgtext("Please select the Product Name.");
             DropDownProductName.Focus();
             return;
         }
         if (string.IsNullOrEmpty(TxtBrandName.Text.ToString()))
         {
             messageShow.singlemsgtext("Brand name should not be empty");
             TxtBrandName.Focus();
             return;
         }
         SelectedProductCode = Convert.ToInt32(((KeyValuePair <string, string>)DropDownProductName.SelectedItem).Key.ToString());
         var brand_master = new BrandMaster
         {
             BrandName     = TxtBrandName.Text.ToString(),
             ProductCode   = SelectedProductCode,
             BrandCode     = BrandCode,
             OperationType = BtnInsertUpdate.Text.ToString() == "Save" ? 1 : 2
         };
         int id = _instanceRepository.InsertUpdateDeleteBrandMaster(brand_master);
         if (id >= 1)
         {
             messageShow.singlemsgtext(brand_master.OperationType == 1 ? "New Brand added successfully" : "Brand updated successfully");
             brand_master.BrandName = "";
             ResetAllControls();
         }
         else if (id == -1)
         {
             messageShow.singlemsgtext("The brand name already exists, please try another name!");
         }
         else
         {
             messageShow.singlemsgtext("Error in Brand insert/update");
         }
     }
     catch (Exception _exception)
     {
         CmC.InsertException(_exception);
         messageShow.singlemsgtext(CmC.ExceptionErrorMessage);
     }
 }
Ejemplo n.º 2
0
 protected void BtnBrandAdd_Click(object sender, EventArgs e)
 {
     using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyWebsiteDB"].ConnectionString))
     {
         con.Open();
         SqlCommand cmd = new SqlCommand("Insert into Tbl_Brands(Name)Values('" + TxtBrandName.Text + "')", con);
         cmd.ExecuteNonQuery();
         Response.Write("<script> alert ('Marka Eklendi'); </script>");
         TxtBrandName.Text = string.Empty;
         con.Close();
         //LblMsg.Text = "Kayıt İşlemi Başarılı";
         //LblMsg.ForeColor = System.Drawing.Color.Green;
         TxtBrandName.Focus();
         BindBrandRepeater();
     }
 }