コード例 #1
0
 private void dgvShenasnamehMashinAlat_Click(object sender, EventArgs e)
 {
     if (dgvShenasnamehMashinAlat.CurrentRow != null)
     {
         if (dgvShenasnamehMashinAlat.CurrentRow.Index != -1)
         {
             model.ID = Convert.ToInt64(dgvShenasnamehMashinAlat.CurrentRow.Cells["ID"].Value);
             dbs_CMMSEntities1 _db = new dbs_CMMSEntities1();
             model = _db.tbl_Ghaleb.Where(x => x.ID == model.ID).FirstOrDefault();
         }
     }
 }
コード例 #2
0
ファイル: FrmAddGhaleb.cs プロジェクト: SHAHABNOORI/CMMS
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                dbs_CMMSEntities1 obj = new dbs_CMMSEntities1();
                tbl_Ghaleb        tbl = new tbl_Ghaleb();
                tbl.Code                  = txtCode.Text;
                tbl.NameGhaleb            = txtName.Text;
                tbl.TypeGhaleb            = cmbType.Text;
                tbl.Tool                  = txtTool.Text;
                tbl.Arz                   = txtArz.Text;
                tbl.Ertefa                = txtErtefa.Text;
                tbl.Vazn                  = txtVazn.Text;
                tbl.VaziyatKharid         = txtVaziyatKharid.Text;
                tbl.SystemKhoonakKonnadeh = txtSystemKhoonakKonnadeh.Text;
                tbl.TypeGiris             = txtTypeGiris.Text;
                tbl.OmreMofid             = txtOmerMofid.Text;
                tbl.Sazandeh              = txtSazandeh.Text;
                tbl.TarikhSakht           = PersianDateTimeHelper.ConvertToDate(txtTarikhSakht.Text);
                tbl.tarikhShorooBeKar     = PersianDateTimeHelper.ConvertToDate(txtTarikhShorooBeKar.Text);
                if (rdbFelezi.Checked)
                {
                    tbl.VaziyatGhaleb = true;
                    tbl.GensGhaleb    = txtFelezi.Text;
                }
                else
                {
                    tbl.VaziyatGhaleb = false;
                    tbl.GensGhaleb    = txtPelastic.Text;
                }

                tbl.UsableMaterials    = txtUsableMaterials.Text;
                tbl.Address            = txtAddress.Text;
                tbl.sharayetneghahdari = txtSharayetNegahdari.Text;
                obj.tbl_Ghaleb.Add(tbl);
                obj.SaveChanges();
                MessageBox.Show("اطلاعات با موفقیت ذخیره گردید", "ثبت اطلاعات", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "خطای رخ داده است", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }