Exemplo n.º 1
0
        private void FormDepartment_Load(object sender, EventArgs e)
        {
            commUse.BuildTree(treeView1, null, "部门信息", "Department", "DepartmentID", "DepartmentName");

            this.txtDeptID.Enabled   = false;
            this.txtDeptName.Enabled = false;
            this.buttonSave.Enabled  = false;
        }
Exemplo n.º 2
0
 private void FormInvenType_Load(object sender, EventArgs e)
 {
     //权限
     commUse.CortrolButtonEnabled(btnAdd, this);
     commUse.CortrolButtonEnabled(btnAmend, this);
     commUse.CortrolButtonEnabled(btnDelete, this);
     //TreeView绑定到数据源
     commUse.BuildTree(tvInvenType, imageList1, "存货分类", "BSInvenType", "InvenTypeCode", "InvenTypeName");
 }
Exemplo n.º 3
0
 private void FormAssignRight_Load(object sender, EventArgs e)
 {
     //权限控制
     commUse.CortrolButtonEnabled(toolSave, this);
     //绑定到数据源
     commUse.BuildTree(tvOperator, imageList1, "操作员", "SYOperator Where IsAdmin <> '1'", "OperatorCode", "OperatorName");
     commUse.BuildTree(tvModule, imageList1, "功能模块", "INModule", "ModuleTag", "ModuleName");
     commUse.BindComboBox(dgvINRightInfo.Columns["RightTag"], "RightTag", "RightName", "Select RightTag,RightName From INRight", "INRight");
 }
Exemplo n.º 4
0
 private void FormBom_Load(object sender, EventArgs e)
 {
     //设置用户的操作权限
     commUse.CortrolButtonEnabled(toolAdd, this);
     commUse.CortrolButtonEnabled(toolAmend, this);
     commUse.CortrolButtonEnabled(toolDelete, this);
     //TreeView绑定到数据源,显示现有的母件
     commUse.BuildTree(tvInven, imageList1, "母件", "V_BomStruct", "InvenCode", "InvenName");
 }
Exemplo n.º 5
0
        private void FormCustomer_Load(object sender, EventArgs e)
        {
            commUse.BuildTree(treeView1, null, "客户信息", "Customer", "CustomerID", "CustomerName");

            this.txtCusID.Enabled   = false;
            this.txtCusName.Enabled = false;
            this.textBox1.Enabled   = false;
            this.textBox2.Enabled   = false;
            this.textBox3.Enabled   = false;
            this.buttonSave.Enabled = false;
        }
Exemplo n.º 6
0
 private void FormCustomerCourse_Load(object sender, EventArgs e)
 {
     //权限
     commUse.CortrolButtonEnabled(toolAdd, this);
     commUse.CortrolButtonEnabled(toolAmend, this);
     commUse.CortrolButtonEnabled(toolDelete, this);
     //dgvSell的DataGridViewComboBoxColumn绑定到数据源
     commUse.BindComboBox(dgvSell.Columns["CustomerCode_Sell"], "CustomerCode", "CustomerName",
                          "Select CustomerCode,CustomerName From BSCustomer", "BSCustomer");
     commUse.BindComboBox(dgvSell.Columns["ChanceCode"], "ChanceCode", "ChanceName",
                          "Select ChanceCode,ChanceName From CUChance", "CUChance");
     commUse.BindComboBox(dgvSell.Columns["InvenCode"], "InvenCode", "InvenName",
                          "Select InvenCode,InvenName From BSInven", "BSInven");
     //dgvRel的DataGridViewComboBoxColumn绑定到数据源
     commUse.BindComboBox(dgvRel.Columns["CustomerCode_Rel"], "CustomerCode", "CustomerName",
                          "Select CustomerCode,CustomerName From BSCustomer", "BSCustomer");
     commUse.BindComboBox(dgvRel.Columns["RelManner"], "Code", "Name", "select Code,Name from INRelManner",
                          "INRelManner");
     //dgvAfter的DataGridViewComboBoxColumn绑定到数据源
     commUse.BindComboBox(dgvAfter.Columns["CustomerCode_After"], "CustomerCode", "CustomerName",
                          "Select CustomerCode,CustomerName From BSCustomer", "BSCustomer");
     commUse.BindComboBox(dgvAfter.Columns["EmployeeCode"], "EmployeeCode", "EmployeeName",
                          "Select EmployeeCode,EmployeeName From BSEmployee", "BSEmployee");
     //tvCustomer绑定到数据源
     commUse.BuildTree(tvCustomer, imageList1, "客户信息", "BSCustomer", "CustomerCode", "CustomerName");
 }
