예제 #1
0
        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 btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                List <ShenasNamehDto> fillData = new List <ShenasNamehDto>();

                using (var db = new dbs_CMMSEntities1())
                {
                    var result = db.tbl_ShenasnamehMoshinAlat.Where(x => x.CodeDastghah.Contains(txtSearch.Text) || x.NameDastgha.Contains(txtSearch.Text) || x.ModelDastGhah.Contains(txtSearch.Text)).ToList();
                    foreach (var item in result)
                    {
                        fillData.Add(new ShenasNamehDto()
                        {
                            ID                   = item.ID,
                            NameDastgha          = item.NameDastgha,
                            CodeDastghah         = item.CodeDastghah,
                            ModelDastGhah        = item.ModelDastGhah,
                            Size                 = item.Size,
                            Vazn                 = item.Vazn,
                            Zarfiyat             = item.Zarfiyat,
                            AmerMofid            = item.AmerMofid,
                            SharkatSazandeh      = item.SharkatSazandeh,
                            KeshvarSazandeh      = item.KeshvarSazandeh,
                            TaiedKonnadeh        = item.TaiedKonnadeh,
                            AdressNamayandegi    = item.AdressNamayandegi,
                            TelphoneNamayandegi  = item.TelphoneNamayandegi,
                            Bargh                = item.Bargh,
                            Ab                   = item.Ab,
                            Hava                 = item.Hava,
                            Ghaz                 = item.Ghaz,
                            TarikhSakht          = PersianDateTimeHelper.FaDate(item.TarikhSakht),
                            TarikhBahrehBardari  = PersianDateTimeHelper.FaDate(item.TarikhBahrehBardari),
                            TarikhTahiyeEttelaat = PersianDateTimeHelper.FaDate(item.TarikhTahiyeEttelaat),
                        });
                    }
                }
                dgvShenasnamehMashinAlat.DataSource = fillData;
            }
            catch (Exception ex)
            {
                conn.Close();
                MessageBox.Show(ex.Message, "خطایی رخ داده است", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
예제 #3
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);
     }
 }
예제 #4
0
        //string VaziyatGhalebToString(bool Vaziyat)
        //{
        //    if(Vaziyat)
        //    return "";
        //    else ""
        //}
        void PopulateDataGridView()
        {
            try
            {
                List <ShenasNamehGalebDto> fillData = new List <ShenasNamehGalebDto>();

                using (var db = new dbs_CMMSEntities1())
                {
                    var result = db.tbl_Ghaleb.ToList();
                    foreach (var item in result)
                    {
                        fillData.Add(new ShenasNamehGalebDto()
                        {
                            ID                    = item.ID,
                            Code                  = item.Code,
                            NameGhaleb            = item.NameGhaleb,
                            GensGhaleb            = item.GensGhaleb,
                            Ertefa                = item.Ertefa,
                            Arz                   = item.Arz,
                            Address               = item.Address,
                            sharayetneghahdari    = item.sharayetneghahdari,
                            SystemKhoonakKonnadeh = item.SystemKhoonakKonnadeh,
                            Tool                  = item.Tool,
                            TypeGhaleb            = item.TypeGhaleb,
                            TypeGiris             = item.TypeGiris,
                            UsableMaterials       = item.UsableMaterials,
                            VaziyatGhaleb         = item.VaziyatGhaleb,
                            VaziyatKharid         = item.VaziyatKharid,
                            OmreMofid             = item.OmreMofid,
                            Sazandeh              = item.Sazandeh,
                            Vazn                  = item.Vazn,
                            TarikhSakht           = PersianDateTimeHelper.FaDate(item.TarikhSakht),
                            tarikhShorooBeKar     = PersianDateTimeHelper.FaDate(item.tarikhShorooBeKar)
                        });
                    }
                }
                dgvShenasnamehMashinAlat.DataSource = fillData;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "خطایی رخ داده است", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            frmEditGhaleb frm = new frmEditGhaleb();

            frm.PropID                  = model.ID;
            frm.txtName.Text            = model.NameGhaleb;
            frm.txtCode.Text            = model.Code;
            frm.cmbType.Text            = model.TypeGhaleb;
            frm.txtVazn.Text            = model.Vazn;
            frm.txtUsableMaterials.Text = model.UsableMaterials;
            frm.txtAddress.Text         = model.Address;

            frm.txtTool.Text                  = model.Tool;
            frm.txtArz.Text                   = model.Arz;
            frm.txtErtefa.Text                = model.Ertefa;
            frm.txtOmerMofid.Text             = model.OmreMofid;
            frm.txtSazandeh.Text              = model.Sazandeh;
            frm.txtSharayetNegahdari.Text     = model.sharayetneghahdari;
            frm.txtSystemKhoonakKonnadeh.Text = model.SystemKhoonakKonnadeh;
            frm.txtTarikhSakht.Text           = PersianDateTimeHelper.FaDate(model.TarikhSakht);
            frm.txtTarikhShorooBeKar.Text     = PersianDateTimeHelper.FaDate(model.tarikhShorooBeKar);
            frm.txtTypeGiris.Text             = model.TypeGiris;
            frm.txtVaziyatKharid.Text         = model.VaziyatKharid;
            if (model.VaziyatGhaleb != null)
            {
                if (model.VaziyatGhaleb == true)
                {
                    frm.rdbFelezi.Checked = true;
                    frm.txtFelezi.Text    = model.GensGhaleb;
                }
                else
                {
                    frm.rdbPelastic.Checked = true;
                    frm.txtPelastic.Text    = model.GensGhaleb;
                }
            }


            frm.ShowDialog();
            PopulateDataGridView();
        }