Esempio n. 1
0
        private void btnDeleteCustomer_Click(object sender, EventArgs e)
        {
            //DataTable ExistEmployee = get_service.GetEmployeeInInvoiceTotal(txtEmpID.Text);
            //if (ExistEmployee.Rows.Count > 0)
            //{
            //    DialogResult t =
            //        MessBox2Choice.ShowBox("Nhân viên mà bạn xóa \nHiện không xóa được.\n Bạn có muốn xóa không", Color.YellowGreen);
            //    if (t.Equals(System.Windows.Forms.DialogResult.No))
            //        return;

            //}
            if (txtMaKH.Text == "101")
            {
                Alert.Show("Không thể xóa \nkhách hàng này !", Color.Red);
                return;
            }
            foreach (Persistence.CustomerSwipe o in swipeList)
            {
                get_service.DeleteCustSwipe(txtMaKH.Text, o.swipeId);
            }
            get_service.DeleteCustomer(txtMaKH.Text);
            Customers = get_service.GetAllCustomers();
            limit     = Customers.Rows.Count - 1;
            btnPrevious_Click(btnPrevious, null);
        }
Esempio n. 2
0
 public FrmCustomer()
 {
     InitializeComponent();
     get_service = new get_GUI();
     serviceGet  = new ServiceGet();
     Customers   = get_service.GetAllCustomers();
     txtMaxBalance.isKeyNumber = true;
 }
Esempio n. 3
0
        public FrmCustomer()
        {

            InitializeComponent();
            get_service = new get_GUI();
            serviceGet = new ServiceGet();
            Customers = get_service.GetAllCustomers();
            txtMaxBalance.isKeyNumber = true;
        }
Esempio n. 4
0
 private void btnExit_Click(object sender, EventArgs e)
 {
     if (btnExit.Text == "Hủy")
     {
         FirstState();
         Customers = get_service.GetAllCustomers();
         limit     = Customers.Rows.Count - 1;
         changeState(Customers, currentIndex);
     }
     else
     {
         this.Dispose();
     }
 }
Esempio n. 5
0
        private void changeState(Customer.CustomerDataTable customerDataTable, int rowindex)
        {
            if (customerDataTable.Rows.Count > 0)
            {
                var row = customerDataTable.Rows[rowindex] as Customer.CustomerRow;
                if (row != null)
                {
                    txtAddress.Text = row.IsAddress_1Null() ? "" : row.Address_1;

                    txtDateBirth.Text        = row.IsBirthdayNull() ? "" : String.Format("{0:d/M/yyyy}", row.Birthday);
                    txtDateCloseAccount.Text = row.IsAcct_Close_DateNull() ? "" : String.Format("{0:d/M/yyyy}", row.Acct_Close_Date);

                    txtDateCustomer.Text = row.IsCreateDateNull() ? "" : String.Format("{0:d/M/yyyy}", row.CreateDate);

                    txtDateOpenAccount.Text = row.IsAcct_Open_DateNull() ? "" : String.Format("{0:d/M/yyyy}", row.Acct_Open_Date);

                    txtDiscountPercent.Text = row.Discount_Percent.ToString();
                    txtEmail.Text           = row.IsEMailNull() ? "" : row.EMail;
                    txtMaKH.Text            = row.CustNum;
                    txtMaxBalance.Text      = row.IsAcct_Max_BalanceNull() ? "" : String.Format("{0:0,0}", row.Acct_Max_Balance);
                    txtMobilephone.Text     = row.IsPhone_1Null() ? "" : row.Phone_1;
                    lbCustName.Text         = txtName.Text = row.Last_Name;
                    txtNameCompany.Text     = row.IsCompanyNull() ? "" : row.Company;
                    txtTelephone.Text       = row.IsPhone_2Null() ? "" : row.Phone_2;
                    lblNumberOfAdd.Text     = row.IsAcct_BalanceNull() ? "" : String.Format("{0:0,0}", row.Acct_Balance);

                    // Swipe
                    listBox1.Items.Clear();
                    swipeList = serviceGet.GetCustSwipeById(row.CustNum);
                    foreach (Persistence.CustomerSwipe customerSwipe in swipeList)
                    {
                        listBox1.Items.Add(customerSwipe);
                    }
                }
            }
        }
Esempio n. 6
0
        private void btnDeleteCustomer_Click(object sender, EventArgs e)
        {
            //DataTable ExistEmployee = get_service.GetEmployeeInInvoiceTotal(txtEmpID.Text);
            //if (ExistEmployee.Rows.Count > 0)
            //{
            //    DialogResult t =
            //        MessBox2Choice.ShowBox("Nhân viên mà bạn xóa \nHiện không xóa được.\n Bạn có muốn xóa không", Color.YellowGreen);
            //    if (t.Equals(System.Windows.Forms.DialogResult.No))
            //        return;

            //}
            if(txtMaKH.Text == "101")
            {
                Alert.Show("Không thể xóa \nkhách hàng này !",Color.Red);
                return;
            }
            foreach (Persistence.CustomerSwipe o in swipeList)
            {
                get_service.DeleteCustSwipe(txtMaKH.Text,o.swipeId);
            }
            get_service.DeleteCustomer(txtMaKH.Text);
            Customers = get_service.GetAllCustomers();
            limit = Customers.Rows.Count - 1;
            btnPrevious_Click(btnPrevious, null);
        }
