protected void Button3_Click(object sender, EventArgs e) { try { cls_operations_admin obj1 = new cls_operations_admin(); cls_operations_admin obj2 = new cls_operations_admin(0, 0, 0, "", "", 0, "", "", 0); obj1 = obj2.Select(txt_ID.Text); global_filepath = obj1.Photo; obj2.ID = Int32.Parse(txt_ID.Text); obj2.Name = txt_name.Text.Trim(); obj2.Brand = txt_brand.Text.Trim(); obj2.Price = float.Parse(txt_price.Text); obj2.Description = txt_description.Text.Trim(); obj2.Photo = img_upload(FileUpload1); obj2.Current_stock = Int32.Parse(txt_current_stock.Text); /*if (String.IsNullOrEmpty(obj2.Name)) //this was to verify i the var was empty of not * { * Response.Write("<script>alert('fil');</script>"); * } * else * { * Response.Write("<script>alert('nope');</script>"); * }*/ //lbl_success.Text = "Product Updated Successfully " + global_filepath+"< "; if (status == true)//check if the picture fulfill all the requirements in the algorithm { if (obj2.Updatek()) { lbl_success.Text = "Product Updated Successfully "; // Response.Write("<script>alert('success');</script>"); txt_ID.Text = ""; txt_name.Text = ""; txt_brand.Text = ""; txt_price.Text = ""; txt_description.Text = ""; DDL_category.SelectedValue = "0"; txt_current_stock.Text = ""; // DeleteFileFromFolder(global_filepath); status = false; DeleteFileFromFolder(global_filepath); } else { lbl_verification.Text = obj2.msg; } } } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
protected void btn_delete_Click(object sender, EventArgs e) { /*difference between find_ID and Select is that find_ID is bool and Select return a class*/ try { cls_operations_admin obj1 = new cls_operations_admin(); cls_operations_admin obj2 = new cls_operations_admin(); if (obj2.find_ID(txt_ID.Text)) { obj1 = obj2.Select(txt_ID.Text); global_filepath = obj1.Photo; //lbl_success.Text = obj1.Photo; // lbl_success.Text = "Product Deleted Successfully"; // obj2.ID = Int32.Parse(txt_ID.Text); //global_filepath = obj2.Photo; if (obj2.Delete(txt_ID.Text)) { lbl_success.Text = "Product Deleted Successfully "; txt_ID.Text = ""; DeleteFileFromFolder(global_filepath); // DeleteFileFromFolder(global_filepath); } else { lblstatus.Text = obj2.msg; } lblstatus.Text = ""; } else { lblstatus.Text = "ID not found"; } } catch (Exception ex) { Response.Write("<script>alert('" + ex.Message + "');</script>"); } }
protected void LINK_BUTTUN_ID_Click(object sender, EventArgs e) { cls_operations_admin obj2 = new cls_operations_admin(0, 0, 0, "", "", 0, "", "", 0); cls_operations_admin obj1 = new cls_operations_admin(); if (obj2.find_ID(txt_ID.Text)) { obj2 = obj1.Select(txt_ID.Text); txt_name.Text = obj2.Name; txt_brand.Text = obj2.Brand; txt_price.Text = obj2.Price.ToString(); txt_description.Text = obj2.Description; DDL_category.SelectedValue = obj2.Fk_id_cat.ToString(); Image2.ImageUrl = obj2.Photo; txt_current_stock.Text = obj2.Current_stock.ToString(); global_filepath = obj2.Photo; lblstatus.Text = ""; // lbl_success.Text = "Product Updated Successfully " + global_filepath + "< "; } else { lblstatus.Text = "ID not found"; } }