private void vendors_nsme_Click(object sender, EventArgs e) { if (itemname.Text.Trim() == "") { notificationMAnager1.show("please enter the item name", 1000); itemname.Focus(); return; } if (pricce_fltb.value == 0) { notificationMAnager1.show("please enter the item price", 1000); pricce_fltb.Focus(); return; } if (textBox_barcode.Text.Trim() == "") { notificationMAnager1.show("Point Barcode Reader properly to the product or, if product has no Barcode then, type 'Na' in barcode field", 2000); textBox_barcode.Focus(); return; } if (comboBox_category.SelectedIndex < 0) { notificationMAnager1.show("Please Select a Category", 1000); return; } if (floattb_cost.value > pricce_fltb.value) { if (Comformation.ShowModal("Please Confirm Your Selling Rate", ", Your selling price is less then cost price please check and confirm", true) == DialogResult.OK) { ; } } if (floattb_wholesaleprice.value > pricce_fltb.value) { if (Comformation.ShowModal("Please Confirm Your wholesale Rate", ", are you sure your selling price is less then wholesale ?", true) == DialogResult.OK) { ; } } if (floattb_wholesaleprice.value == 0) { floattb_wholesaleprice.value = pricce_fltb.value; } else { floattb_wholesaleprice.value = floattb_wholesaleprice.value; } try { item i = new item(); i.name = itemname.Text; i.stock = qty_fltb.value; i.rate = pricce_fltb.value; i.buyrate = floattb_cost.value; i.barcode = textBox_barcode.Text; i.wholesaleprice = floattb_wholesaleprice.value; i.category_id = (comboBox_category.SelectedItem as category).id; i.created_at = DateTime.Now; i.updated_at = DateTime.Now; db.items.Add(i); db.SaveChanges(); if (onDataSaved != null) { onDataSaved(this, new DataSaveargs() { data = i }); } notificationMAnager1.show("Successfully Data are Saved......", 10000); this.Close(); } catch (Exception ex) { notificationMAnager1.show("data is not save Please Try Again" + ex.Message, 10000); } }
private void label2_Click(object sender, EventArgs e) { if (itemeditname_txt.Text.Trim() == "") { notificationMAnager1.show("please enter your item name", 1000); return; } if (comboBox_category.SelectedItem == null) { notificationMAnager1.show("please select catrgory", 1000); return; } if (bettertextbox_barcode.Text.Trim() == "") { notificationMAnager1.show("Point Barcode Reader properly to the product or, if product has no Barcode then, type 'Na' in barcode field", 2000); bettertextbox_barcode.Focus(); return; } if (floattb_cost.value > price_fltb.value) { if (Comformation.ShowModal("Please Confirm Your Selling Rate", ", Your selling price is less then cost price please check and confirm", true) == DialogResult.OK) { ; } } if (floattb_wholesaleprice.value > price_fltb.value) { if (Comformation.ShowModal("Please Confirm Your wholesale Rate", ", are you sure your selling price is less then wholesale ?", true) == DialogResult.OK) { ; } } if (floattb_wholesaleprice.value == 0) { floattb_wholesaleprice.value = price_fltb.value; } else { floattb_wholesaleprice.value = floattb_wholesaleprice.value; } try { item a = db.items.Where(o => o.id == id).First(); a.name = itemeditname_txt.Text; a.category_id = (comboBox_category.SelectedItem as Models.category).id; a.stock = stock_fltb.value; a.rate = price_fltb.value; a.buyrate = floattb_cost.value; a.barcode = bettertextbox_barcode.Text; a.wholesaleprice = floattb_wholesaleprice.value; a.created_at = DateTime.Now; a.updated_at = DateTime.Now; db.Entry(a).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); if (onDataEdited != null) { onDataEdited(this, new DataSaveargs() { data = a }); } } catch (Exception) { notificationMAnager1.show("data can not be saved", 1000); } this.Close(); }