Beispiel #1
0
        /*   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();
            }
        }
Beispiel #2
0
 private void btnOK_Click(object sender, RoutedEventArgs e)
 {
     if (txtCustID.Text.Equals("") || txtFirstname.Text.Equals("") || txtLastname.Text.Equals(""))
     {
         MessageBox.Show("Bạn không được để trống CustID hoặc Họ và Tên");
     }
     else
     {
         INDIVIDUAL    i  = new INDIVIDUAL();
         IndividualDao id = new IndividualDao();
         i.CUST_ID    = int.Parse(txtCustID.Text);
         i.LAST_NAME  = txtLastname.Text;
         i.FIRST_NAME = txtFirstname.Text;
         if (Birthdate.Text.Equals(""))
         {
             i.BIRTH_DATE = null;
         }
         else
         {
             i.BIRTH_DATE = Convert.ToDateTime(Birthdate.Text);
         }
         if (cv == "insert")
         {
             id.Insert(i);
         }
         else
         {
             id.Update(i);
         }
         this.Close();
         il.UpdateDatagrid();
     }
 }
Beispiel #3
0
        public List <INDIVIDUAL> Load()
        {
            List <INDIVIDUAL> list = new List <INDIVIDUAL>();
            IndividualDao     id   = new IndividualDao();

            list = id.getAll();
            return(list);
        }
Beispiel #4
0
        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());
            }
        }
Beispiel #5
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            INDIVIDUAL row = grindividual.SelectedItem as INDIVIDUAL;

            if (row == null)
            {
                MessageBox.Show("Bạn chưa chọn phòng nào", "Thông báo");
            }
            else
            {
                IndividualDao In = new IndividualDao();
                In.Delete(row.CUST_ID);
                UpdateDatagrid();
            }
        }
Beispiel #6
0
 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;
         }
     }
 }
Beispiel #7
0
        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");
            }
        }
Beispiel #8
0
        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(); });
        }