예제 #1
0
 private void BtnLogin_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         using (UnitofWork db = new UnitofWork())
         {
             if (IsEdit)
             {
                 var Login = db.LoginRepository.GetAll().First();
                 Login.UserName = TxtUsername.Text;
                 Login.Password = Txtpassword.Text;
                 db.LoginRepository.Update(Login);
                 db.Save();
                 Application.Restart();
             }
             else
             {
                 if (db.LoginRepository.GetAll(l =>
                                               l.UserName == TxtUsername.Text &&
                                               l.Password == Txtpassword.Text).Any())
                 {
                     DialogResult = DialogResult.OK;
                 }
                 else
                 {
                     RtlMessageBox.Show("اطلاعات وارد شده صحیح نمیباشد");
                 }
             }
         }
     }
 }
예제 #2
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         using (UnitOfWork db = new UnitOfWork())
         {
             if (IsEdit)
             {
                 var login = db.LoginRepository.Get().First();
                 login.UserName = txtUserName.Text;
                 login.Password = txtPassword.Text;
                 db.LoginRepository.Update(login);
                 db.Save();
                 Application.Restart();
             }
             else
             {
                 if (db.LoginRepository.Get(l => l.UserName == txtUserName.Text && l.Password == txtPassword.Text).Any())
                 {
                     DialogResult = DialogResult.OK;
                 }
                 else
                 {
                     RtlMessageBox.Show("کاربری یافت نشد.");
                 }
             }
         }
     }
 }
예제 #3
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         using (var uow = new UnitOfWorks())
         {
             if (IsEdit)
             {
                 var id   = Common.Common.UserID;
                 var user = uow.Userrepository.GetById(id);
                 user.Username     = txtUsername.Text;
                 user.userPassword = txtPassword.Text;
                 uow.Userrepository.Update(user);
                 uow.Save();
                 Application.Restart();
             }
             else
             {
                 if (uow.Userrepository.GetAll(l => l.Username == txtUsername.Text && l.userPassword == txtPassword.Text).Any())
                 {
                     Common.Common.UserID = uow.Userrepository.GetAll(l => l.Username == txtUsername.Text && l.userPassword == txtPassword.Text).Select(u => u.UserID).SingleOrDefault();
                     DialogResult         = DialogResult.OK;
                 }
                 else
                 {
                     RtlMessageBox.Show("اطلاعات وارد شده صحیح نمی باشد", "هشدار", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 }
             }
         }
     }
 }
예제 #4
0
 private void btnAddCustomer_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         string imageName = Guid.NewGuid().ToString() + Path.GetExtension(pcCustomer.ImageLocation);
         string imagePath = Application.StartupPath + "/Images/Customers/";
         if (!Directory.Exists(imagePath))
         {
             Directory.CreateDirectory(imagePath);
         }
         pcCustomer.Image.Save(imagePath + imageName);
         Customers customer = new Customers()
         {
             FullName        = txtFullName.Text.ToString(),
             Email           = txtEmail.Text.ToString(),
             CustomerAddress = txtAddress.Text.ToString(),
             CustomerImage   = imageName,
             Mobile          = txtMobile.Text.ToString()
         };
         using (var uof = new UnitOfWorks())
         {
             if (customerID == 0)
             {
                 uof.CustomerRepository.InsertCustomers(customer);
             }
             else
             {
                 customer.CustomerID = customerID;
                 uof.CustomerRepository.Update(customer);
             }
             uof.Save();
         }
         DialogResult = DialogResult.OK;
     }
 }
예제 #5
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         BookTB book = new BookTB()
         {
             BookName   = txtBookName.Text,
             Code       = txtBookCode.Text,
             Publishare = txtPublishare.Text,
             Writer     = txtWriter.Text
         };
         using (ControlerDB db = new ControlerDB())
         {
             if (BookId == 0)
             {
                 db.BookRepository.Insert(book);
                 db.Save();
             }
             else
             {
                 book.BookID = BookId;
                 db.BookRepository.Updatae(book);
                 db.Save();
             }
         }
         DialogResult = DialogResult.OK;
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         if (rbPayment.Checked || rbRecieve.Checked)
         {
             var accounting = new DataLayer.Context.Accounting()
             {
                 CustomerID_Cus        = int.Parse(dgvTransAction.CurrentRow.Cells[1].Value.ToString()),
                 AccountingDescription = txtDescription.Text,
                 TypeID_typ            = (rbRecieve.Checked) ? 2 : 1,
                 Amount       = txtAmount.Text.ToString(),
                 CreationDate = DateTime.Now
             };
             using (var uow = new UnitOfWorks())
             {
                 if (accountingId == 0)
                 {
                     uow.AccountingRepo.Insert(accounting);
                 }
                 else
                 {
                     accounting.AccountigID = accountingId;
                     uow.AccountingRepo.Update(accounting);
                 }
                 uow.Save();
             };
             DialogResult = DialogResult.OK;
         }
         else
         {
             RtlMessageBox.Show("لطفا نوع تراکنش را انتخاب کنید");
         }
     }
 }
