コード例 #1
0
        private void btAdd_Click(object sender, EventArgs e)
        {
            Form custAddForm = new Form();

            custAddForm.Text = "Thêm khách hàng mới";
            CustomerUserControl custUserControl = new CustomerUserControl();

            custAddForm.Controls.Add(custUserControl);
            custAddForm.Width = custUserControl.Width;
            custAddForm.Show();
        }
コード例 #2
0
        private void viewCustomerTransactionHistory(object sender, EventArgs e)
        {
            DataGridViewRow row    = grvCustomer.Rows[currentMouseOverRow];
            string          custID = row.Cells[0].Value.ToString();

            JSManagementDataSet.CustomerDataTable custData = customerTableAdapter.GetDataByCustomerId(int.Parse(custID));

            if (custData.Rows.Count == 0)
            {
                return;
            }
            string custName    = custData[0].CustomerName;
            string custAddress = custData[0].Address;
            string custPhone   = custData[0].Telephone;
            string custNote    = custData[0].Note;

            Form custEditForm = new Form();

            custEditForm.Text = "Sửa thông tin khách hàng";

            CustomerUserControl custUserControl = new CustomerUserControl();
            TextBox             txtCustName     = custUserControl.Controls.Find("txtCustName", true)[0] as TextBox;
            TextBox             txtCustAddress  = custUserControl.Controls.Find("txtCustAddress", true)[0] as TextBox;
            TextBox             txtNote         = custUserControl.Controls.Find("txtNote", true)[0] as TextBox;
            TextBox             txtPhone        = custUserControl.Controls.Find("txtPhone", true)[0] as TextBox;
            Label    lbCustId             = custUserControl.Controls.Find("lbCustId", true)[0] as Label;
            Label    lbHeader             = custUserControl.Controls.Find("lbHeader", true)[0] as Label;
            ComboBox comboBoxCustomerType = custUserControl.Controls.Find("comboBoxCustomerType", true)[0] as ComboBox;

            comboBoxCustomerType.DataSource    = customerTypeTableAdapter.GetData();
            comboBoxCustomerType.DisplayMember = CUST_TYPE_NAME;
            comboBoxCustomerType.ValueMember   = CUST_TYPE_ID;

            lbCustId.Text       = custID;
            txtCustName.Text    = custName;
            txtCustAddress.Text = custAddress;
            txtPhone.Text       = custPhone;
            txtNote.Text        = custNote;
            comboBoxCustomerType.SelectedValue = custData[0].CustTypeId;
            lbHeader.Text = string.Format("Sửa thông tin khách hàng").ToUpper();

            custEditForm.Controls.Add(custUserControl);
            custEditForm.Width  = custUserControl.Width;
            custEditForm.Height = custUserControl.Height;
            custEditForm.Show();
        }
コード例 #3
0
        private void grvCustomer_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            DataGridViewRow row         = grvCustomer.Rows[e.RowIndex];
            string          custID      = row.Cells[0].Value.ToString();
            string          custName    = row.Cells[1].Value.ToString();
            string          custAddress = row.Cells[2].Value.ToString();
            string          custPhone   = row.Cells[3].Value.ToString();

            FormCollection fc       = Application.OpenForms;
            Form           mainform = new Form();

            foreach (Form f in fc)
            {
                if (f.Name == "productOutputForm")
                {
                    mainform = f;
                }
                if (f.Name == "productInputForm")
                {
                    mainform = f;
                }
            }


            if (mainform.Controls.Count > 0)
            {
                TextBox txtCustomerCode = mainform.Controls.Find("txtCustomerCode", true)[0] as TextBox;
                Label   lbCustomerInfo  = mainform.Controls.Find("lbCustomerInfo", true)[0] as Label;
                lbCustomerInfo.Text  = string.Format("{0}, {1}, {2}", custName, custAddress, custPhone);
                txtCustomerCode.Text = custID;
                Form custListForm = (Form)this.Parent;
                custListForm.Close();
            }
            else
            {
                Form custEditForm = new Form();
                custEditForm.Text = "Sửa thông tin khách hàng";

                CustomerUserControl custUserControl = new CustomerUserControl();
                TextBox             txtCustName     = custUserControl.Controls.Find("txtCustName", true)[0] as TextBox;
                TextBox             txtCustAddress  = custUserControl.Controls.Find("txtCustAddress", true)[0] as TextBox;
                TextBox             txtPhone        = custUserControl.Controls.Find("txtPhone", true)[0] as TextBox;
                Label lbCustId = custUserControl.Controls.Find("lbCustId", true)[0] as Label;
                Label lbHeader = custUserControl.Controls.Find("lbHeader", true)[0] as Label;

                txtCustName.Text    = custName;
                txtCustAddress.Text = custAddress;
                txtPhone.Text       = custPhone;
                lbCustId.Text       = custID;
                lbHeader.Text       = string.Format("Sửa thông tin khách hàng").ToUpper();

                custEditForm.Controls.Add(custUserControl);
                custEditForm.Width  = custUserControl.Width;
                custEditForm.Height = custUserControl.Height;
                custEditForm.Show();
            }
        }