private void btn_add_Click(object sender, EventArgs e) { if (txt_Name.Text == string.Empty) { MessageBox.Show("رجاء ادخل اسم العمیل"); txt_Name.Focus(); return; } if (txt_phone.Text == string.Empty) { MessageBox.Show("رجاء ادخل رقم الهاتف"); txt_phone.Focus(); return; } if (txt_email.Text == string.Empty) { MessageBox.Show("رجاء ادخل البريد الكتروني"); txt_email.Focus(); return; } else { if (id == 0) { //add FRM_CUST frm_cust = new FRM_CUST(); pic_cust.Image.Save(model_pic.ms, System.Drawing.Imaging.ImageFormat.Jpeg); tb_cust.CUST_NAME = txt_Name.Text; tb_cust.CUST_PHONE = txt_phone.Text; tb_cust.CUST_EMAIL = txt_email.Text; tb_cust.CUST_IMAGE = model_pic.Convert_Byte(); dbs.TB_CUST.Add(tb_cust); dbs.SaveChanges(); MessageBox.Show("تم الحفظ العمیل بالنجاح"); dbs = new DB_SMPEntities(); frm_cust.gridControl1.DataSource = dbs.TB_CUST.ToList(); this.Close(); } else { // Edit pic_cust.Image.Save(model_pic.ms, System.Drawing.Imaging.ImageFormat.Jpeg); tb_cust.CUST_NAME = txt_Name.Text; tb_cust.CUST_PHONE = txt_phone.Text; tb_cust.CUST_EMAIL = txt_email.Text; tb_cust.ID_CUST = id; tb_cust.CUST_IMAGE = model_pic.Convert_Byte(); dbs.Entry(tb_cust).State = System.Data.Entity.EntityState.Modified; dbs.SaveChanges(); MessageBox.Show("تم تعديل العمیل بالنجاح"); dbs = new DB_SMPEntities(); FRM_CUST frm_cust = new FRM_CUST(); frm_cust.gridControl1.DataSource = dbs.TB_CUST.ToList(); this.Close(); } } }
private void btn_add_Click(object sender, EventArgs e) { if (txt_Name.Text == string.Empty) { MessageBox.Show("رجاء ادخل اسم المسخدم"); txt_Name.Focus(); return; } if (txt_pass.Text == string.Empty) { MessageBox.Show("رجاء ادخل كلمه المرور"); txt_pass.Focus(); return; } if (txt_roll.Text == string.Empty) { MessageBox.Show("رجاء ادخل صلاحيات المستخدم"); txt_roll.Focus(); return; } else { if (id == 0) { //add tb_user.USER_NAME = txt_Name.Text; tb_user.USER_PASS = txt_pass.Text; tb_user.USER_ROLL = txt_roll.Text; tb_user.USER_STATE = "False"; dbs.TB_USERS.Add(tb_user); dbs.SaveChanges(); MessageBox.Show("تم الحفظ المستخدم بالنجاح"); dbs = new DB_SMPEntities(); this.Close(); } else { // Edit tb_user.USER_ID = id; tb_user.USER_NAME = txt_Name.Text; tb_user.USER_PASS = txt_pass.Text; tb_user.USER_ROLL = txt_roll.Text; tb_user.USER_STATE = "false"; dbs.Entry(tb_user).State = System.Data.Entity.EntityState.Modified; dbs.SaveChanges(); MessageBox.Show("تم تعديل المستخدم بالنجاح"); dbs = new DB_SMPEntities(); FRM_SUPP frm_user = new FRM_SUPP(); frm_user.gridControl1.DataSource = dbs.TB_USERS.ToList(); this.Close(); } } }
// add or edit private void btn_add_Click(object sender, EventArgs e) { Toast toast = new Toast(); Dialog dialog = new Dialog(); // Check if add or edit if (edt_name.Text == "") { dialog.Width = this.Width; dialog.txt_caption.Text = "اسم الصنف المطلوب"; dialog.Show(); } else { //Check if add or edit if (id == 0) { //add pic_cover.Image.Save(methods.ma, System.Drawing.Imaging.ImageFormat.Jpeg); tb_cat.CAT_Name = edt_name.Text; tb_cat.CAT_Cover = methods.convert_byte(); db.TB_CAT.Add(tb_cat); db.SaveChanges(); toast.txt_caption.Text = "تم اضافة صنف جديد"; toast.Show(); db = new DB_SMPEntities(); frm_cat.gridControl1.DataSource = db.TB_CAT.ToList(); this.Close(); } else { //Edit pic_cover.Image.Save(methods.ma, System.Drawing.Imaging.ImageFormat.Jpeg); tb_cat.CAT_Name = edt_name.Text; tb_cat.ID = id; tb_cat.CAT_Cover = methods.convert_byte(); db.Entry(tb_cat).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); toast.txt_caption.Text = "تم تعديل الصنف "; toast.Show(); db = new DB_SMPEntities(); frm_cat.gridControl1.DataSource = db.TB_CAT.ToList(); this.Close(); } } }
private void btn_add_Click(object sender, EventArgs e) { if (txt_Name_Cat.Text == string.Empty) { MessageBox.Show("رجاء ادخل اسم الصنف"); txt_Name_Cat.Focus(); return; } else { if (id == 0) { //add pic_cover.Image.Save(model_pic.ms, System.Drawing.Imaging.ImageFormat.Jpeg); tb_cat.CAT_Name = txt_Name_Cat.Text; tb_cat.CAT_Cover = model_pic.Convert_Byte(); dbs.TB_CAT.Add(tb_cat); dbs.SaveChanges(); MessageBox.Show("تم الحفظ الصنف بالنجاح"); dbs = new DB_SMPEntities(); FRM_CAT frm_cat = new FRM_CAT(); frm_cat.gridControl1.DataSource = dbs.TB_CAT.ToList(); this.Close(); } else { // Edit pic_cover.Image.Save(model_pic.ms, System.Drawing.Imaging.ImageFormat.Jpeg); tb_cat.CAT_Name = txt_Name_Cat.Text; tb_cat.ID_CAT = id; tb_cat.CAT_Cover = model_pic.Convert_Byte(); dbs.Entry(tb_cat).State = System.Data.Entity.EntityState.Modified; dbs.SaveChanges(); MessageBox.Show("تم تعديل الصنف بالنجاح"); dbs = new DB_SMPEntities(); FRM_CAT frm_cat = new FRM_CAT(); frm_cat.gridControl1.DataSource = dbs.TB_CAT.ToList(); this.Close(); } } }
void update_data() { dbs = new DB_SMPEntities(); gridControl1.DataSource = dbs.TB_SELL.ToList(); }
private void btn_add_Click(object sender, EventArgs e) { if (txt_name.Text == string.Empty) { MessageBox.Show("رجاء ادخل اسم المادة"); txt_name.Focus(); return; } if (txt_type.Text == string.Empty) { MessageBox.Show("رجاء ادخل نوع المادة"); txt_type.Focus(); return; } if (add_cat.Text == string.Empty) { MessageBox.Show("رجاء اختر الصنف"); add_cat.Focus(); return; } if (add_supp.Text == string.Empty) { MessageBox.Show("رجاء اختر المورد"); add_supp.Focus(); return; } if (txt_det.Text == string.Empty) { MessageBox.Show("رجاء اكتب التفاصیل"); txt_det.Focus(); return; } else { if (id == 0) { //add tb_pur.PUR_NAME = txt_name.Text; tb_pur.PUR_TYPE = txt_type.Text; tb_pur.PUR_CAT = add_cat.Text; tb_pur.PUR_SUPP = add_supp.Text; tb_pur.PUR_DET = txt_det.Text; tb_pur.PUR_BUY = Convert.ToDouble(txt_buy.Text); tb_pur.PUR_SELL = Convert.ToDouble(txt_sell.Text); tb_pur.PUR_QT = Convert.ToDouble(txt_qt.Text); tb_pur.PUR_Tbuy = Convert.ToDouble(t_buy.Text); tb_pur.PUR_Tsell = Convert.ToDouble(t_sell.Text); tb_pur.PUR_TRev = Convert.ToDouble(t_all.Text); dbs.TB_PUR.Add(tb_pur); dbs.SaveChanges(); MessageBox.Show("تم الحفظ شراء بالنجاح"); dbs = new DB_SMPEntities(); this.Close(); } else { // Edit tb_pur.ID_PUR = id; tb_pur.PUR_NAME = txt_name.Text; tb_pur.PUR_TYPE = txt_type.Text; tb_pur.PUR_CAT = add_cat.Text; tb_pur.PUR_SUPP = add_supp.Text; tb_pur.PUR_DET = txt_det.Text; tb_pur.PUR_BUY = Convert.ToDouble(txt_buy.Text); tb_pur.PUR_SELL = Convert.ToDouble(txt_sell.Text); tb_pur.PUR_QT = Convert.ToDouble(txt_qt.Text); tb_pur.PUR_Tbuy = Convert.ToDouble(t_buy.Text); tb_pur.PUR_Tsell = Convert.ToDouble(t_sell.Text); tb_pur.PUR_TRev = Convert.ToDouble(t_all.Text); dbs.Entry(tb_pur).State = System.Data.Entity.EntityState.Modified; dbs.SaveChanges(); MessageBox.Show("تم تعدیل شراء بالنجاح"); this.Close(); } } }
private void update_data() { db = new DB_SMPEntities(); gridControl1.DataSource = db.TB_SUP.ToList(); }
private void btn_add_Click(object sender, EventArgs e) { //حساب من كمیه مطلوبه qtp = Convert.ToDouble(t_qt.Text); qtn = Convert.ToDouble(txt_qt.Text); qtr = qtp - qtn; if (txt_name.Text == string.Empty) { MessageBox.Show("رجاء ادخل اسم المادة"); txt_name.Focus(); return; } if (txt_cust.Text == string.Empty) { MessageBox.Show("رجاء ادخل اسم العمیل"); txt_cust.Focus(); return; } if (txt_sell.Text == string.Empty) { MessageBox.Show("رجاء ادخل سعر البیع"); txt_sell.Focus(); return; } if (txt_qt.Text == string.Empty) { MessageBox.Show("رجاء ادخل الكمیة"); txt_qt.Focus(); return; } else { if (id == 0) { ////add if (qtr >= 0) { tb_sell.SELL_NAME = txt_name.Text; tb_sell.SELL_CUST = txt_cust.Text; tb_sell.SELL_PRICE = Convert.ToDouble(txt_sell.Text); tb_sell.SELL_QT = Convert.ToDouble(txt_qt.Text); tb_sell.SELL_T_PRICE = (Convert.ToDouble(txt_qt.Value)) * Convert.ToDouble(txt_sell.Text); tb_sell.SELL_DATE = DateTime.Now; dbs.TB_SELL.Add(tb_sell); // تعدیل كمیه بعد بیع tb_pur.PUR_QT = qtr; dbs.Entry(tb_pur).State = System.Data.Entity.EntityState.Modified; dbs.SaveChanges(); MessageBox.Show("تم الحفظ البیع بالنجاح"); dbs = new DB_SMPEntities(); frm_sell.gridControl1.DataSource = dbs.TB_SELL.ToList(); this.Close(); } else { MessageBox.Show("كمية المطوبة غير موجود", "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error);; return; } } else { //// Edit //tb_pur.ID_PUR = id; //tb_pur.PUR_NAME = txt_name.Text; //tb_pur.PUR_TYPE = txt_type.Text; //tb_pur.PUR_CAT = txt_name.Text; //tb_pur.PUR_SUPP = txt_cust.Text; //tb_pur.PUR_DET = txt_det.Text; //tb_pur.PUR_BUY = Convert.ToDouble(txt_sell.Text); //tb_pur.PUR_SELL = Convert.ToDouble(txt_sell.Text); //tb_pur.PUR_QT = Convert.ToDouble(txt_qt.Text); //tb_pur.PUR_Tbuy = Convert.ToDouble(t_selll.Text); //tb_pur.PUR_Tsell = Convert.ToDouble(t_buy.Text); //tb_pur.PUR_TRev = Convert.ToDouble(t_qt.Text); //dbs.Entry(tb_pur).State = System.Data.Entity.EntityState.Modified; //dbs.SaveChanges(); //MessageBox.Show("تم تعدیل شراء بالنجاح"); //this.Close(); } } }