Exemplo n.º 7
0
 private void FormDepartment_Load(object sender, EventArgs e)
 {
     //权限
     commUse.CortrolButtonEnabled(btnAdd, this);
     commUse.CortrolButtonEnabled(btnAmend, this);
     commUse.CortrolButtonEnabled(btnDelete, this);
     commUse.BuildTree(tvDepartment, imageList1, "部门分类", "BSDepartment", "DepartmentCode", "DepartmentName");
 }
Exemplo n.º 8
0
        private void FormAssignRight_Load(object sender, EventArgs e)
        {
            //绑定到数据源

            commUse.BuildTree(tvOperator, imageList1, "用户", "k3_2Operator Where IsAdmin <> '1'", "UserID", "OperatorName");
            commUse.BuildTree2(tvModule, imageList1, "功能模块", "k3_2sysMK", "ID", "FNAME", "0");
            // commUse.BindComboBox(dgvINRightInfo.Columns["RightTag"], "RightTag", "RightName", "Select RightTag,RightName From INRight", "INRight");
        }
Exemplo n.º 9
0
 private void FormBaseType_Load(object sender, EventArgs e)
 {
     ////权限
     commUse.CortrolButtonEnabled(toolAdd, this);
     commUse.CortrolButtonEnabled(toolAmend, this);
     commUse.CortrolButtonEnabled(toolDelete, this);
     //TreeView绑定到数据源
     commUse.BuildTree(tvBaseType, imageList1, "基础分类", "INBaseType", "Code", "Name");
 }
