Example #1
0
        private void button1_Click(object sender, EventArgs e)                                   //借样机按钮
        {
            string ip = Fuctions.GetIpAddress();

            if (LoginForm.admin == 0)
            {
                if (ip != IPADRESS && ip != IPADDRESS1 && ip != IPADRESS2 && ip != IPADRESS3)
                {
                    MessageBox.Show("请去指定电脑进行样机借阅", "提示");
                    return;
                }
            }


            //MySqlConnection conn = new MySqlConnection(GetConn.connection);                             //连接对象
            BorrowBLL borrowbll = new BorrowBLL();
            PhoneBLL  phonebll  = new PhoneBLL();

            if (cbbStaffName.Text == "" || cbbPhoneName.Text == "" || cbbPhoneStage.Text == "" || ((cbbPhoneNum.Text == "") && (cbbPhoneNumL1.Text == "") && (cbbPhoneNumL2.Text == "") && (cbbPhoneNumL3.Text == "") && (cbbPhoneNumL4.Text == "")))
            {
                MessageBox.Show("请输入样机信息");
                return;
            }
            else
            {
                if (cbbPhoneNum.Text != "")
                {
                    if (cbbPhoneNum.Text == cbbPhoneNumL1.Text || cbbPhoneNum.Text == cbbPhoneNumL2.Text || cbbPhoneNum.Text == cbbPhoneNumL3.Text || cbbPhoneNum.Text == cbbPhoneNumL4.Text)
                    {
                        MessageBox.Show("借阅样机编号重复,请检查编号");
                        return;
                    }


                    if (borrowbll.addBorrow(this.cbbStaffName.Text, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum.Text, LoginForm.usrName))
                    {
                        //MessageBox.Show("借阅成功");
                    }
                    if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum.Text))                            //更新数据库 PmPhone 中的信息
                    {
                        //MessageBox.Show("借阅成功");
                    }
                }

                if (cbbPhoneNumL1.Text != "")
                {
                    if (cbbPhoneNumL1.Text == cbbPhoneNum.Text || cbbPhoneNumL1.Text == cbbPhoneNumL2.Text || cbbPhoneNumL1.Text == cbbPhoneNumL3.Text || cbbPhoneNumL1.Text == cbbPhoneNumL4.Text)
                    {
                        MessageBox.Show("借阅样机编号重复,请检查编号");
                        return;
                    }

                    if (borrowbll.addBorrow(this.cbbStaffName.Text, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL1.Text, LoginForm.usrName))
                    {
                        //MessageBox.Show("借阅成功");
                    }
                    if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL1.Text))                            //更新数据库 PmPhone 中的信息
                    {
                        //MessageBox.Show("借阅成功");
                    }
                }

                if (cbbPhoneNumL2.Text != "")
                {
                    if (cbbPhoneNumL2.Text == cbbPhoneNum.Text || cbbPhoneNumL2.Text == cbbPhoneNumL1.Text || cbbPhoneNumL2.Text == cbbPhoneNumL3.Text || cbbPhoneNumL2.Text == cbbPhoneNumL4.Text)
                    {
                        MessageBox.Show("借阅样机编号重复,请检查编号");
                        return;
                    }

                    if (borrowbll.addBorrow(this.cbbStaffName.Text, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL2.Text, LoginForm.usrName))
                    {
                        //MessageBox.Show("借阅成功");
                    }
                    if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL2.Text))                            //更新数据库 PmPhone 中的信息
                    {
                        //MessageBox.Show("借阅成功");
                    }
                }

                if (cbbPhoneNumL3.Text != "")
                {
                    if (cbbPhoneNumL3.Text == cbbPhoneNum.Text || cbbPhoneNumL3.Text == cbbPhoneNumL1.Text || cbbPhoneNumL3.Text == cbbPhoneNumL2.Text || cbbPhoneNumL3.Text == cbbPhoneNumL4.Text)
                    {
                        MessageBox.Show("借阅样机编号重复,请检查编号");
                        return;
                    }


                    if (borrowbll.addBorrow(this.cbbStaffName.Text, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL3.Text, LoginForm.usrName))
                    {
                        //MessageBox.Show("借阅成功");
                    }
                    if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL3.Text))                            //更新数据库 PmPhone 中的信息
                    {
                        //MessageBox.Show("借阅成功");
                    }
                }

                if (cbbPhoneNumL4.Text != "")
                {
                    if (cbbPhoneNumL4.Text == cbbPhoneNum.Text || cbbPhoneNumL4.Text == cbbPhoneNumL1.Text || cbbPhoneNumL4.Text == cbbPhoneNumL2.Text || cbbPhoneNumL4.Text == cbbPhoneNumL3.Text)
                    {
                        MessageBox.Show("借阅样机编号重复,请检查编号");
                        return;
                    }

                    if (borrowbll.addBorrow(this.cbbStaffName.Text, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL4.Text, LoginForm.usrName))
                    {
                        //MessageBox.Show("借阅成功");
                    }
                    if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL4.Text))                            //更新数据库 PmPhone 中的信息
                    {
                        //MessageBox.Show("借阅成功");
                    }
                }

                MessageBox.Show("借阅成功");
            }

            borrows = borrowbll.GetAllBorrow();                                                 //DataGridView显示所借样机
            borrowDataGrid.DataSource = borrows;

            //**************************************************借样机相关内容更新
            string           strSql = "select distinct PhoneName from PmPhone where PhoneStatus = '在库' and PhoneDisplay = 'TRUE'"; //更新cbb中样机信息
            MySqlCommand     cmd    = new MySqlCommand(strSql, conn);
            MySqlDataAdapter da     = new MySqlDataAdapter(cmd);
            DataSet          ds     = new DataSet();

            conn.Open();
            da.Fill(ds, "PmPhone");
            conn.Close();
            cbbPhoneName.DisplayMember = "PhoneName";
            cbbPhoneName.ValueMember   = "PhoneName";
            cbbPhoneName.DataSource    = ds.Tables["PmPhone"];
            cbbPhoneName.Text          = "";

            //**************************************************还样机相关内容更新
            //strSql = "select distinct StaffName from PmStaff";                      //还员工姓名combobox内容加载--cbbPhoneName1--cbbPhoneStage1--cbbPhoneNum1
            strSql = "select distinct StaffName from PmBorrow where IsReturn='false' order by convert(StaffName USING gbk) asc";

            cmd = new MySqlCommand(strSql, conn);

            da = new MySqlDataAdapter(cmd);
            ds = new DataSet();
            conn.Open();
            da.Fill(ds, "PmStaff");
            conn.Close();
            cbbStaffName1.DisplayMember = "StaffName";
            cbbStaffName1.ValueMember   = "StaffName";
            cbbStaffName1.DataSource    = ds.Tables["PmStaff"];
            cbbStaffName1.Text          = "";
        }
