示例#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();
            }
        }
示例#2
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());
            }
        }
示例#3
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");
            }
        }
示例#4
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(); });
        }