Exemplo n.º 10
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string   strSql            = null;
            string   strDepartmentCode = null;
            DataBase db = new DataBase();

            if (tvDepartment.SelectedNode != null)
            {
                if (tvDepartment.SelectedNode.Tag != null)
                {
                    strDepartmentCode = tvDepartment.SelectedNode.Tag.ToString();

                    //判断当前记录的主键值是否存在外键约束
                    if (commUse.IsExistConstraint("BSDepartment", strDepartmentCode))
                    {
                        MessageBox.Show("已发生业务关系,无法删除", "软件提示");
                        return;
                    }

                    if (MessageBox.Show("确定要删除吗?", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) ==
                        DialogResult.Yes)
                    {
                        strSql = "DELETE FROM BSDepartment WHERE DepartmentCode = '" + strDepartmentCode + "'";

                        try
                        {
                            if (db.ExecDataBySql(strSql) > 0)
                            {
                                MessageBox.Show("删除成功!", "软件提示");
                                commUse = new CommonUse();
                                commUse.BuildTree(tvDepartment, imageList1, "部门分类", "BSDepartment", "DepartmentCode",
                                                  "DepartmentName");
                            }
                            else
                            {
                                MessageBox.Show("删除失败!", "软件提示");
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "软件提示");
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            string        strCode = null;
            SqlDataReader sdr     = null;
            CommonUse     commUse = null;

            errorInfo.Clear();

            if (String.IsNullOrEmpty(txtTypeCode.Text.Trim()))
            {
                errorInfo.SetError(txtTypeCode, "类别编码不许为空!");
                return;
            }

            if (String.IsNullOrEmpty(txtTypeName.Text.Trim()))
            {
                errorInfo.SetError(txtTypeName, "类别名称不许为空!");
                return;
            }

            if (this.Tag.ToString() == "Add") //添加操作
            {
                strCode = "select * from BSCostType where CostTypeCode = '" + txtTypeCode.Text.Trim() + "'";

                try
                {
                    sdr = db.GetDataReader(strCode);
                    sdr.Read();

                    if (!sdr.HasRows)
                    {
                        sdr.Close();
                        strCode = "INSERT INTO BSCostType(CostTypeCode,CostTypeName) VALUES('" + txtTypeCode.Text.Trim() + "','" + txtTypeName.Text.Trim() + "')";

                        if (db.ExecDataBySql(strCode) > 0)
                        {
                            MessageBox.Show("保存成功!", "软件提示");
                            commUse = new CommonUse();
                            commUse.BuildTree(formCostType.tvCostType, formCostType.imageList1, "费用分类", "BSCostType", "CostTypeCode", "CostTypeName");
                            btnQuit_Click(sender, e);
                        }
                        else
                        {
                            MessageBox.Show("保存失败!", "软件提示");
                        }
                    }
                    else
                    {
                        MessageBox.Show("编码重复,请重新设置", "软件提示");
                        txtTypeCode.Focus();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "软件提示");
                    throw ex;
                }
                finally
                {
                    sdr.Close();
                }
            }
            else //修改操作
            {
                //类别代码被修改过
                if (formCostType.tvCostType.SelectedNode.Tag.ToString() != txtTypeCode.Text.Trim())
                {
                    strCode = "select * from BSCostType where CostTypeCode = '" + txtTypeCode.Text.Trim() + "'";

                    try
                    {
                        sdr = db.GetDataReader(strCode);
                        sdr.Read();

                        if (sdr.HasRows)
                        {
                            MessageBox.Show("编码重复,请重新设置", "软件提示");
                            txtTypeCode.Focus();
                            sdr.Close();
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "软件提示");
                        throw ex;
                    }
                    finally
                    {
                        sdr.Close();
                    }
                }

                //更新数据库
                try
                {
                    strCode = "UPDATE BSCostType SET CostTypeCode = '" + txtTypeCode.Text.Trim() + "',CostTypeName = '" + txtTypeName.Text.Trim() + "' WHERE CostTypeCode = '" + formCostType.tvCostType.SelectedNode.Tag.ToString() + "'";
                    if (db.ExecDataBySql(strCode) > 0)
                    {
                        MessageBox.Show("保存成功!", "软件提示");
                        commUse = new CommonUse();
                        commUse.BuildTree(formCostType.tvCostType, formCostType.imageList1, "费用分类", "BSCostType", "CostTypeCode", "CostTypeName");
                        btnQuit_Click(sender, e);
                    }
                    else
                    {
                        MessageBox.Show("保存失败!", "软件提示");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "软件提示");
                    throw ex;
                }
            }
        }
Exemplo n.º 12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string strProInvenCode    = null;                           //表示母件代码
            string strMatInvenCode    = null;                           //表示子件代码
            string strOldMatInvenCode = null;                           //表示未修改之前的子件代码
            string strCode            = null;                           //表示SQL语句字符串

            if (cbxProInvenCode.SelectedIndex == -1)                    //母件不许为空
            {
                MessageBox.Show("请选择母件!", "软件提示");
                cbxProInvenCode.Focus();
                return;
            }
            if (cbxMatInvenCode.SelectedIndex == -1)                    //子件不许为空
            {
                MessageBox.Show("请选择子件!", "软件提示");
                cbxMatInvenCode.Focus();
                return;
            }
            //母件与子件不许相同
            if (cbxMatInvenCode.SelectedValue.ToString() == cbxProInvenCode.SelectedValue.ToString())
            {
                MessageBox.Show("母件与子件不许相同!", "软件提示");
                cbxProInvenCode.Focus();
                return;
            }
            if (String.IsNullOrEmpty(txtQuantity.Text.Trim()))              //组成数量不许为空
            {
                MessageBox.Show("组成数量不许为空!", "软件提示");
                txtQuantity.Focus();
                return;
            }
            if (Convert.ToInt32(txtQuantity.Text.Trim()) == 0)              //组成数量不许为零
            {
                MessageBox.Show("组成数量不许为零!", "软件提示");
                txtQuantity.Focus();
                return;
            }
            strProInvenCode = cbxProInvenCode.SelectedValue.ToString(); //获取当前的母件代码
            strMatInvenCode = cbxMatInvenCode.SelectedValue.ToString(); //获取当前的子件代码
                                                                        //如果是添加操作,则需要判断将要添加的子件是否与现有的子件重复
            if (this.Tag.ToString() == "Add")
            {
                foreach (PropertyClass item in propBoms)                //遍历包含Bom信息的泛型列表
                {
                    //若将要添加的子件与当前母件现有的子件重复,则系统禁止添加
                    if (item.ProInvenCode == strProInvenCode && item.MatInvenCode == strMatInvenCode)
                    {
                        MessageBox.Show("子件不许重复!", "软件提示");
                        return;                                     //程序终止运行
                    }
                }
                ParametersAddValue();  //给下面INSERT语句中的参数赋值
                                       //表示为当前母件插入新子件
                strCode  = "INSERT INTO BSBom(ProInvenCode,MatInvenCode,Quantity) ";
                strCode += "VALUES(@ProInvenCode,@MatInvenCode,@Quantity)";
                if (db.ExecDataBySql(strCode) > 0)                      //执行SQL语句成功
                {
                    MessageBox.Show("保存成功!", "软件提示");
                }
                else                                                    //执行SQL语句失败
                {
                    MessageBox.Show("保存失败!", "软件提示");
                }
            }
            if (this.Tag.ToString() == "Edit")                              //若是修改操作
            {
                strOldMatInvenCode = formBom.dgvStructInfo[0,
                                                           formBom.dgvStructInfo.CurrentRow.Index].Value.ToString(); //获取修改之前的子件代码
                                                                                                                     //如果修改了子件,则需要判断该母件是否存在重复子件
                if (strMatInvenCode != strOldMatInvenCode)
                {
                    foreach (PropertyClass item in propBoms)                //遍历包含Bom信息的泛型列表
                    {
                        //如果存在重复子件,则系统禁止修改
                        if (item.ProInvenCode == strProInvenCode && item.MatInvenCode == strMatInvenCode)
                        {
                            MessageBox.Show("子件不许重复!", "软件提示");
                            return;                                 //终止程序运行
                        }
                    }
                }
                ParametersAddValue();                                   //为SQL语句中的参数赋值
                strCode  = "UPDATE BSBom SET ProInvenCode=@ProInvenCode,MatInvenCode = @MatInvenCode,Quantity = @Quantity ";
                strCode += " WHERE ProInvenCode = '" + strProInvenCode + "' AND MatInvenCode = '" +
                           strOldMatInvenCode + "'";            //修改当前母件的某个子件的信息
                if (db.ExecDataBySql(strCode) > 0)              //执行SQL语句成功
                {
                    MessageBox.Show("保存成功!", "软件提示");
                }
                else                                                    //执行SQL语句失败
                {
                    MessageBox.Show("保存失败!", "软件提示");
                }
            }
            commUse.BuildTree(formBom.tvInven, formBom.imageList1, "母件", "V_BomStruct", "InvenCode",
                              "InvenName");                         //TreeView控件重新绑定到数据源
                                                                    //重新设置物料清单窗体中TreeView控件的被选定节点
            formBom.tvInven.SelectedNode = formBom.tvInven.Nodes[0].Nodes[intNodeIndex];
            this.Close();                                           //关闭当前窗体
        }
Exemplo n.º 13
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string strProInvenCode    = null; //母件代码
            string strMatInvenCode    = null; //子件代码
            string strOldMatInvenCode = null; //未修改的子件代码
            string strCode            = null;

            if (cbxProInvenCode.SelectedIndex == -1)
            {
                MessageBox.Show("请选择母件!", "软件提示");
                cbxProInvenCode.Focus();
                return;
            }

            if (cbxMatInvenCode.SelectedIndex == -1)
            {
                MessageBox.Show("请选择子件!", "软件提示");
                cbxMatInvenCode.Focus();
                return;
            }

            if (cbxMatInvenCode.SelectedValue.ToString() == cbxProInvenCode.SelectedValue.ToString())
            {
                MessageBox.Show("母件与子件不许相同!", "软件提示");
                cbxProInvenCode.Focus();
                return;
            }

            if (String.IsNullOrEmpty(txtQuantity.Text.Trim()))
            {
                MessageBox.Show("组成数量不许为空!", "软件提示");
                txtQuantity.Focus();
                return;
            }

            if (Convert.ToInt32(txtQuantity.Text.Trim()) == 0)
            {
                MessageBox.Show("组成数量不许为零!", "软件提示");
                txtQuantity.Focus();
                return;
            }

            //当前的母件代码
            strProInvenCode = cbxProInvenCode.SelectedValue.ToString();
            //当前的子件代码
            strMatInvenCode = cbxMatInvenCode.SelectedValue.ToString();

            //添加操作
            if (Tag.ToString() == "Add")
            {
                foreach (PropertyClass item in propBoms)
                {
                    if (item.ProInvenCode == strProInvenCode && item.MatInvenCode == strMatInvenCode)
                    {
                        MessageBox.Show("子件不许重复!", "软件提示");
                        return;
                    }
                }

                //设置参数
                ParametersAddValue();

                strCode  = "INSERT INTO BSBom(ProInvenCode,MatInvenCode,Quantity) ";
                strCode += "VALUES(@ProInvenCode,@MatInvenCode,@Quantity)";

                if (db.ExecDataBySql(strCode) > 0)
                {
                    MessageBox.Show("保存成功!", "软件提示");
                }
                else
                {
                    MessageBox.Show("保存失败!", "软件提示");
                }
            }

            //修改操作
            if (Tag.ToString() == "Edit")
            {
                //获取修改之前的子件代码
                strOldMatInvenCode = formBom.dgvStructInfo[0, formBom.dgvStructInfo.CurrentRow.Index].Value.ToString();

                //如果修改了子件代码,则需要判断该母件是否存在重复子件
                if (strMatInvenCode != strOldMatInvenCode)
                {
                    foreach (PropertyClass item in propBoms)
                    {
                        if (item.ProInvenCode == strProInvenCode && item.MatInvenCode == strMatInvenCode)
                        {
                            MessageBox.Show("子件不许重复!", "软件提示");
                            return;
                        }
                    }
                }

                //设置参数
                ParametersAddValue();

                strCode  = "UPDATE BSBom SET ProInvenCode=@ProInvenCode,MatInvenCode=@MatInvenCode,Quantity = @Quantity ";
                strCode += " WHERE ProInvenCode = '" + strProInvenCode + "' AND MatInvenCode = '" + strOldMatInvenCode +
                           "'";

                if (db.ExecDataBySql(strCode) > 0)
                {
                    MessageBox.Show("保存成功!", "软件提示");
                }
                else
                {
                    MessageBox.Show("保存失败!", "软件提示");
                }
            }

            commUse.BuildTree(formBom.tvInven, formBom.imageList1, "母件", "V_BomStruct", "InvenCode", "InvenName");
            formBom.tvInven.SelectedNode = formBom.tvInven.Nodes[0].Nodes[intNodeIndex];

            Close();
        }