Example #2
0
        /*
         *需求:通过按键实现样机 借还一起,主要是为了记录做过的实验,及实验后的状态
         *思路:先借 后还
         */

        private void button1_Click(object sender, EventArgs e)
        {
            string ip = Fuctions.GetIpAddress();

            if (LoginForm.admin == 0)
            {
                if (ip != IPADRESS && ip != IPADDRESS1 && ip != IPADRESS2)
                {
                    MessageBox.Show("请去指定电脑进行样机借阅", "提示");
                    return;
                }
            }

            BorrowBLL borrowbll = new BorrowBLL();
            PhoneBLL  phonebll  = new PhoneBLL();

            //若是五行中的 样机编号没有选,给出提示
            if (cbbPhoneNum1.Text == "" && cbbPhoneNum2.Text == "" && cbbPhoneNum3.Text == "" && cbbPhoneNum4.Text == "" && cbbPhoneNum.Text == "" & cbbPhoneNum5.Text == "" && cbbPhoneNum6.Text == "" && cbbPhoneNum7.Text == "" && cbbPhoneNum8.Text == "" && cbbPhoneNum9.Text == "")
            {
                MessageBox.Show("请输入样机编号");
                return;
            }

            if (cbbPhoneName.Text == "" || cbbPhoneStage.Text == "")
            {
                MessageBox.Show("请输入样机信息");
                return;
            }
            else
            {
                //判断样机状态是否选择
                if (cbbPhoneNum.Text != "")
                {
                    if (cbbIsNormal.Text == "")
                    {
                        MessageBox.Show("请输入样机状态");
                        return;
                    }
                    //样机状态是否正常,若是故障时需要输入备注
                    if (cbbIsNormal.Text == "故障" && txtRemark.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }
                }
                if (cbbPhoneNum1.Text != "")
                {
                    if (cbbIsNormal1.Text == "")
                    {
                        MessageBox.Show("请输入样机状态");
                        return;
                    }
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal1.Text == "故障" && txtRemark1.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }
                }
                if (cbbPhoneNum2.Text != "")
                {
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal2.Text == "故障" && txtRemark2.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }
                    if (cbbIsNormal2.Text == "")
                    {
                        MessageBox.Show("请输入样机状态");
                        return;
                    }
                }
                if (cbbPhoneNum3.Text != "")
                {
                    if (cbbIsNormal3.Text == "")
                    {
                        MessageBox.Show("请输入样机状态");
                        return;
                    }
                    //样机状态是否正常,若是故障时需要输入备注
                    if (cbbIsNormal3.Text == "故障" && txtRemark3.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }
                }
                if (cbbPhoneNum4.Text != "")
                {
                    if (cbbIsNormal4.Text == "")
                    {
                        MessageBox.Show("请输入样机状态");
                        return;
                    }
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal4.Text == "故障" && txtRemark4.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }
                }
                if (cbbPhoneNum5.Text != "")
                {
                    if (cbbIsNormal5.Text == "")
                    {
                        MessageBox.Show("请输入样机状态");
                        return;
                    }
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal5.Text == "故障" && txtRemark5.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }
                }
                if (cbbPhoneNum6.Text != "")
                {
                    if (cbbIsNormal6.Text == "")
                    {
                        MessageBox.Show("请输入样机状态");
                        return;
                    }
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal6.Text == "故障" && txtRemark6.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }
                }
                if (cbbPhoneNum7.Text != "")
                {
                    if (cbbIsNormal7.Text == "")
                    {
                        MessageBox.Show("请输入样机状态");
                        return;
                    }
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal7.Text == "故障" && txtRemark7.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }
                }
                if (cbbPhoneNum8.Text != "")
                {
                    if (cbbIsNormal8.Text == "")
                    {
                        MessageBox.Show("请输入样机状态");
                        return;
                    }
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal8.Text == "故障" && txtRemark8.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }
                }
                if (cbbPhoneNum9.Text != "")
                {
                    if (cbbIsNormal9.Text == "")
                    {
                        MessageBox.Show("请输入样机状态");
                        return;
                    }
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal9.Text == "故障" && txtRemark9.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }
                }


                //借机操作
                if (cbbPhoneNum.Text != "")
                {
                    //借与还操作
                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum.Text, LoginForm.usrName))
                    {
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum.Text + "借", "提示");
                    }
                    if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum.Text, cbbHGroupTest.Text, cbbIsNormal.Text, txtRemark.Text))
                    {
                        //MessageBox.Show("操作成功", "提示");
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum.Text + "还", "提示");
                    }
                }


                //借机操作2
                if (cbbPhoneNum1.Text != "")
                {
                    //借与还操作
                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum1.Text, LoginForm.usrName))
                    {
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum1.Text + "借错误", "提示");
                    }
                    if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum1.Text, cbbHGroupTest.Text, cbbIsNormal1.Text, txtRemark1.Text))
                    {
                        //MessageBox.Show("操作成功", "提示");
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum1.Text + "还错误", "提示");
                    }
                }

                //操作3
                if (cbbPhoneNum2.Text != "")
                {
                    //借与还操作
                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum2.Text, LoginForm.usrName))
                    {
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum2.Text + "借错误", "提示");
                    }
                    if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum2.Text, cbbHGroupTest.Text, cbbIsNormal2.Text, txtRemark2.Text))
                    {
                        //MessageBox.Show("操作成功", "提示");
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum2.Text + "还错误", "提示");
                    }
                }


                //操作4
                if (cbbPhoneNum3.Text != "")
                {
                    //借与还操作
                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum3.Text, LoginForm.usrName))
                    {
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum3.Text + "借错误", "提示");
                    }
                    if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum3.Text, cbbHGroupTest.Text, cbbIsNormal3.Text, txtRemark3.Text))
                    {
                        //MessageBox.Show("操作成功", "提示");
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum3.Text + "还错误", "提示");
                    }
                }


                //操作5
                if (cbbPhoneNum4.Text != "")
                {
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal4.Text == "故障" && txtRemark4.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }

                    //借与还操作
                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum4.Text, LoginForm.usrName))
                    {
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum4.Text + "借错误", "提示");
                    }
                    if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum4.Text, cbbHGroupTest.Text, cbbIsNormal4.Text, txtRemark4.Text))
                    {
                        //MessageBox.Show("操作成功", "提示");
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum4.Text + "还错误", "提示");
                    }
                }


                //操作6
                if (cbbPhoneNum5.Text != "")
                {
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal5.Text == "故障" && txtRemark5.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }

                    //借与还操作
                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum5.Text, LoginForm.usrName))
                    {
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum5.Text + "借错误", "提示");
                    }
                    if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum5.Text, cbbHGroupTest.Text, cbbIsNormal5.Text, txtRemark5.Text))
                    {
                        //MessageBox.Show("操作成功", "提示");
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum5.Text + "还错误", "提示");
                    }
                }


                //操作7
                if (cbbPhoneNum6.Text != "")
                {
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal6.Text == "故障" && txtRemark6.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }

                    //借与还操作
                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum6.Text, LoginForm.usrName))
                    {
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum6.Text + "借错误", "提示");
                    }
                    if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum6.Text, cbbHGroupTest.Text, cbbIsNormal6.Text, txtRemark6.Text))
                    {
                        //MessageBox.Show("操作成功", "提示");
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum6.Text + "还错误", "提示");
                    }
                }


                //操作8
                if (cbbPhoneNum7.Text != "")
                {
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal7.Text == "故障" && txtRemark7.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }

                    //借与还操作
                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum7.Text, LoginForm.usrName))
                    {
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum7.Text + "借错误", "提示");
                    }
                    if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum7.Text, cbbHGroupTest.Text, cbbIsNormal7.Text, txtRemark7.Text))
                    {
                        //MessageBox.Show("操作成功", "提示");
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum7.Text + "还错误", "提示");
                    }
                }


                //操作9
                if (cbbPhoneNum8.Text != "")
                {
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal8.Text == "故障" && txtRemark8.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }

                    //借与还操作
                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum8.Text, LoginForm.usrName))
                    {
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum8.Text + "借错误", "提示");
                    }
                    if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum8.Text, cbbHGroupTest.Text, cbbIsNormal8.Text, txtRemark8.Text))
                    {
                        //MessageBox.Show("操作成功", "提示");
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum8.Text + "还错误", "提示");
                    }
                }


                //操作10
                if (cbbPhoneNum9.Text != "")
                {
                    //样机状态是否正常,若是故障时需要输入备注

                    if (cbbIsNormal9.Text == "故障" && txtRemark9.Text == "")
                    {
                        MessageBox.Show("样机故障,请输入故障信息", "提示");
                        return;
                    }

                    //借与还操作
                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum9.Text, LoginForm.usrName))
                    {
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum9.Text + "借错误", "提示");
                    }
                    if (borrowbll.returnPhone(LoginForm.usrName, cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum9.Text, cbbHGroupTest.Text, cbbIsNormal9.Text, txtRemark9.Text))
                    {
                        //MessageBox.Show("操作成功", "提示");
                    }
                    else
                    {
                        MessageBox.Show(this.cbbPhoneNum9.Text + "还错误", "提示");
                    }
                }
                MessageBox.Show("操作成功");
            }

            string strSql = "select * from PmBorrow where StaffName = '" + LoginForm.usrName + "' order by BorrowID DESC"; //样机名称combobox内容加载

            borrows = borrowbll.selByCondition(strSql);                                                                    //DataGrid 内容加载
            borrowDataGrid.DataSource = borrows;

            //借机相关内容更新**********************************************************
            strSql = "select distinct PhoneName from PmPhone where PhoneStatus = '在库'and PhoneDisplay = 'TRUE'";  //更新借样机cbb中样机信息
            MySqlCommand     cmd = new MySqlCommand(strSql, conn);
            MySqlDataAdapter da  = new MySqlDataAdapter(cmd);
            DataSet          ds  = new DataSet();

            conn.Open();
            da.Fill(ds, "PmPhone");
            conn.Close();
            cbbPhoneName.DisplayMember = "PhoneName";
            cbbPhoneName.ValueMember   = "PhoneName";
            cbbPhoneName.DataSource    = ds.Tables["PmPhone"];
            cbbPhoneName.Text          = "";

            //收尾工作:清空无关信息

            txtRemark.Text  = "";
            txtRemark1.Text = "";
            txtRemark2.Text = "";
            txtRemark3.Text = "";
            txtRemark4.Text = "";
            txtRemark5.Text = "";
            txtRemark6.Text = "";
            txtRemark7.Text = "";
            txtRemark8.Text = "";
            txtRemark9.Text = "";

            //默认正常
            cbbIsNormal.Text  = "正常";
            cbbIsNormal1.Text = "正常";
            cbbIsNormal2.Text = "正常";
            cbbIsNormal3.Text = "正常";
            cbbIsNormal4.Text = "正常";
            cbbIsNormal5.Text = "正常";
            cbbIsNormal6.Text = "正常";
            cbbIsNormal7.Text = "正常";
            cbbIsNormal8.Text = "正常";
            cbbIsNormal9.Text = "正常";
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)                                   //借样机按钮
        {
            string ip = Fuctions.GetIpAddress();

            if (LoginForm.admin == 0)
            {
                if (ip != IPADRESS && ip != IPADDRESS1 && ip != IPADRESS2 && ip != IPADRESS3)
                {
                    MessageBox.Show("请去指定电脑进行样机借阅", "提示");
                    return;
                }
            }

            BorrowBLL borrowbll = new BorrowBLL();
            PhoneBLL  phonebll  = new PhoneBLL();

            if (cbbPhoneName.Text == "" || cbbPhoneStage.Text == "" || ((cbbPhoneNum.Text == "") && (cbbPhoneNumL1.Text == "") && (cbbPhoneNumL2.Text == "") && (cbbPhoneNumL3.Text == "") && (cbbPhoneNumL4.Text == "")))
            {
                MessageBox.Show("请输入样机信息");
                return;
            }
            else
            {
                if (cbbPhoneNum.Text != "")
                {
                    if (cbbPhoneNum.Text == cbbPhoneNumL1.Text || cbbPhoneNum.Text == cbbPhoneNumL2.Text || cbbPhoneNum.Text == cbbPhoneNumL3.Text || cbbPhoneNum.Text == cbbPhoneNumL4.Text)
                    {
                        MessageBox.Show("借阅样机编号重复,请检查编号");
                        return;
                    }

                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNum.Text, LoginForm.usrName))
                    {
                        //MessageBox.Show("借阅成功");
                    }
                    if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNum.Text))                            //更新数据库 PmPhone 中的信息
                    {
                        //MessageBox.Show("借阅成功");
                    }
                }

                if (cbbPhoneNumL1.Text != "")
                {
                    if (cbbPhoneNumL1.Text == cbbPhoneNum.Text || cbbPhoneNumL1.Text == cbbPhoneNumL2.Text || cbbPhoneNumL1.Text == cbbPhoneNumL3.Text || cbbPhoneNumL1.Text == cbbPhoneNumL4.Text)
                    {
                        MessageBox.Show("借阅样机编号重复,请检查编号");
                        return;
                    }
                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL1.Text, LoginForm.usrName))
                    {
                        //MessageBox.Show("借阅成功");
                    }
                    if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL1.Text))                            //更新数据库 PmPhone 中的信息
                    {
                        //MessageBox.Show("借阅成功");
                    }
                }

                if (cbbPhoneNumL2.Text != "")
                {
                    if (cbbPhoneNumL2.Text == cbbPhoneNum.Text || cbbPhoneNumL2.Text == cbbPhoneNumL1.Text || cbbPhoneNumL2.Text == cbbPhoneNumL3.Text || cbbPhoneNumL2.Text == cbbPhoneNumL4.Text)
                    {
                        MessageBox.Show("借阅样机编号重复,请检查编号");
                        return;
                    }

                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL2.Text, LoginForm.usrName))
                    {
                        //MessageBox.Show("借阅成功");
                    }
                    if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL2.Text))                            //更新数据库 PmPhone 中的信息
                    {
                        //MessageBox.Show("借阅成功");
                    }
                }

                if (cbbPhoneNumL3.Text != "")
                {
                    if (cbbPhoneNumL3.Text == cbbPhoneNum.Text || cbbPhoneNumL3.Text == cbbPhoneNumL1.Text || cbbPhoneNumL3.Text == cbbPhoneNumL2.Text || cbbPhoneNumL3.Text == cbbPhoneNumL4.Text)
                    {
                        MessageBox.Show("借阅样机编号重复,请检查编号");
                        return;
                    }
                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL3.Text, LoginForm.usrName))
                    {
                        //MessageBox.Show("借阅成功");
                    }
                    if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL3.Text))                            //更新数据库 PmPhone 中的信息
                    {
                        //MessageBox.Show("借阅成功");
                    }
                }

                if (cbbPhoneNumL4.Text != "")
                {
                    if (cbbPhoneNumL4.Text == cbbPhoneNum.Text || cbbPhoneNumL4.Text == cbbPhoneNumL1.Text || cbbPhoneNumL4.Text == cbbPhoneNumL2.Text || cbbPhoneNumL4.Text == cbbPhoneNumL3.Text)
                    {
                        MessageBox.Show("借阅样机编号重复,请检查编号");
                        return;
                    }
                    if (borrowbll.addBorrow(LoginForm.usrName, this.cbbPhoneName.Text, this.cbbPhoneStage.Text, this.cbbPhoneNumL4.Text, LoginForm.usrName))
                    {
                        //MessageBox.Show("借阅成功");
                    }
                    if (phonebll.updatePhoneStatusOut(cbbPhoneName.Text, cbbPhoneStage.Text, cbbPhoneNumL4.Text))                            //更新数据库 PmPhone 中的信息
                    {
                        //MessageBox.Show("借阅成功");
                    }
                }

                MessageBox.Show("借阅成功");
            }


            string strSql = "select * from PmBorrow where StaffName = '" + LoginForm.usrName + "' and IsReturn = 'false' order by BorrowID DESC"; //样机名称combobox内容加载

            borrows = borrowbll.selByCondition(strSql);                                                                                           //DataGrid 内容加载
            borrowDataGrid.DataSource = borrows;

            //借机相关内容更新**********************************************************
            strSql = "select distinct PhoneName from PmPhone where PhoneStatus = '在库'and PhoneDisplay = 'TRUE'";  //更新借样机cbb中样机信息
            MySqlCommand     cmd = new MySqlCommand(strSql, conn);
            MySqlDataAdapter da  = new MySqlDataAdapter(cmd);
            DataSet          ds  = new DataSet();

            conn.Open();
            da.Fill(ds, "PmPhone");
            conn.Close();
            cbbPhoneName.DisplayMember = "PhoneName";
            cbbPhoneName.ValueMember   = "PhoneName";
            cbbPhoneName.DataSource    = ds.Tables["PmPhone"];
            cbbPhoneName.Text          = "";

            //还机相关内容更新**********************************************************
            strSql = "select distinct PhoneName from PmBorrow where IsReturn = 'false' and StaffName = '" + LoginForm.usrName + "'";        //还样机名称combobox内容加载
            cmd    = new MySqlCommand(strSql, conn);

            da = new MySqlDataAdapter(cmd);
            ds = new DataSet();
            conn.Open();
            da.Fill(ds, "PmBorrow");
            conn.Close();
            cbbPhoneName1.DisplayMember = "PhoneName";
            cbbPhoneName1.ValueMember   = "PhoneName";
            cbbPhoneName1.DataSource    = ds.Tables["PmBorrow"];
            cbbPhoneName1.Text          = "";
        }