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 pic_supp.Image.Save(model_pic.ms, System.Drawing.Imaging.ImageFormat.Jpeg); tb_supp.SUPP_NAME = txt_Name.Text; tb_supp.SUPP_PHONE = txt_phone.Text; tb_supp.SUPP_EMAIL = txt_email.Text; tb_supp.SUPP_IMAGE = model_pic.Convert_Byte(); dbs.TB_SUPP.Add(tb_supp); dbs.SaveChanges(); MessageBox.Show("تم الحفظ المورد بالنجاح"); dbs = new DB_SMPEntities(); this.Close(); } else { // Edit pic_supp.Image.Save(model_pic.ms, System.Drawing.Imaging.ImageFormat.Jpeg); tb_supp.SUPP_NAME = txt_Name.Text; tb_supp.SUPP_PHONE = txt_phone.Text; tb_supp.SUPP_EMAIL = txt_email.Text; tb_supp.ID_SUPP = id; tb_supp.SUPP_IMAGE = model_pic.Convert_Byte(); dbs.Entry(tb_supp).State = System.Data.Entity.EntityState.Modified; dbs.SaveChanges(); MessageBox.Show("تم تعديل المورد بالنجاح"); dbs = new DB_SMPEntities(); FRM_SUPP frm_supp = new FRM_SUPP(); frm_supp.gridControl1.DataSource = dbs.TB_SUPP.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(); } } }