예제 #7
0
 private void btnsave_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         if (AID == 0)
         {
             DataLayer.Accounting accounting = new DataLayer.Accounting()
             {
                 CustomerID  = int.Parse(dgvCustomer.CurrentRow.Cells[0].Value.ToString()),
                 TypeID      = byte.Parse(((rbtnInCome.Checked) ? 1 : 2).ToString()),
                 Amount      = int.Parse(numericUpDown1.Text.ToString()),
                 DateTime    = DateTime.Now,
                 Description = textBox1.Text
             };
             db.BaseRepositoryAccounting.Insert(accounting);
         }
         else
         {
             DataLayer.Accounting myAccounting = db.BaseRepositoryAccounting.GetById(AID);
             myAccounting.CustomerID  = db.CustomerRepository.GetCustomersByName(txtCustomer.Text).CustomersID;
             myAccounting.Amount      = int.Parse(numericUpDown1.Text);
             myAccounting.Description = textBox1.Text;
             myAccounting.TypeID      = byte.Parse((((rbtnInCome.Checked) ? 1 : 2).ToString()));
             db.BaseRepositoryAccounting.Update(myAccounting);
         }
         db.Save();
         DialogResult = DialogResult.OK;
     }
 }
예제 #8
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         if (rbPay.Checked || rbResive.Checked)
         {
             db = new UnitOfWork();
             DateLayer.Acconting acconting = new DateLayer.Acconting()
             {
                 Amount      = int.Parse(txtAmount.Value.ToString()),
                 CustomerID  = db.customerRepository.GetCustomerIDByName(txtName.Text),
                 TypeID      = (rbResive.Checked) ? 1 : 2,
                 DateTime    = DateTime.Now,
                 Description = txtDescription.Text
             };
             if (AccontID == 0)
             {
                 db.AccontingRepository.Insert(acconting);
             }
             else
             {
                 acconting.ID = AccontID;
                 db.AccontingRepository.Update(acconting);
             }
             db.Save();
             db.Dispose();
             DialogResult = DialogResult.OK;
         }
         else
         {
             RtlMessageBox.Show("لطفا نوع تراکنش را انتخاب کنید ");
         }
     }
 }
예제 #9
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         if (rbPay.Checked || rbRecieve.Checked)
         {
             db = new UnitOfWork();
             DataLayer.Accounting accounting = new DataLayer.Accounting()
             {
                 Amount      = int.Parse(txtAmount.Value.ToString()),
                 CustomerID  = db.CustomerRepository.GetCustomerByName(txtName.Text),
                 TypeID      = (rbRecieve.Checked) ? 1 : 2,
                 DateTitle   = DateTime.Now,
                 Description = txtDescription.Text
             };
             if (AccountId == 0)
             {
                 db.AccountingRepository.Insert(accounting);
                 db.Save();
             }
             else
             {
                 accounting.ID = AccountId;
                 db.AccountingRepository.Update(accounting);
             }
             db.Save();
             db.Dispose();
             DialogResult = DialogResult.OK;
         }
         else
         {
             MessageBox.Show("Please choose the transaction type");
         }
     }
 }
예제 #10
0
        private void BtnSubmit_Click(object sender, EventArgs e)
        {
            if (BaseValidator.IsFormValid(this.components))
            {
                if (RbtnIncome.Checked || RbtnOutgoing.Checked)
                {
                    db = new UnitofWork();
                    DataLayer.Accounting accounting = new DataLayer.Accounting()
                    {
                        Amount      = int.Parse(NumericAmount.Value.ToString()),
                        TypeID      = (RbtnIncome.Checked) ? 1 : 2,
                        CustomerID  = db.CustomerRepository.GetCustomerIdByName(TxtName.Text),
                        Description = TxtDecription.Text,
                        Datetime    = DateTime.Now
                    };
                    if (AccountId == 0)
                    {
                        db.accountingrepository.Insert(accounting);
                    }
                    else
                    {
                        accounting.AccID = AccountId;
                        db.accountingrepository.Update(accounting);
                    }

                    db.Save();
                    db.Dispose();
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    RtlMessageBox.Show("لطفا نوع تراکنش را انتخاب کنید");
                }
            }
        }
