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(); } }
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("لطفا نوع تراکنش را انتخاب کنید"); } } }
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("اطلاعات وارد شده صحیح نمیباشد"); } } } } }
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; } } } }
public void register(string username, string password, string email) { using (var unitofwork = new UnitofWork(new JooleEntities())) { User tempuser = new User(); tempuser.UserName = username; tempuser.Password = password; tempuser.Email = email; tempuser.RoleDescription = "Customer"; tempuser.UserRoleId = 2; unitofwork.UserRepository.Insert(tempuser); unitofwork.Save(); } }
private void BtnSubmit_Click(object sender, EventArgs e) { //if (BaseValidator.IsFormValid(this.components)) if (TxtName.Text != null) { if (TxtMobile.Text != null) { string Path = Application.StartupPath + "/Images/"; string ImageName = Guid.NewGuid() + System.IO.Path.GetExtension(MypictureBox.ImageLocation); if (!Directory.Exists(Path)) { Directory.CreateDirectory(Path); } MypictureBox.Image.Save(Path + ImageName); Customers customers = new Customers() { FullName = TxtName.Text, Mobile = TxtMobile.Text, Email = TxtEmail.Text, Address = TxtAddress.Text, CustomerImage = "no" }; if (customerId == 0) { db.CustomerRepository.InsertCustomer(customers); } else { customers.CustomerID = customerId; db.CustomerRepository.UpdateCustomer(customers); } db.Save(); DialogResult = DialogResult.OK; } else { RtlMessageBox.Show("لطفا شماره موبایل را وارد کنید", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { RtlMessageBox.Show("لطفا شماره نام" + "را وارد کنید", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void BtnDelete_Click(object sender, EventArgs e) { if (MYdataGridView.CurrentRow != null) { int id = int.Parse(MYdataGridView.CurrentRow.Cells[0].Value.ToString()); if (RtlMessageBox.Show("ایا از حذف شخص مطمئن هستید", "توجه" , MessageBoxButtons.YesNo) == DialogResult.Yes) { using (UnitofWork db = new UnitofWork()) { db.accountingrepository.Delete(id); db.Save(); Filter(); } } } }
private void BtnDelete_Click(object sender, EventArgs e) { if (MydataGridView.CurrentRow != null) { using (UnitofWork db = new UnitofWork()) { string name = MydataGridView.CurrentRow.Cells[1].Value.ToString(); if (RtlMessageBox.Show($"ایا از حذف {name} مطمئن هستید؟", "توجه", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { int customerId = int.Parse(MydataGridView.CurrentRow.Cells[0].Value.ToString()); db.CustomerRepository.DeleteCustomer(customerId); db.Save(); Bindgrid(); } } } else { RtlMessageBox.Show("لطفا شخص مورد نظر را انتخاب کنید"); } }