private void btn_sua_Click(object sender, EventArgs e) { category ctgr = new category(); try { if (CheckValidate() == true) { bool confirm = Util.Show_Message_YesNo(Message.msg_notification, "Chắc chắn sửa ?"); if (confirm) { ctgr.Name = txt_name_category.Text.Trim(); ctgr.Note = txt_Note.Text.Trim(); ctgr.UpdatedAt = DateTime.Now; ctgr.id = _ID_CATEGORY; bool check = DAL_QLCategory.Add_and_Edit_Category(ctgr, Variable.action_status.is_update, _user); if (check == true) { Util.Show_Message_Notification(Message.msg_notification, Message.msg_success_edit_data); ((Form)this.TopLevelControl).Close(); } else { Util.Show_Message_Error(Message.msg_error, Message.msg_error_edit_data); } } } } catch (Exception ex) { Util.Show_Message_Error(Message.msg_error, ex.Message.ToString()); } }
private void btn_sua_Click(object sender, EventArgs e) { user ctgr = new user(); try { if (CheckValidate() == true) { if (Util.Show_Message_YesNo(Message.msg_notification, "Chắc chắn sửa")) { { //ctgr.UserName = txt_name_category.Text.Trim(); if (txt_password_user.Text.ToString().Trim() != "") { ctgr.PassWord = txt_password_user.Text.Trim(); } ctgr.FullName = txt_fullname.Text.Trim(); ctgr.PhoneNumber = txt_phone_user.Text.Trim(); ctgr.Address = txt_address_user.Text.Trim(); ctgr.Note = txt_Note.Text.Trim(); ctgr.BirthDay = DateTime.Parse(birthDay_user.Text.Trim()); ctgr.Sex = (bool)radio_sex_user.EditValue; ctgr.Type = (string)radio_type_user.EditValue; ctgr.IdCard = txt_idCard_user.Text.Trim(); ctgr.UpdatedAt = DateTime.Now; ctgr.id = _ID_USER; bool check = DAL_QLUser.Add_and_Edit_User(ctgr, Variable.action_status.is_update); if (check == true) { Util.Show_Message_Notification(Message.msg_notification, Message.msg_success_edit_data); ((Form)this.TopLevelControl).Close(); } else { Util.Show_Message_Error(Message.msg_error, Message.msg_error_edit_data); } } } } } catch (Exception ex) { Util.Show_Message_Error(Message.msg_error, ex.Message.ToString()); } }
private void btn_update_Click(object sender, EventArgs e) { try { if (CheckValidate()) { if (Util.Show_Message_YesNo(Message.msg_notification, "Chắc chắn sửa ?")) { DataTable datasource = (DataTable)grcFriend.DataSource; List <Model.Friend> list_friend = datasource.AsEnumerable() .Select(m => new Model.Friend() { PhoneNumber = m.Field <string>("PhoneNumber"), FullName = m.Field <string>("FullName"), Relationship = m.Field <string>("Relationship"), Note = m.Field <string>("Note"), Id = m.Field <int>("Id") }).ToList(); int count = 0; foreach (var friend in list_friend) { friend friends = new friend(); friends.FullName = friend.FullName; friends.PhoneNumber = friend.PhoneNumber; friends.Relationship = friend.Relationship; friends.Note = friend.Note; friends.UpdatedBy = _user.id; friends.id = friend.Id; bool check = DAL_QLFriend.Add_and_Edit_Friend(friends, Variable.action_status.is_update); if (check) { count++; } else { Util.Show_Message_Error(Message.msg_error, Message.msg_error_edit_data); ((Form)this.TopLevelControl).Close(); break; } if (count == list_friend.Count) { Util.Show_Message_Notification(Message.msg_notification, Message.msg_success_edit_data); ((Form)this.TopLevelControl).Close(); } } } } } catch (Exception) { Util.Show_Message_Notification(Message.msg_notification, "Có lỗi xảy ra"); } }
private void btn_sua_Click(object sender, EventArgs e) { try { customer Customer = new customer(); if (CheckValidate()) { if (Util.Show_Message_YesNo(Message.msg_notification, "Chắc chắn sửa ?")) { { Customer.Address = txt_edit_address.Text.ToString().Trim(); Customer.BirthDay = DateTime.Parse(birthDay_customer.Text.ToString().Trim()); Customer.FullName = txt_edit_fullname.Text.ToString().Trim(); Customer.IdCard = txt_edit_idcard.Text.ToString().Trim(); Customer.PhoneNumber = txt_edit_phone.Text.ToString().Trim(); Customer.Sex = (bool)radio_edit_sex.EditValue; Customer.FamilyPhoneNumber = txt_edit_familyphone.Text.ToString().Trim(); Customer.CategoryId = int.Parse(cbb_category.EditValue.ToString()); Customer.Money = Convert.ToInt32(txt_money.Text.ToString().Trim().Replace(",", "")); Customer.Note = txt_edit_note.Text.ToString().Trim(); Customer.id = _ID_CUSTOMER; Customer.cycle = Convert.ToInt32(txt_cycle.Value); bool check = DAL_QLCustomer.Add_and_Edit_Customer(Customer, new List <Model.Friend>(), Variable.action_status.is_update, _user); if (check == true) { Util.Show_Message_Notification(Message.msg_notification, Message.msg_success_edit_data); ((Form)this.TopLevelControl).Close(); } else { Util.Show_Message_Error(Message.msg_error, Message.msg_error_edit_data); } } } } } catch (Exception ex) { Util.Show_Message_Error(Message.msg_error, ex.Message.ToString()); } }
private void btn_add_interest_Click(object sender, EventArgs e) { try { historyInterestRate historyInterest = new historyInterestRate(); if (CheckValidate() == true) { if (Util.Show_Message_YesNo(Message.msg_notification, "Chắc chắn muốn thêm ?")) { { historyInterest.Percents = Double.Parse(txt_percent.Text.Trim().Replace(".", ",")); historyInterest.Note = txt_ghi_chu.Text.Trim(); historyInterest.CreatedAt = DateTime.Now; historyInterest.UpdatedAt = DateTime.Now; historyInterest.Status = true; historyInterest.StartDate = DateTime.Parse(date_start.Text.ToString().Trim()); bool check = DAL_QLLaiSuat.Add_and_Edit_HistoryInterest(historyInterest, Variable.action_status.is_add, _user); if (check == true) { Util.Show_Message_Notification(Message.msg_notification, Message.msg_success_add_data); Load_Data(); } else { Util.Show_Message_Error(Message.msg_error, Message.msg_error_add_data); } restartFormAddInterest(); } } } } catch (Exception ex) { throw ex; } }
private void btn_add_category_Click(object sender, EventArgs e) { category ctgr = new category(); try { if (CheckValidate() == true) { bool confirm = Util.Show_Message_YesNo(Message.msg_notification, "Thêm danh mục ?"); if (confirm) { ctgr.Name = txt_name_category.Text.Trim(); ctgr.Note = txt_ghi_chu.Text.Trim(); ctgr.CreatedAt = DateTime.Now; ctgr.UpdatedAt = DateTime.Now; ctgr.Status = true; bool check = DAL_QLCategory.Add_and_Edit_Category(ctgr, Variable.action_status.is_add, _user); if (check == true) { Util.Show_Message_Notification(Message.msg_notification, Message.msg_success_add_data); Load_Data(); } else { Util.Show_Message_Error(Message.msg_error, Message.msg_error_add_data); } } restart_form_add_category(); } } catch (Exception ex) { Util.Show_Message_Error(Message.msg_error, ex.Message.ToString()); } }
private void btn_change_password_Click(object sender, EventArgs e) { try { if (CheckValidate()) { bool confirm = Util.Show_Message_YesNo(Message.msg_notification, "Chắc chắn đổi mật khẩu ?"); if (confirm) { bool check_change = DAL_QLUser.ChangePassword(_user, txt_new_password.Text); if (check_change) { this.DialogResult = DialogResult.OK; Util.Show_Message_Notification(Message.msg_notification, "Đổi mật khẩu thành công"); ((Form)this.TopLevelControl).Close(); } } } } catch (Exception) { Util.Show_Message_Notification(Message.msg_notification, "Đổi mật khẩu thất bại, thử lại sau"); } }
private void btn_thanh_toan_Click(object sender, EventArgs e) { bool check = false, checkTienLai = false, checkTienGoc = false; try { if (CheckValidate()) { bool confirmPaid = Util.Show_Message_YesNo(Message.msg_notification, "Chắc chắn thanh toán ?"); if (confirmPaid) { if (_isTienlai) { historyPaid paid = new historyPaid(); paid.Money = Convert.ToInt32(txt_money_lai.Text.ToString().Trim().Replace(",", "")); paid.TypePaid = "1"; paid.CustomerId = idCustomer; paid.CreatedAt = DateTime.Now; paid.UpdatedAt = DateTime.Now; paid.UpdatedBy = _user.id; paid.CreatedBy = _user.id; paid.Status = true; paid.PaidDate = DateTime.Now; checkTienLai = DAL_LichSuTraTien.Add_Paid_Money(paid, Variable.action_status.is_add, _user); } if (_isTiengoc) { historyPaid paid = new historyPaid(); paid.Money = Convert.ToInt32(txt_money.Text.ToString().Trim().Replace(",", "")); paid.TypePaid = "0"; paid.CustomerId = idCustomer; paid.CreatedAt = DateTime.Now; paid.UpdatedAt = DateTime.Now; paid.UpdatedBy = _user.id; paid.CreatedBy = _user.id; paid.Status = true; paid.PaidDate = DateTime.Now; checkTienGoc = DAL_LichSuTraTien.Add_Paid_Money(paid, Variable.action_status.is_add, _user); } if (_isTienlai && _isTiengoc) { if (checkTienGoc && checkTienLai) { check = true; } } else if (_isTiengoc) { if (checkTienGoc) { check = true; } } else if (_isTienlai) { if (checkTienLai) { check = true; } } if (check) { Util.Show_Message_Notification(Message.msg_notification, "Thanh toán thành công !!!"); ((Form)this.TopLevelControl).Close(); } } } } catch (Exception) { throw; } }