예제 #11
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         string IMGName = Guid.NewGuid().ToString() + Path.GetExtension(pcCustomer.ImageLocation);
         string path    = Application.StartupPath + "/Images/";
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         pcCustomer.Image.Save(path + IMGName);
         CustomerTB customer = new CustomerTB()
         {
             Address     = txtAddress.Text,
             Email       = txtEmail.Text,
             Phone       = txtPhone.Text,
             FullName    = txtName.Text,
             CustomerIMG = IMGName
         };
         if (customerID == 0)
         {
             db.customerRepository.InsertCustomer(customer);
         }
         else
         {
             customer.CustomerID = customerID;
             db.customerRepository.UpdateCustomer(customer);
         }
         db.Save();
         DialogResult = DialogResult.OK;
     }
 }
예제 #12
0
 private void Btnsubmit_Click(object sender, EventArgs e)
 {
     using (UnitofWork db = new UnitofWork())
     {
         if (BaseValidator.IsFormValid(this.components))
         {
             if (Txtrepeatpassword.Text != TxtPassword.Text)
             {
                 RtlMessageBox.Show("لطفا کلمه عبور را دوباره وارد کنید");
                 Txtrepeatpassword.Focus();
                 Txtrepeatpassword.SelectAll();
             }
             else
             {
                 DataLayer.Login login = new DataLayer.Login()
                 {
                     FullName = TxtName.Text,
                     UserName = TxtUsername.Text,
                     Password = TxtPassword.Text
                 };
                 if (db.LoginRepository.GetAll(l => l.UserName == TxtUsername.Text).Any() == false)
                 {
                     db.LoginRepository.Insert(login);
                 }
                 db.Save();
                 Application.Restart();
                 DialogResult = DialogResult.OK;
             }
         }
     }
 }
예제 #13
0
 private void btnsave_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         using (MainContext db = new MainContext())
         {
             string imagename = Guid.NewGuid().ToString() + Path.GetExtension(pictureBox1.ImageLocation);
             string path      = Application.StartupPath + "/Images/";
             if (!Directory.Exists(path))
             {
                 Directory.CreateDirectory(path);
             }
             pictureBox1.Image.Save(path + imagename);
             Customers customer = new Customers()
             {
                 FullName      = txtname.Text,
                 Address       = txtaddress.Text,
                 Email         = txtemail.Text,
                 Mobile        = txtmobile.Text,
                 CustomerImage = imagename
             };
             if (customerID == 0)
             {
                 db.CustomerRepository.InsertCustomer(customer);
             }
             else
             {
                 var editcustomer = db.CustomerRepository.GetCustomerById(customerID);
                 db.CustomerRepository.UpdateCustomer(editcustomer);
             }
             db.Save();
         }
         DialogResult = DialogResult.OK;
     }
 }
예제 #14
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     using (UnitOfWork db = new UnitOfWork())
     {
         string ImageName = Guid.NewGuid().ToString() + Path.GetExtension(pcCustomerPhoto.ImageLocation);
         string PathName  = Application.StartupPath + "/Images/";
         if (!Directory.Exists(PathName))
         {
             Directory.CreateDirectory(PathName);
         }
         pcCustomerPhoto.Image.Save(PathName + ImageName);
         if (BaseValidator.IsFormValid(this.components))
         {
             Customers customer = new Customers()
             {
                 FullName      = txtFullName.Text,
                 Address       = txtAddress.Text,
                 EmailAddress  = txtEmailAddress.Text,
                 Mobile        = txtMobile.Text,
                 CustomerImage = ImageName
             };
             if (customerId == 0)
             {
                 db.CustomerRepository.InsertCustomer(customer);
             }
             else
             {
                 customer.CustomerID = customerId;
                 db.CustomerRepository.UpdateCustomer(customer);
             }
             db.Save();
             DialogResult = DialogResult.OK;
         }
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         String imageName = Guid.NewGuid().ToString() + Path.GetExtension(pcCustomer.ImageLocation);
         String path      = Application.StartupPath + "/Images/";
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         pcCustomer.Image.Save(path + imageName);
         DataLayer.Customers customer = new DataLayer.Customers()
         {
             Fullname      = txtFullname.Text,
             Address       = txtAddress.Text,
             Mobile        = txtMobile.Text,
             Email         = txtEmail.Text,
             CustomerImage = imageName
         };
         if (customerId == 0)
         {
             db.CustomerRepository.InsertCustomer(customer);
         }
         else
         {
             customer.CustomerID = customerId;
             db.CustomerRepository.UpdateCustomer(customer);
         }
         db.Save();
         DialogResult = DialogResult.OK;
     }
 }
