private void busttonNewOfficer_Click(object sender, RoutedEventArgs e) { if (buttonNewOfficer.Content.ToString() == "Register new VIPClient") { CUSTOMER cust = new CUSTOMER(); cust.ADDRESS = textBoxAddressClient.Text; cust.CITY = textBoxCityClient.Text; cust.FED_ID = textBoxFedClient.Text; cust.POSTAL_CODE = textBoxPostalCodeClient.Text; cust.STATE = BankView.db.BRANCH.Where(x => x.BRANCH_ID == bank.Select).Select(y => y.STATE).FirstOrDefault(); cust.CUST_TYPE_CD = "I"; BankView.db.CUSTOMER.InsertOnSubmit(cust); BankView.db.SubmitChanges(); OFFICER offi = new OFFICER(); offi.FIRST_NAME = textBoxFirstClient.Text; offi.LAST_NAME = textBoxLastClient.Text; offi.CUST_ID = cust.CUST_ID; BankView.db.OFFICER.InsertOnSubmit(offi); BankView.db.SubmitChanges(); listBoxUser.ItemsSource = null; listBoxUser.ItemsSource = BankView.db.CUSTOMER.Where(x => x.CUST_TYPE_CD == "B"); } else if (buttonNewOfficer.Content.ToString() == "Save changed data") { BankView.db.SubmitChanges(); } }
protected void Button1_Click(object sender, EventArgs e) { if (checkdata() == true) { if (validatedata() == true) { Label7.Visible = false; OFFICER newofficer = new OFFICER(); newofficer.rank = DropDownList1.SelectedValue; newofficer.O_name = textbox1.Text; newofficer.weapon_id = int.Parse(DropDownList2.SelectedValue); newofficer.olde = int.Parse(textbox4.Text); newofficer.address = textbox2.Text; newofficer.telephone = textbox3.Text; newofficer.job_id = int.Parse(DropDownList3.SelectedValue); entities.OFFICERs.Add(newofficer); entities.SaveChanges(); Response.Redirect("OFFICERS.aspx"); } else { Label7.Visible = true; } } else { Label7.Visible = true; } }
/* public ObservableCollection<CUSTOMER> UpdateListview() * { * List<EMPLOYEE> listp = CustomerDao.Instance().getAll(); * * ObservableCollection<CUSTOMER> result = new ObservableCollection<CUSTOMER>(); * foreach (EMPLOYEE p in listp) * { * CUSTOMER pv = new CUSTOMER(p); * result.Add(pv); * } * return result; * * } */ private void SelectedItem(CUSTOMER p) { ResetView(); OFFICER of = OfficerDao.Instance().SelectbyCustId(p.CUST_ID); BUSINESS bu = BusinessDao.Instance().SelectbyId(p.CUST_ID); INDIVIDUAL ind = IndividualDao.Instance().SelectbyId(p.CUST_ID); if (ind != null) { In_lastname = ind.LAST_NAME; In_firstname = ind.FIRST_NAME; In_birthdate = ind.BIRTH_DATE.ToString(); } if (of != null) { Of_lastname = of.LAST_NAME; Of_firstname = of.FIRST_NAME; Of_title = of.TITLE; Of_startdate = of.START_DATE.ToString(); Of_enddate = of.END_DATE.ToString(); } if (bu != null) { Bu_name = bu.NAME; Bu_stateid = bu.STATE_ID; Bu_incorpdate = bu.INCORP_DATE.ToString(); } }
private void Find(FrameworkElement p) { string id = ""; if (p != null) { var fe = p as Grid; if (fe != null) { foreach (var item in fe.Children) { var tx = item as TextBox; if (tx != null) { if (tx.Name.Equals("txtSearch")) { id = tx.Text; } } } } } if (!string.IsNullOrEmpty(id)) { String key = id.ToLower(); ObservableCollection <CUSTOMER> result = new ObservableCollection <CUSTOMER>(); foreach (CUSTOMER c in CustomerLists) { OFFICER of = OfficerDao.Instance().SelectbyCustId(c.CUST_ID); BUSINESS bu = BusinessDao.Instance().SelectbyId(c.CUST_ID); INDIVIDUAL ind = IndividualDao.Instance().SelectbyId(c.CUST_ID); String temp = c.CUST_ID.ToString() + " " + c.ADDRESS + " " + c.CITY + " " + c.FED_ID + " " + c.POSTAL_CODE + " " + c.STATE + " "; if (of != null && bu != null) { temp += of.FIRST_NAME + " " + of.LAST_NAME + " " + of.OFFICER_ID + " " + of.TITLE + " " + of.START_DATE.ToString() + " " + of.END_DATE.ToString() + " " + bu.NAME + " " + bu.STATE_ID + " " + bu.INCORP_DATE.ToString() + " "; } if (ind != null) { temp += ind.LAST_NAME + " " + ind.FIRST_NAME + " " + ind.BIRTH_DATE.ToString(); } temp.ToLower(); if (temp.Contains(key)) { result.Add(c); } } CustomerLists = result; } else { CustomerLists = new ObservableCollection <CUSTOMER>(CustomerDao.Instance().getAll()); } }
private void btnOK_Click(object sender, RoutedEventArgs e) { if (txtCustType == null || txtFedID == null || txtFirstname == null || txtLastname == null || StartDate == null) { MessageBox.Show("Bạn không được để trống họ ,tên, ngày bắt đầu, FED ID và loại khách"); } else { OFFICER o = new OFFICER(); CustomerDao cd = new CustomerDao(); CUSTOMER cus = new CUSTOMER(); OfficerDao od = new OfficerDao(); // //set data cho Customer cus.ADDRESS = txtAdress.Text; cus.CITY = txtCity.Text; cus.CUST_TYPE_CD = txtCustType.Text; cus.POSTAL_CODE = txtPostcode.Text; cus.STATE = txtState.Text; cus.FED_ID = txtFedID.Text; cus.CUST_ID = int.Parse(txtCustID.Text); // //set data cho Officer o.OFFICER_ID = int.Parse(txtOfficerID.Text); o.LAST_NAME = txtLastname.Text; o.FIRST_NAME = txtFirstname.Text; o.START_DATE = Convert.ToDateTime(StartDate.Text); o.END_DATE = Convert.ToDateTime(DateEnd.Text); o.TITLE = txtTitle.Text; o.CUST_ID = int.Parse(txtCustID.Text); if (DateEnd == null) { o.END_DATE = null; } else { o.END_DATE = Convert.ToDateTime(DateEnd.Text); } // if (cv == "insert") { cd.Insert(cus); od.Insert(o); } else { cd.Update(cus); od.Update(o); } this.Close(); ol.UpdateDatagrid(); } }
protected void Button1_Click(object sender, EventArgs e) { OFFICER editofficer = entities.OFFICERs.Find(id); editofficer.rank = accountType.SelectedValue.ToString(); editofficer.O_name = TextBox1.Text; editofficer.address = TextBox2.Text; editofficer.telephone = TextBox3.Text; editofficer.job_id = int.Parse(joblist.SelectedValue); editofficer.weapon_id = int.Parse(weaponlist.SelectedValue); entities.SaveChanges(); Response.Redirect("OFFICERS.aspx"); }
private void btnUpdate_Click(object sender, RoutedEventArgs e) { OFFICER row = grofficer.SelectedItem as OFFICER; if (row == null) { MessageBox.Show("Bạn chưa chọn nhân viên nào!", "Thông báo"); } else { new OfficerEdit(row, this).Show(); } }
private void btnDelete_Click(object sender, RoutedEventArgs e) { OFFICER row = grofficer.SelectedItem as OFFICER; if (row == null) { MessageBox.Show("Bạn chưa chọn nhân viên nào!", "Thông báo"); } else { OfficerDao od = new OfficerDao(); CustomerDao cd = new CustomerDao(); od.Delete(row.OFFICER_ID); cd.Delete(row.CUST_ID); UpdateDatagrid(); } }
public AccountView(ACCOUNT a) { this.id = a.ACCOUNT_ID; this.avail_balance = a.AVAIL_BALANCE; this.close_date = a.CLOSE_DATE; this.last_date = a.LAST_ACTIVITY_DATE; this.open_date = a.OPEN_DATE; this.pending_balance = a.PENDING_BALANCE; this.status = a.STATUS; this.branch = BranchDao.Instance().SelectbyId(a.OPEN_BRANCH_ID).NAME; this.employee = EmployeeDao.Instance().SelectbyId(a.OPEN_EMP_ID); this.NameEm = employee.FIRST_NAME + " " + employee.LAST_NAME; this.product = ProductDao.Instance().SelectbyId(a.PRODUCT_CD).NAME; this.customer = CustomerDao.Instance().SelectbyId(a.CUST_ID); if (customer.CUST_TYPE_CD == "I") { INDIVIDUAL ind = IndividualDao.Instance().SelectbyId(a.CUST_ID); if (ind == null) { this.NameCus = ""; } else { this.NameCus = ind.FIRST_NAME + " " + ind.LAST_NAME; } } else { OFFICER off = OfficerDao.Instance().SelectbyCustId(a.CUST_ID); if (off == null) { this.NameCus = ""; } else { this.NameCus = off.FIRST_NAME + " " + off.LAST_NAME; } } }
public OfficerEdit(OFFICER o, OfficerList ol) { InitializeComponent(); this.cv = "update"; this.ol = ol; CustomerDao cd = new CustomerDao(); CUSTOMER cus = new CUSTOMER(); cus = cd.SelectbyId(o.CUST_ID); txtAdress.Text = cus.ADDRESS; txtCity.Text = cus.CITY; txtCustType.Text = cus.CUST_TYPE_CD; txtFedID.Text = cus.FED_ID; txtPostcode.Text = cus.POSTAL_CODE; txtState.Text = cus.STATE; txtFirstname.Text = o.FIRST_NAME; txtLastname.Text = o.LAST_NAME; txtTitle.Text = o.TITLE; DateEnd.Text = o.END_DATE.ToString(); StartDate.Text = o.START_DATE.ToString(); txtOfficerID.Text = o.OFFICER_ID.ToString(); txtCustID.Text = o.CUST_ID.ToString(); }
private void OKevent(Window p) { if (validate_customer() == true) { CUSTOMER cus = new CUSTOMER(); cus.ADDRESS = Cus_address; cus.CITY = Cus_city; cus.CUST_TYPE_CD = Cus_custype; cus.FED_ID = Cus_fedid; cus.POSTAL_CODE = Cus_postalcode; cus.STATE = Cus_state; if (cv == "insert") { CustomerDao.Instance().Insert(cus); off = new OFFICER(); ind = new INDIVIDUAL(); bus = new BUSINESS(); int last_cus = CustomerDao.Instance().LastCUST().CUST_ID; off.CUST_ID = last_cus; ind.CUST_ID = last_cus; bus.CUST_ID = last_cus; if (Cus_custype == "I") { if (validate_individual() == true) { if (In_birthdate.Equals("")) { ind.BIRTH_DATE = null; } else { ind.BIRTH_DATE = Convert.ToDateTime(In_birthdate); } ind.FIRST_NAME = In_firstname; ind.LAST_NAME = In_lastname; IndividualDao.Instance().Insert(ind); } else { MessageBox.Show("Bạn điền thiếu thông tin Individual!", "Thông báo"); } } else { if (validate_officer() == true && validate_business() == true) { bus.NAME = Bu_name; bus.STATE_ID = Bu_stateid; if (Bu_incorpdate.Equals("")) { bus.INCORP_DATE = null; } else { bus.INCORP_DATE = Convert.ToDateTime(Bu_incorpdate); } off.LAST_NAME = Of_lastname; off.FIRST_NAME = Of_firstname; off.TITLE = Of_title; off.START_DATE = Convert.ToDateTime(Of_startdate); if (Of_enddate.Equals("")) { bus.INCORP_DATE = null; } else { off.END_DATE = Convert.ToDateTime(Of_enddate); } OfficerDao.Instance().Insert(off); BusinessDao.Instance().Insert(bus); } else { MessageBox.Show("Bạn điền thiếu thông tin Officer và Business!", "Thông báo"); } } } else { cus.CUST_ID = custid; if (Cus_custype == "I") { if (validate_individual() == true) { if (In_birthdate.Equals("")) { ind.BIRTH_DATE = null; } else { ind.BIRTH_DATE = Convert.ToDateTime(In_birthdate); } ind.FIRST_NAME = In_firstname; ind.LAST_NAME = In_lastname; CustomerDao.Instance().Update(cus); IndividualDao.Instance().Update(ind); } else { MessageBox.Show("Bạn điền thiếu thông tin Individual!", "Thông báo"); } } else { if (validate_officer() == true && validate_business() == true) { bus.NAME = Bu_name; bus.STATE_ID = Bu_stateid; if (Bu_incorpdate.Equals("")) { bus.INCORP_DATE = null; } else { bus.INCORP_DATE = Convert.ToDateTime(Bu_incorpdate); } off.LAST_NAME = Of_lastname; off.FIRST_NAME = Of_firstname; off.TITLE = Of_title; off.START_DATE = Convert.ToDateTime(Of_startdate); if (Of_enddate.Equals("")) { bus.INCORP_DATE = null; } else { off.END_DATE = Convert.ToDateTime(Of_enddate); } CustomerDao.Instance().Update(cus); OfficerDao.Instance().Update(off); BusinessDao.Instance().Update(bus); } else { MessageBox.Show("Bạn điền thiếu thông tin Officer và Business!", "Thông báo"); } } } p.Close(); vm.CustomerLists = new ObservableCollection <CUSTOMER>(CustomerDao.Instance().getAll()); } else { MessageBox.Show("Customer:Bạn điền thiếu thông tin!", "Thông báo"); } }
public CustomerEditVM(CUSTOMER c, CustomerVM vm) { if (c == null) { this.In_firstname = ""; this.In_lastname = ""; this.In_birthdate = ""; this.Bu_name = ""; this.Bu_stateid = ""; this.Bu_incorpdate = ""; this.Of_enddate = ""; this.Of_firstname = ""; this.Of_startdate = ""; this.Of_title = ""; this.Of_lastname = ""; this.Cus_address = ""; this.Cus_city = ""; this.Cus_custype = ""; this.Cus_postalcode = ""; this.Cus_fedid = ""; this.Cus_state = ""; this.cv = "insert"; } else { ind = IndividualDao.Instance().SelectbyId(c.CUST_ID); bus = BusinessDao.Instance().SelectbyId(c.CUST_ID); off = OfficerDao.Instance().SelectbyCustId(c.CUST_ID); if (ind != null) { In_lastname = ind.LAST_NAME; In_firstname = ind.FIRST_NAME; In_birthdate = ind.BIRTH_DATE.ToString(); } if (off != null && bus != null) { Of_lastname = off.LAST_NAME; Of_firstname = off.FIRST_NAME; Of_title = off.TITLE; Of_startdate = off.START_DATE.ToString(); Of_enddate = off.END_DATE.ToString(); Bu_name = bus.NAME; Bu_stateid = bus.STATE_ID; Bu_incorpdate = bus.INCORP_DATE.ToString(); } this.Cus_address = c.ADDRESS; this.Cus_city = c.CITY; this.Cus_custype = c.CUST_TYPE_CD; this.Cus_postalcode = c.POSTAL_CODE; this.Cus_fedid = c.FED_ID; this.Cus_state = c.STATE; this.cv = "update"; this.custid = c.CUST_ID; } this.vm = vm; OKCommand = new RelayCommand <Window>((p) => { return(p != null ? true : false); }, (p) => { OKevent(p); }); CancelCommand = new RelayCommand <Window>((p) => true, (p) => { p.Close(); }); }
private void buttonAddProduct_Click(object sender, RoutedEventArgs e)//Добавить кредит - погасить { int cust_id = -1; CUSTOMER cust = null; OFFICER offi = null; if (textBoxCost.Text.All(x => !char.IsDigit(x)) && comboBoxClientOptions.SelectedIndex != -1 && comboBoxEmployee.SelectedIndex != -1) { MessageBox.Show("Сумма введена не верно!"); return; } if (listBoxUser.SelectedItem is CUSTOMER) { cust = (CUSTOMER)listBoxUser.SelectedItem; cust_id = cust.CUST_ID; } else if (listBoxUser.SelectedItem is OFFICER) { offi = (OFFICER)listBoxUser.SelectedItem; cust_id = (int)BankView.db.OFFICER.Where(x => x.OFFICER_ID == offi.OFFICER_ID).Select(y => y.CUST_ID).FirstOrDefault(); } if (cust_id != -1) { ACCOUNT acc = new ACCOUNT(); if (buttonAddProduct.Content.ToString() == "Оформить") { acc.AVAIL_BALANCE = double.Parse(textBoxCost.Text); acc.OPEN_BRANCH_ID = bank.Select; acc.OPEN_DATE = DateTime.Now; if (comboBoxClientOptions.SelectedItem.ToString() == "Insurance Offerings") { acc.PENDING_BALANCE = double.Parse(textBoxCost.Text) * 5; } else { acc.PENDING_BALANCE = double.Parse(textBoxCost.Text); } acc.PRODUCT_CD = BankView.db.PRODUCT.Where(x => x.NAME == comboBoxClientOptions.SelectedItem.ToString()).Select(y => y.PRODUCT_CD).FirstOrDefault(); acc.CUST_ID = cust_id; acc.OPEN_EMP_ID = BankView.db.EMPLOYEE.Where(x => x.FIRST_NAME + " " + x.LAST_NAME == comboBoxEmployee.SelectedItem.ToString()).Select(y => y.EMP_ID).FirstOrDefault(); acc.STATUS = "ACTIVE"; BankView.db.ACCOUNT.InsertOnSubmit(acc); BankView.db.SubmitChanges(); comboBoxClientOptions.SelectedIndex = -1; //listBoxProductName.ItemsSource = BankView.db.ACCOUNT.Where(x => x.CUST_ID == cust_id).Select(y => y.PRODUCT.NAME); //listBoxProductName.ItemsSource = BankView.db.ACCOUNT.Where(x => x.CUST_ID == cust_id); } else if (buttonAddProduct.Content.ToString() == "Погасить/Положить") { acc = cust == null ? (ACCOUNT)listBoxProductNameVIP.SelectedItem : (ACCOUNT)listBoxProductName.SelectedItem; string product_type = BankView.db.PRODUCT.Where(x => x.PRODUCT_CD == acc.PRODUCT_CD).Select(y => y.PRODUCT_TYPE_CD).FirstOrDefault(); double pending_balance = (double)acc.PENDING_BALANCE; double cost = double.Parse(textBoxCost.Text); ACC_TRANSACTION transaction = new ACC_TRANSACTION(); transaction.ACCOUNT_ID = acc.ACCOUNT_ID; transaction.EXECUTION_BRANCH_ID = bank.Select; transaction.TELLER_EMP_ID = BankView.db.EMPLOYEE.Where(x => x.FIRST_NAME + " " + x.LAST_NAME == comboBoxEmployee.SelectedItem.ToString()).Select(y => y.EMP_ID).FirstOrDefault(); transaction.AMOUNT = cost; transaction.TXN_DATE = DateTime.Now; transaction.FUNDS_AVAIL_DATE = DateTime.Now; transaction.TXN_TYPE_CD = "CDT"; if (product_type == "ACCOUNT") //Счета { acc.PENDING_BALANCE += cost; acc.AVAIL_BALANCE += cost; BankView.db.ACC_TRANSACTION.InsertOnSubmit(transaction); BankView.db.SubmitChanges(); } else if (product_type == "LOAN") //Кредит-лизинг { if (pending_balance - cost > 0) { acc.PENDING_BALANCE -= cost; BankView.db.ACC_TRANSACTION.InsertOnSubmit(transaction); BankView.db.SubmitChanges(); } else { acc.CLOSE_DATE = DateTime.Now; acc.STATUS = "CLOSE"; BankView.db.SubmitChanges(); } } } if (cust == null) { listBoxProductNameVIP.ItemsSource = null; listBoxProductNameVIP.ItemsSource = BankView.db.ACCOUNT.Where(x => x.CUST_ID == cust_id); } else { listBoxProductName.ItemsSource = null; listBoxProductName.ItemsSource = BankView.db.ACCOUNT.Where(x => x.CUST_ID == cust_id); } } textBoxCost.Text = ""; textBoxCost.IsEnabled = false; }