コード例 #1
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);
            }
        }
コード例 #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         DateTime dt;
         if (DateTime.TryParse(txtTarikhSakht.Text, out dt) && DateTime.TryParse(txtTarikhBahrehBardari.Text, out dt) && DateTime.TryParse(txtTarikhTahiyehAtelaat.Text, out dt))
         {
             dbs_CMMSEntities1         obj = new dbs_CMMSEntities1();
             tbl_ShenasnamehMoshinAlat tbl = new tbl_ShenasnamehMoshinAlat();
             tbl.NameDastgha         = txtNameDastghah.Text;
             tbl.CodeDastghah        = txtCodeDastghah.Text;
             tbl.ModelDastGhah       = txtModelDastghah.Text;
             tbl.Size                = txtSize.Text;
             tbl.Vazn                = txtVazn.Text;
             tbl.Zarfiyat            = txtZarfiyat.Text;
             tbl.AmerMofid           = txtOmrehMofid.Text;
             tbl.SharkatSazandeh     = txtSherkateSazandeh.Text;
             tbl.KeshvarSazandeh     = txtKeshvarSazandeh.Text;
             tbl.TaiedKonnadeh       = txtTaiedKonnandeh.Text;
             tbl.AdressNamayandegi   = txtAddressNamayandegi.Text;
             tbl.TelphoneNamayandegi = txtTelphoneNamayandegi.Text;
             tbl.Bargh               = chkBargh.Checked;
             tbl.Ab                   = chkAb.Checked;
             tbl.Hava                 = chkHava.Checked;
             tbl.Ghaz                 = chkGaz.Checked;
             tbl.TarikhSakht          = PersianDateTimeHelper.ConvertToDate(txtTarikhSakht.Text);
             tbl.TarikhBahrehBardari  = PersianDateTimeHelper.ConvertToDate(txtTarikhBahrehBardari.Text);
             tbl.TarikhTahiyeEttelaat = PersianDateTimeHelper.ConvertToDate(txtTarikhTahiyehAtelaat.Text);
             obj.tbl_ShenasnamehMoshinAlat.Add(tbl);
             obj.SaveChanges();
             MessageBox.Show("اطلاعات با موفقیت ذخیره گردید", "ثبت اطلاعات", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
         else
         {
             MessageBox.Show("لطفا تاریخ را درست وارد نمایید", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "خطای رخ داده است", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
コード例 #3
0
ファイル: frmEditGhaleb.cs プロジェクト: SHAHABNOORI/CMMS
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                dbs_CMMSEntities1 obj = new dbs_CMMSEntities1();
                var EditeData         = obj.tbl_Ghaleb.Where(x => x.ID == PropID).First();
                EditeData.NameGhaleb         = txtName.Text;
                EditeData.Code               = txtCode.Text;
                EditeData.Vazn               = txtVazn.Text;
                EditeData.Address            = txtAddress.Text;
                EditeData.UsableMaterials    = txtUsableMaterials.Text;
                EditeData.TypeGhaleb         = cmbType.Text;
                EditeData.Tool               = txtTool.Text;
                EditeData.Arz                = txtArz.Text;
                EditeData.Ertefa             = txtErtefa.Text;
                EditeData.OmreMofid          = txtOmerMofid.Text;
                EditeData.Sazandeh           = txtSazandeh.Text;
                EditeData.sharayetneghahdari = txtSharayetNegahdari.Text;
                EditeData.TarikhSakht        = PersianDateTimeHelper.ConvertToDate(txtTarikhSakht.Text);
                EditeData.tarikhShorooBeKar  = PersianDateTimeHelper.ConvertToDate(txtTarikhShorooBeKar.Text);
                EditeData.TypeGiris          = txtTypeGiris.Text;
                EditeData.VaziyatKharid      = txtVaziyatKharid.Text;
                if (rdbFelezi.Checked)
                {
                    EditeData.VaziyatGhaleb = true;
                    EditeData.GensGhaleb    = txtFelezi.Text;
                }
                else
                {
                    EditeData.VaziyatGhaleb = false;
                    EditeData.GensGhaleb    = txtPelastic.Text;
                }

                obj.SaveChanges();
                MessageBox.Show("اطلاعات با موفقیت ویرایش گردید", "ویرایش", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "خطایی رخ داده است", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }