Esempio n. 1
0
        public FrmEmp(PersonModel p)
        {
            InitializeComponent();
            btnsave.Text          = "ویرایش";
            ID                    = p.ID;
            txtname.Text          = p.Name;
            txtfamily.Text        = p.Family;
            txtbimenum.Text       = p.BimeNum;
            txtempcode.Text       = p.EmpCode;
            txtfathername.Text    = p.FatherName;
            txtnationalcode.Text  = p.NationalCode;
            txtshsh.Text          = p.EmpShSh;
            txtmsh1.Text          = p.EmpMSh1;
            txtmsh2.Text          = p.EmpMSh2;
            txtcitysodor.Text     = p.CitySodor;
            txtcodecitysodor.Text = p.CityCodeSodor;
            txtbakhshsodor.Text   = p.BakhshSodor;
            txtcitytavalod.Text   = p.CityTavalod;
            txtcodetavalod.Text   = p.CityTavalodCode;
            txtcountry.Text       = p.CountryTavalod;
            txtcodecountry.Text   = p.CountryTavalodCode;
            txttavaloddate.Text   = p.TavalodDate.ToString();
            txtjobname.Text       = p.Job;
            txtjobcode.Text       = p.JobCode;
            if (p.Sex == "مرد")
            {
                cmbSex.SelectedItem = "مرد";
            }
            else if (p.Sex == "زن")
            {
                cmbSex.SelectedItem = "زن";
            }

            if (p.Married == "متاهل")
            {
                cmbMarrid.SelectedItem = "متاهل";
            }
            else if (p.Married == "مجرد")
            {
                cmbMarrid.SelectedItem = "مجرد";
            }
            txtchild.Value = Convert.ToInt32(p.Child);

            if (p.National == "ایرانی")
            {
                cmbNation.SelectedItem = "ایرانی";
            }
            else if (p.National == "غیر ایرانی")
            {
                cmbNation.SelectedItem = "غیر ایرانی";
            }

            cmbEducation.SelectedValue = p.Education;
            txtbranch.Text             = p.Branch;
            txtunivercity.Text         = p.UniverCity;
            txtyear.Text     = p.YearEducation.ToString();
            txttell.Text     = p.Tell;
            txttellcode.Text = p.CodeTell;
            txtmobile.Text   = p.Mobile;
            txtemail.Text    = p.Email;
            txtaddress.Text  = p.Address;
            txtpost.Text     = p.Post;
            txtjobnum.Text   = p.JobNum;
            txtjobdate.Text  = p.JobDate.ToString();
            txtbankname.Text = p.BankName;
            txtbanknum.Text  = p.Banknum;
            txtbankcard.Text = p.BankCard;
            pic = p.Pic;
            if (File.Exists(Application.StartupPath + "\\Photo\\" + pic))
            {
                pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\Photo\\" + pic);
            }
        }
Esempio n. 2
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            //try
            //{

            PersonModel p = new PersonModel();

            p.Name               = txtname.Text;
            p.Family             = txtfamily.Text;
            p.BimeNum            = txtbimenum.Text;       //3
            p.EmpCode            = txtempcode.Text;       //4
            p.FatherName         = txtfathername.Text;    //5
            p.NationalCode       = txtnationalcode.Text;  //6
            p.EmpShSh            = txtshsh.Text;          //7
            p.EmpMSh1            = txtmsh1.Text;          //8
            p.EmpMSh2            = txtmsh2.Text;          //9
            p.CitySodor          = txtcitysodor.Text;     //10
            p.CityCodeSodor      = txtcodecitysodor.Text; //11
            p.BakhshSodor        = txtbakhshsodor.Text;   //12
            p.CityTavalod        = txtcitytavalod.Text;   //13
            p.CityTavalodCode    = txtcodetavalod.Text;   //14
            p.CountryTavalod     = txtcountry.Text;       //15
            p.CountryTavalodCode = txtcodecountry.Text;   //16
            //p.TavalodDate = Convert.ToInt32(txttavaloddate.Text.Replace("/",""));  //17
            p.Job     = txtjobname.Text;                  //18
            p.JobCode = txtjobcode.Text;                  //19
            //p.Sex = cmbSex.SelectedItem.ToString();     //20
            //p.Married = cmbMarrid.SelectedItem.ToString();  //21
            p.Child = txtchild.Value.ToString();                  //22
            //p.National = cmbNation.SelectedItem.ToString();     //23
            p.Education  = cmbEducation.SelectedValue.ToString(); //FMessageBox.Show(cmbEducation.SelectedValue.ToString());    //24
            p.Branch     = txtbranch.Text;                        //25
            p.UniverCity = txtunivercity.Text;                    //26
            //p.YearEducation = Convert.ToInt32(txtyear.Text);       //27
            p.Tell     = txttell.Text;                            //28
            p.CodeTell = txttellcode.Text;                        //29
            p.Mobile   = txtmobile.Text;                          //30


            try
            {
                //var eMailValidator = new System.Net.Mail.MailAddress(txtemail.Text);
                //p.Email = eMailValidator.ToString();
            }
            catch (FormatException ex)
            {
                FMessageBox.Show("آدرس ایمیل درست وارد کنید");
                return;
            }

            p.Address = txtaddress.Text;        //32
            p.Post    = txtpost.Text;           //33
            p.JobNum  = txtjobnum.Text;         //34
            //p.JobDate = Convert.ToInt32(txtjobdate.Text.Replace("/", ""));  //35
            p.BankName = txtbankname.Text;      //36
            p.Banknum  = txtbanknum.Text;       //37
            p.BankCard = txtbankcard.Text;      //38
            p.Pic      = pic;                   //39


            if (btnsave.Text == "ویرایش")
            {
                p.ID = ID;
                SqlliteDataAccess.EditPerson(p);
                FMessageBox.Show("با موفقیت ویرایش شد", "پیام", FMessageBoxButtons.OK, FMessageBoxIcons.Information);
            }
            else
            {
                SqlliteDataAccess.SavePerson(p);
                FMessageBox.Show("با موفقیت ثبت شد", "پیام", FMessageBoxButtons.OK, FMessageBoxIcons.Information);
            }
            FrmViewEmp vm = new FrmViewEmp();

            vm.InitializeBinding();

            this.Close();


            //}
            //catch (Exception ex)
            //{

            //    FMessageBox.Show(ex.Message, "پیام", FMessageBoxButtons.OK, FMessageBoxIcons.Warning);

            //}
        }