Esempio n. 7
0
        private void btnSaveCustomer_Click(object sender, EventArgs e)
        {
            if (txtMaKH.Text.Equals(""))
            {
                Alert.Show("Bạn phải nhập mã \nkhách hàng!", Color.Red);
                return;
            }
            //cmbCate.SelectedIndex = 0;
            //DataRowView item = (DataRowView)cmbDept.SelectedItem;
            //Customer.CustomerDataTable tmp = get_service.GetCustomerByID(txtMaKH.Text);
            //if (tmp.Rows.Count > 0)
            //{
            //    Alert.Show("Mã này đã tồn tại", Color.Red);
            //    return;
            //}

            DateTime dateTimeOpenAccount = DateTime.Now;
            DateTime dateTimeCloseAccount = DateTime.Now;
            DateTime dateTimeBirth = DateTime.Now;
            Decimal maxBalance = new decimal();
            if (!DateTime.TryParseExact(txtDateOpenAccount.Text, "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTimeOpenAccount))
            {
           
                Alert.Show("Bạn nhập sai kiểu ngày!", Color.Red);
                txtDateOpenAccount.Focus();
                return;
            }
            if (!DateTime.TryParseExact(txtDateCloseAccount.Text, "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTimeCloseAccount))
            {

                Alert.Show("Bạn nhập sai kiểu ngày!", Color.Red);
                txtDateCloseAccount.Focus();
                return;
            }
            if (!DateTime.TryParseExact(txtDateBirth.Text, "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTimeBirth))
            {

                Alert.Show("Bạn nhập sai kiểu ngày!", Color.Red);
                txtDateBirth.Focus();
                return;
            }
            if (!Decimal.TryParse(txtMaxBalance.Text, out maxBalance))
            {
                Alert.Show("Bạn nhập sai", Color.Red);
                txtMaxBalance.Focus();
                return;
            }
            get_service.UpdateCustomer(txtMaKH.Text, "", txtName.Text, txtNameCompany.Text, txtAddress.Text, "", "",
                                           "", "", txtTelephone.Text, txtMobilephone.Text,
                                           "", "", "", "", float.Parse(txtDiscountPercent.Text),
                                           dateTimeOpenAccount,
                                           dateTimeCloseAccount, (decimal?)0,
                                           Decimal.Parse(txtMaxBalance.Text),
                                           true, 0, true, null, true, "", "", txtEmail.Text, "VN", "", DateTime.Now, "",
                                           dateTimeBirth, null, null, true, null, null, "", null, null, "", true,
                                           null, null, "", txtAddress.Text, "", "", "", null, null, null,m_oldCusNum);

            updateCustSwipe(txtMaKH.Text);

            Customers = get_service.GetAllCustomers();
            ckb_Sua.Checked = false;
            btnSearch.Enabled = true;
            btnPrevious.Enabled = true;
            btnNext.Enabled = true;
            btnExit.Text = "Thoát";
            btnDeleteCustomer.Enabled = true;
            btnAddCustomer.Enabled = true;
            btnSaveCustomer.Enabled = false;
            ckb_Sua.Enabled = true;
            txtName.Enabled = true;
            txtMaKH.Enabled = true;
            this.Refresh();

        }
Esempio n. 8
0
 private void btnExit_Click(object sender, EventArgs e)
 {
     if (btnExit.Text == "Hủy")
     {
         FirstState();
         Customers = get_service.GetAllCustomers();
         limit = Customers.Rows.Count - 1;
         changeState(Customers, currentIndex);
     }
     else
     {
         this.Dispose();
     }
 }
Esempio n. 9
0
 public void DeleteCustomer(string customerID)
 {
     var customer = new Customer.CustomerDataTable();
     var customerTableAdapter = new CustomerTableAdapter();
     customerTableAdapter.Connection = DataProvider.ConnectionData(sr);
     int customer1 = customerTableAdapter.DeleteCustomer(customerID);
 }
Esempio n. 10
0
        public void UpdateCustomer(string CustNum, 
                    string First_Name, 
                    string Last_Name, 
                    string Company, 
                    string Address_1, 
                    string Address_2, 
                    string City, 
                    string State, 
                    string Zip_Code, 
                    string Phone_1, 
                    string Phone_2, 
                    string CC_Type, 
                    string CC_Num, 
                    string CC_Exp, 
                    string Discount_Level, 
                    float Discount_Percent, 
                    DateTime? Acct_Open_Date, 
                    DateTime? Acct_Close_Date, 
                    decimal? Acct_Balance, 
                    decimal? Acct_Max_Balance, 
                    bool Bonus_Plan_Member, 
                    int? Bonus_Points, 
                    bool Tax_Exempt, 
                    DateTime? Member_Exp, 
                    bool Dirty, 
                    string Phone_3, 
                    string Phone_4, 
                    string EMail, 
                    string County, 
                    string Def_SP, 
                    DateTime? CreateDate, 
                    string Referral, 
                    DateTime? Birthday, 
                    DateTime? Last_Birthday_Bonus, 
                    DateTime? Last_Visit, 
                    bool Require_PONum, 
                    int? Max_Charge_NumDays, 
                    decimal? Max_Charge_Amount, 
                    string License_Num, 
                    DateTime? ID_Last_Checked, 
                    DateTime? Next_Start_Date, 
                    string Checking_AcctNum, 
                    bool PrintNotes, 
                    short? Loyalty_Plan_ID, 
                    int? Tax_Rate_ID, 
                    string Bill_To_Name, 
                    string Contact_1, 
                    string Contact_2, 
                    string Terms, 
                    string Resale_Num, 
                    DateTime? Last_Coupon, 
                    short? Account_Type, 
                    bool? ChargeAtCost,
                    string original_CustNum)
        {
            var customer = new Customer.CustomerDataTable();
            var customerTableAdapter = new CustomerTableAdapter();
            customerTableAdapter.Connection = DataProvider.ConnectionData(sr);
            customerTableAdapter.UpdateCustomer(CustNum, First_Name, Last_Name, Company, Address_1, Address_2, City,
                                                State, Zip_Code, Phone_1, Phone_2, CC_Type,
                                                CC_Num, CC_Exp, Discount_Level, Discount_Percent, Acct_Open_Date,
                                                Acct_Close_Date, Acct_Balance, Acct_Max_Balance, Bonus_Plan_Member,
                                                Bonus_Points,
                                                Tax_Exempt, Member_Exp, Dirty, Phone_3, Phone_4, EMail, County, Def_SP,
                                                CreateDate, Referral, Birthday, Last_Birthday_Bonus, Last_Visit,
                                                Require_PONum,
                                                Max_Charge_NumDays, Max_Charge_Amount, License_Num, ID_Last_Checked,
                                                Next_Start_Date, Checking_AcctNum, PrintNotes, Loyalty_Plan_ID,
                                                Tax_Rate_ID,
                                                Bill_To_Name, Contact_1, Contact_2, Terms, Resale_Num, Last_Coupon,
                                                Account_Type, ChargeAtCost, original_CustNum);

        }
Esempio n. 11
0
 public Customer.CustomerDataTable GetCustomerByID(string id)
 {
     var customer = new Customer.CustomerDataTable();
     var customerTableAdapter = new CustomerTableAdapter();
     customerTableAdapter.Connection = DataProvider.ConnectionData(sr);
     customerTableAdapter.FillByCustomerID(customer, id);
     return customer;
 }
Esempio n. 12
0
 public Customer.CustomerDataTable GetAllCustomers()
 {
     var customer=new Customer.CustomerDataTable();
     var customerTableAdapter=new CustomerTableAdapter();
     customerTableAdapter.Connection = DataProvider.ConnectionData(sr);
     customerTableAdapter.Fill(customer);
     return customer;
 }
Esempio n. 13
0
        private void btnAddCustomer_Click(object sender, EventArgs e)
        {
            if (btnAddCustomer.Text.Equals("Lưu lại"))
            {
                if (txtMaKH.Text.Equals(""))
                {
                    Alert.Show("Bạn phải nhập mã \nkhách hàng!", Color.Red);
                    return;
                }
                //cmbCate.SelectedIndex = 0;
                //DataRowView item = (DataRowView)cmbDept.SelectedItem;
                Customer.CustomerDataTable tmp = get_service.GetCustomerByID(txtMaKH.Text);
                if (tmp.Rows.Count > 0)
                {
                    Alert.Show("Mã này đã tồn tại", Color.Red);
                    return;
                }

                DateTime dateTimeOpenAccount  = DateTime.Now;
                DateTime dateTimeCloseAccount = DateTime.Now;
                DateTime dateTimeBirth        = DateTime.Now;
                txtMaxBalance.Text = "0";
                Decimal maxBalance = new decimal();
                if (!DateTime.TryParseExact(txtDateOpenAccount.Text, "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTimeOpenAccount))
                {
                    Alert.Show("Ngày mở tài khoản\n không đúng!", Color.Red);
                    txtDateOpenAccount.Focus();
                    return;
                }
                if (!DateTime.TryParseExact(txtDateCloseAccount.Text, "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTimeCloseAccount))
                {
                    Alert.Show("Ngày đóng tài khoản\n không đúng!", Color.Red);
                    txtDateCloseAccount.Focus();
                    return;
                }
                if (!DateTime.TryParseExact(txtDateBirth.Text, "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTimeBirth))
                {
                    Alert.Show("Ngày sinh không đúng", Color.Red);
                    txtDateBirth.Focus();
                    return;
                }
                if (!Decimal.TryParse(txtMaxBalance.Text, out maxBalance))
                {
                    Alert.Show("Bạn nhập sai", Color.Red);
                    txtMaxBalance.Focus();
                    return;
                }
                get_service.CreateCustomer(txtMaKH.Text, "", txtName.Text, txtNameCompany.Text, txtAddress.Text, "", "",
                                           "", "", txtTelephone.Text, txtMobilephone.Text,
                                           "", "", "", "", float.Parse(txtDiscountPercent.Text),
                                           dateTimeOpenAccount, dateTimeCloseAccount, (decimal?)0,
                                           Decimal.Parse(txtMaxBalance.Text),
                                           true, 0, true, null, true, "", "", txtEmail.Text, "VN", "", DateTime.Now, "",
                                           dateTimeBirth, null, null, true, null, null, "", null, null, "", true,
                                           null, null, "", txtAddress.Text, "", "", "", null, null, null);

                updateCustSwipe(txtMaKH.Text);
                limit = Customers.Rows.Count - 1;
            }
            AddState(1);
        }
Esempio n. 14
0
        private void btnSaveCustomer_Click(object sender, EventArgs e)
        {
            if (txtMaKH.Text.Equals(""))
            {
                Alert.Show("Bạn phải nhập mã \nkhách hàng!", Color.Red);
                return;
            }
            //cmbCate.SelectedIndex = 0;
            //DataRowView item = (DataRowView)cmbDept.SelectedItem;
            //Customer.CustomerDataTable tmp = get_service.GetCustomerByID(txtMaKH.Text);
            //if (tmp.Rows.Count > 0)
            //{
            //    Alert.Show("Mã này đã tồn tại", Color.Red);
            //    return;
            //}

            DateTime dateTimeOpenAccount  = DateTime.Now;
            DateTime dateTimeCloseAccount = DateTime.Now;
            DateTime dateTimeBirth        = DateTime.Now;
            Decimal  maxBalance           = new decimal();

            if (!DateTime.TryParseExact(txtDateOpenAccount.Text, "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTimeOpenAccount))
            {
                Alert.Show("Bạn nhập sai kiểu ngày!", Color.Red);
                txtDateOpenAccount.Focus();
                return;
            }
            if (!DateTime.TryParseExact(txtDateCloseAccount.Text, "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTimeCloseAccount))
            {
                Alert.Show("Bạn nhập sai kiểu ngày!", Color.Red);
                txtDateCloseAccount.Focus();
                return;
            }
            if (!DateTime.TryParseExact(txtDateBirth.Text, "d/M/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTimeBirth))
            {
                Alert.Show("Bạn nhập sai kiểu ngày!", Color.Red);
                txtDateBirth.Focus();
                return;
            }
            if (!Decimal.TryParse(txtMaxBalance.Text, out maxBalance))
            {
                Alert.Show("Bạn nhập sai", Color.Red);
                txtMaxBalance.Focus();
                return;
            }
            get_service.UpdateCustomer(txtMaKH.Text, "", txtName.Text, txtNameCompany.Text, txtAddress.Text, "", "",
                                       "", "", txtTelephone.Text, txtMobilephone.Text,
                                       "", "", "", "", float.Parse(txtDiscountPercent.Text),
                                       dateTimeOpenAccount,
                                       dateTimeCloseAccount, (decimal?)0,
                                       Decimal.Parse(txtMaxBalance.Text),
                                       true, 0, true, null, true, "", "", txtEmail.Text, "VN", "", DateTime.Now, "",
                                       dateTimeBirth, null, null, true, null, null, "", null, null, "", true,
                                       null, null, "", txtAddress.Text, "", "", "", null, null, null, m_oldCusNum);

            updateCustSwipe(txtMaKH.Text);

            Customers                 = get_service.GetAllCustomers();
            ckb_Sua.Checked           = false;
            btnSearch.Enabled         = true;
            btnPrevious.Enabled       = true;
            btnNext.Enabled           = true;
            btnExit.Text              = "Thoát";
            btnDeleteCustomer.Enabled = true;
            btnAddCustomer.Enabled    = true;
            btnSaveCustomer.Enabled   = false;
            ckb_Sua.Enabled           = true;
            txtName.Enabled           = true;
            txtMaKH.Enabled           = true;
            this.Refresh();
        }