예제 #16
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (BaseValidator.IsFormValid(this.components))
         {
             var s = new Staff();
             s.StaffName        = txtName.Text;
             s.StaffEmail       = txtEmail.Text;
             s.StaffSection     = txtSection.Text;
             s.StaffAddress     = txtAddress.Text;
             s.StaffAge         = int.Parse(txtAge.Text.ToString());
             s.StaffPhoneNumber = txtPhoneNumber.Text;
             using (UnitOfWork db = new UnitOfWork())
             {
                 if (id == 0)
                 {
                     db.SGenericRepository.Insert(s);
                 }
                 else
                 {
                     s.StaffID = id;
                     db.SGenericRepository.Update(s);
                 }
                 db.Save();
                 DialogResult = DialogResult.OK;
             }
         }
     }
     catch
     {
         RtlMessageBox.Show("به صورت صحیح وارد کنید!", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #17
0
        private void BtnSubmit_Click(object sender, EventArgs e)
        {
            using (UnitofWork db = new UnitofWork())
            {
                if (BaseValidator.IsFormValid(this.components))
                {
                    DataLayer.Product product = new DataLayer.Product()
                    {
                        ProductName = TxtProductName.Text,
                        Unit        = TxtUnit.Text,
                        QTY         = int.Parse(NumQTY.Value.ToString()),
                        Price       = int.Parse(NumPrice.Value.ToString())
                    };
                    if (IsEdit == false)
                    {
                        db.ProductRepository.Insert(product);
                    }
                    else
                    {
                        int id = Convert.ToInt32(MydataGridView.CurrentRow.Cells[0].Value.ToString());

                        product.ProductID = id;
                        db.ProductRepository.Update(product);
                    }
                }
                db.Save();

                DialogResult = DialogResult.OK;
                bindgrid();
            }
        }
예제 #18
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         string ImageName = null;
         if (pcCustomer.ImageLocation == null || !(pcCustomer.ImageLocation.Contains("Man")) || !(pcCustomer.ImageLocation.Contains("Woman")))
         {
             ImageName = Guid.NewGuid().ToString() + Path.GetExtension(pcCustomer.ImageLocation);
         }
         else
         {
             if (Check())
             {
                 ImageName = "Man.png";
             }
             else
             {
                 ImageName = "Woman.png";
             };
         }
         pcCustomer.Image.Save(PathLo + ImageName);
         using (UnitOfWork Un = new UnitOfWork())
         {
             Customers customer = new Customers
             {
                 FullName   = txtName.Text,
                 Age        = (int)txtAge.Value,
                 Email      = txtEmail.Text,
                 Address    = txtAddres.Text,
                 Phone      = txtPhone.Text,
                 PhotoImage = ImageName,
             };
             if (Check())
             {
                 customer.Sex = "M";
             }
             else
             {
                 customer.Sex = "W";
             }
             if (ContactID != 0)
             {
                 //Edit Customer
                 customer.ColumnID = ContactID;
                 Un.Customers.Update(customer);
             }
             else
             {
                 //New Customer
                 Un.Customers.Insert(customer);
             }
             Un.Save();
             DialogResult = DialogResult.OK;
         }
     }
 }
 private void Button1_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         this.Close();
     }
     else
     {
         MessageBox.Show("You still have invalid input.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
예제 #20
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (BaseValidator.IsFormValid(this.components))
         {
             using (UnitOfWork db = new UnitOfWork())
             {
                 var M = db.MGenericRepository.GetById(1);
                 if (M.ManagerImage != null)
                 {
                     File.Delete(Application.StartupPath + "/Images/" + M.ManagerImage);
                 }
             }
             string imageName = Guid.NewGuid().ToString() + Path.GetExtension(pcManager.ImageLocation);
             string path      = Application.StartupPath + "/Images/";
             if (!Directory.Exists(path))
             {
                 Directory.CreateDirectory(path);
             }
             pcManager.Image.Save(path + imageName);
             var m = new Manager();
             m.ManagerID          = 1;
             m.ManagerName        = txtName.Text;
             m.ManagerAddress     = txtAddress.Text;
             m.ManagerAge         = int.Parse(txtAge.Text.ToString());
             m.ManagerPhoneNumber = txtPhoneNumber.Text;
             m.ManagerExpert      = txtExpert.Text;
             m.ManagerEmail       = txtEmail.Text;
             m.ManagerImage       = imageName;
             using (UnitOfWork db = new UnitOfWork())
             {
                 db.MGenericRepository.Update(m);
                 db.Save();
                 DialogResult = DialogResult.OK;
             }
         }
     }
     catch
     {
         RtlMessageBox.Show("به صورت صحیح وارد کنید!", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #21
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         using (UnitOfWork dn = new UnitOfWork())
         {
             if (!isEdit)
             {
                 var Login = dn.LoginRepository;
                 if (Login.Get(a => a.Username == txtUsername.Text).Any())
                 {
                     if (dn.LoginRepository.Get(a => a.Password == txtPassword.Text).Any())
                     {
                         DialogResult = DialogResult.OK;
                     }
                     else
                     {
                         MessageBox.Show("Your entered password is not correct");
                     }
                 }
                 else
                 {
                     MessageBox.Show("Your entered Username is not correct");
                 }
             }
             else
             {
                 var Login = dn.LoginRepository.Get().First();
                 Login.Username = txtUsername.Text;
                 Login.Password = txtPassword.Text;
                 dn.LoginRepository.Update(Login);
                 dn.Save();
                 MessageBox.Show("Your ID is updted");
                 DialogResult = DialogResult.OK;
             }
         }
     }
     else
     {
         MessageBox.Show("Please fix errors first", "Error");
     }
 }
예제 #22
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            using (ControlerDB db = new ControlerDB())
            {
                string path = Application.StartupPath + "/Images/";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                string imagename = Guid.NewGuid().ToString() +
                                   Path.GetExtension(pcCustomer.ImageLocation);
                pcCustomer.Image.Save(path + imagename);
                if (BaseValidator.IsFormValid(this.components))
                {
                    CustomerTB customer = new CustomerTB()
                    {
                        FullName    = txtFullName.Text,
                        Address     = txtAddress.Text,
                        Email       = txtEmail.Text,
                        Phone       = txtPhone.Text,
                        CustomerIMG = imagename
                    };
                    if (userId == 0)
                    {
                        db.CustomersRepository.InsertCustomers(customer);
                    }

                    if (userId != 0)
                    {
                        customer.CustomerID = userId;
                        db.CustomersRepository.UpdateCustomer(customer);
                    }
                    db.Save();
                }

                DialogResult = DialogResult.OK;
            }
        }
