コード例 #1
0
        //选择销售管理标签时,自动加载相应的combobox选项,包括员工姓名和产品类别
        private void Manage_Sys_SelectedIndexChanged(object sender, EventArgs e)
        {
            //库存管理标签
            if (this.Manage_Sys.SelectedIndex == 1)
            {
                DataSet ds         = new DataSet();
                String  cmdProSort = "select distinct Pro_Sort from db_Product";
                ds = allOperate.getDS(cmdProSort);


                //使用SelectedValueChanged方法要将数据源的绑定放在DisplayMember和ValueMember前面;
                //使用SelectedIndexChanged方法要将数据源的绑定放在DisplayMember和ValueMember后面;

                SortCombobox.DataSource    = ds.Tables[0];
                SortCombobox.DisplayMember = "Pro_Sort";
                SortCombobox.ValueMember   = "Pro_Sort";
                SortCombobox.Text          = "请选择";
            }



            //销售记录标签
            if (this.Manage_Sys.SelectedIndex == 2)
            {
                DataSet ds = new DataSet();
                String  cmdEmployeeName = "select * from db_Employee";
                ds = allOperate.getDS(cmdEmployeeName);

                employeeName.DataSource    = ds.Tables[0];
                employeeName.DisplayMember = "EmployeeName";
                employeeName.ValueMember   = "EmployeeName";
                employeeName.Text          = "请选择";
                employeeID.Text            = "请选择";
                DatabaseOP operateDB = new DatabaseOP();
                String     sortStr   = "select distinct Pro_Sort from db_Product";
                DataSet    sortDS    = new DataSet();
                sortDS = operateDB.getDS(sortStr);
                saleProductSort.DataSource    = sortDS.Tables[0];
                saleProductSort.DisplayMember = "Pro_sort";
                saleProductSort.ValueMember   = "Pro_sort";
                saleProductSort.Text          = "请选择";
                saleProductType.Text          = "请选择";
            }
            //销售明细标签
            if (this.Manage_Sys.SelectedIndex == 5)
            {
                DataSet ds = new DataSet();
                String  cmdEmployeeName = "select * from db_Employee";

                ds = allOperate.getDS(cmdEmployeeName);

                viewEmployeeName.DataSource    = ds.Tables[0];
                viewEmployeeName.DisplayMember = "EmployeeName";
                viewEmployeeName.ValueMember   = "EmployeeName";
                //viewEmployeeID.DataSource = ds.Tables[0];
                //viewEmployeeID.DisplayMember = "EmployeeID";
                viewEmployeeName.Text = "请选择";
                viewEmployeeID.Text   = "请选择";
            }
        }
コード例 #2
0
        //产品类别发生变化时,自动加载相应的型号列表
        private void saleProductSort_SelectedValueChanged(object sender, EventArgs e)
        {
            DatabaseOP operateDB  = new DatabaseOP();
            String     sqlTypeStr = "select Pro_Type from db_Product where Pro_Sort = '" + saleProductSort.Text.Trim() + "';";
            DataSet    ds         = new DataSet();

            ds = operateDB.getDS(sqlTypeStr);
            saleProductType.DataSource    = ds.Tables[0];
            saleProductType.DisplayMember = "Pro_Type";
            saleProductType.Text          = "请选择";
        }
コード例 #3
0
        //当员工姓名发生变化时,自动查找相应的工号
        private void employeeName_SelectedValueChanged(object sender, EventArgs e)
        {
            DatabaseOP opDatabase = new DatabaseOP();

            DataSet ds            = new DataSet();
            String  cmdEmployeeID = "select * from db_Employee where EmployeeName = " + "'" + employeeName.SelectedValue.ToString() + "'";

            ds = opDatabase.getDS(cmdEmployeeID);

            employeeID.DataSource    = ds.Tables[0];
            employeeID.DisplayMember = "EmployeeID";
            //employeeID.Text = "请选择";
        }
コード例 #4
0
        //添加新产品
        private void addNewProduct_Click(object sender, EventArgs e)
        {
            DatabaseOP addPro  = new DatabaseOP();
            String     newSort = sortTextBox.Text.Trim();
            String     newType = typeTextBox.Text.Trim();

            addPro.addNewProduct(newSort, newType);
            DataSet ds = new DataSet();

            ds = addPro.getDS("select * from db_Product;");
            productDataGridView.DataSource = ds.Tables[0].DefaultView;
            sortTextBox.Clear();
            typeTextBox.Clear();
        }
コード例 #5
0
        //增加新员工
        private void btn_addNewEmployee_Click(object sender, EventArgs e)
        {
            DatabaseOP insertDB        = new DatabaseOP();
            String     newEmployeeName = newNameBox.Text.Trim();
            String     newEmployeeID   = newIDBox.Text.Trim();

            insertDB.insertData(newEmployeeName, newEmployeeID);
            String  employeeSelect = "select * from db_Employee";
            DataSet ds             = new DataSet();

            ds = insertDB.getDS(employeeSelect);
            employeeDataGridView.DataSource = ds.Tables[0].DefaultView;
            newNameBox.Clear();
            newIDBox.Clear();
        }
コード例 #6
0
        //当类别发生改变时,自动加载对应的型号
        private void SortClass_SelectedValueChanged(object sender, EventArgs e)
        {
            String cmdProType = "select * from db_Product where Pro_Sort = " + "'" + SortCombobox.SelectedValue.ToString() + "'";

            DataSet ds = new DataSet();

            ds = allOperate.getDS(cmdProType);

            TypeCombobox.DataSource = ds.Tables[0];

            TypeCombobox.DisplayMember = "Pro_Type";
            TypeCombobox.Text          = "请选择";
        }