예제 #23
0
        private void btninsertdata_Click(object sender, EventArgs e)
        {
            if (BaseValidator.IsFormValid(this.components))
            {
                string locationName = string.Empty;
                if (pc.Image != null)
                {
                    locationName = Guid.NewGuid().ToString() + Path.GetExtension(pc.ImageLocation);
                    if (!Directory.Exists(Application.StartupPath + "/Images/"))
                    {
                        Directory.CreateDirectory(Application.StartupPath + "/Images/");
                    }
                    pc.Image.Save(Application.StartupPath + "/Images/" + locationName);
                }

                using (Business.Customers UOW = new Business.Customers())
                {
                    DataLayer.Customers customer = new DataLayer.Customers()
                    {
                        Address  = txtAddress.Text.Trim(),
                        Email    = txtEmail.Text.Trim(),
                        FullName = txtName.Text.Trim(),
                        Mobile   = txtMobile.Text.Trim(),
                        Image    = locationName
                    };
                    if (CustomerID != 0)
                    {
                        customer.ID = CustomerID;
                        UOW.Update(customer);
                    }
                    else
                    {
                        UOW.Insert(customer);
                    }

                    UOW.Save();
                }
            }
        }
예제 #24
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (BaseValidator.IsFormValid(this.components))
     {
         if (lblPerson.Visible != false)
         {
             if (MessageBox.Show("Are you sure that you want to save it?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
             {
                 //Accounting accounting = new Accounting()
                 //{
                 //    Amount = int.Parse(txtAmount.Value.ToString()),
                 //    DateTitle = DateTime.Now,
                 //    TypeID = (rbIncome.Checked == true) ? 1 : 2,
                 //    CustomerID = int.Parse(db.Customers.Get(a => a.FullName ==lblPerson.Text).Select(a => a.ColumnID).ToString()),
                 //    Description = txtDescription.Text,
                 //
                 //};
                 Accounting accounting = new Accounting();
                 accounting.FullName    = dgvPeoples.CurrentRow.Cells[0].Value.ToString();
                 accounting.Amount      = int.Parse(txtAmount.Value.ToString());
                 accounting.DateTitle   = DateTime.Now;
                 accounting.TypeID      = (rbIncome.Checked == true) ? 1 : 2;
                 accounting.Description = txtDescription.Text;
                 db.AccountingRepository.Insert(accounting);
                 db.Save();
                 DialogResult = DialogResult.OK;
                 this.Close();
             }
         }
         else
         {
             MessageBox.Show("Please Select a person!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Please Fix the errors first!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #25
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (BaseValidator.IsFormValid(this.components))
         {
             if (rbBlood.Checked || rbHeart.Checked)
             {
                 if (id != 0)
                 {
                     using (UnitOfWork db = new UnitOfWork())
                     {
                         var D = db.DGetGenericRepository.GetById(id);
                         if (D.DoctorImage != null)
                         {
                             File.Delete(Application.StartupPath + "/Images/" + D.DoctorImage);
                         }
                     }
                 }
                 string imageName = Guid.NewGuid().ToString() + Path.GetExtension(pcDoctor.ImageLocation);
                 string path      = Application.StartupPath + "/Images/";
                 if (!Directory.Exists(path))
                 {
                     Directory.CreateDirectory(path);
                 }
                 pcDoctor.Image.Save(path + imageName);
                 var d = new Doctor();
                 d.DoctorAddress     = txtAddress.Text;
                 d.DoctorAge         = int.Parse(txtAge.Text.ToString());
                 d.DoctorImage       = imageName;
                 d.DoctorName        = txtName.Text;
                 d.DoctorPhoneNumber = txtPhoneNumber.Text;
                 if (rbBlood.Checked)
                 {
                     d.DoctorSection = "خون";
                 }
                 else
                 {
                     d.DoctorSection = "قلب";
                 }
                 using (UnitOfWork db = new UnitOfWork())
                 {
                     if (id == 0)
                     {
                         db.DGetGenericRepository.Insert(d);
                     }
                     else
                     {
                         d.DoctorID = id;
                         db.DGetGenericRepository.Update(d);
                     }
                     db.Save();
                     DialogResult = DialogResult.OK;
                 }
             }
             else
             {
                 RtlMessageBox.Show("نوع بخش را انتخاب کنید!", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch
     {
         RtlMessageBox.Show("به صورت صحیح وارد کنید!", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (BaseValidator.IsFormValid(this.components))
         {
             if (rbBlood.Checked || rbHeart.Checked)
             {
                 if (Id != 0)
                 {
                     using (UnitOfWork db = new UnitOfWork())
                     {
                         var P = db.PGenericRepository.GetById(Id);
                         if (P.PatientImage != null)
                         {
                             File.Delete(Application.StartupPath + "/Images/" + P.PatientImage);
                         }
                     }
                 }
                 string imageName = Guid.NewGuid().ToString() + Path.GetExtension(pcPatient.ImageLocation);
                 string path      = Application.StartupPath + "/Images/";
                 if (!Directory.Exists(path))
                 {
                     Directory.CreateDirectory(path);
                 }
                 pcPatient.Image.Save(path + imageName);
                 var p = new Patient();
                 p.PatientName        = txtName.Text;
                 p.PatientPhoneNumber = txtPhoneNumber.Text;
                 p.PatientAddress     = txtAddress.Text;
                 p.PatientEmail       = txtEmail.Text;
                 p.PatientImage       = imageName;
                 if (rbBlood.Checked)
                 {
                     p.PatientDisease = "خونی";
                     p.PatientAmount  = 12000;
                 }
                 else
                 {
                     p.PatientDisease = "قلبی";
                     p.PatientAmount  = 15000;
                 }
                 using (UnitOfWork db = new UnitOfWork())
                 {
                     if (Id == 0)
                     {
                         p.PatientDate = DateTime.Now.DayOfYear.ToString();
                         db.PGenericRepository.Insert(p);
                     }
                     else
                     {
                         p.PatientID   = Id;
                         p.PatientDate = Time;
                         db.PGenericRepository.Update(p);
                     }
                     db.Save();
                     DialogResult = DialogResult.OK;
                 }
             }
             else
             {
                 RtlMessageBox.Show("نوع بیماری را انتخاب کنید!", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch
     {
         RtlMessageBox.Show("به صورت صحیح وارد کنید!", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }