Пример #1
0
        //以旧换新 确定按钮
        public void Button_Exchange_Enter_Click(object sender, EventArgs e)
        {
            ToolsIn toolsIn = new ToolsIn();
            //获取编码、领用人、操作人信息
            //检查领用人信息、检查操作人信息
            //更新工装数据库,添加记录数据库
            String borrower        = Program.mw.textBox_toolsReturn_returner.Text;
            String borrowerName    = Program.mw.textBox_toolsReturn_returnerName.Text;
            String borrowerContact = Program.mw.textBox_toolsReturn_returnerContact.Text;
            String borrowLine      = Program.mw.textBox_toolsReturn_returnLine.Text;
            String operator1       = Program.mw.textBox_toolsReturn_operator.Text;
            String operatorName    = Program.mw.textBox_toolsReturn_operatorName.Text;
            String operatorContact = Program.mw.textBox_toolsReturn_operatorContact.Text;

            //先执行归还入库按钮操作
            if (toolsIn.ToolsReturn_Enter() == true)
            {
                //校验各项数据
                if (borrower.Length != 8 || CommonFunction.HasChinese(borrower) || borrowerName.Length < 1)
                {
                    MessageBox.Show("请正确填写领用人信息!");
                    return;
                }
                if (operator1.Length != 8 || CommonFunction.HasChinese(operator1) || operatorName.Length < 1)
                {
                    MessageBox.Show("请正确填写操作人信息!");
                    return;
                }
                if (count < dtExchange.Rows.Count)
                {
                    DialogResult result = MessageBox.Show("换新工装数量少于归还工装,确认继续?", "数量确认", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (result == DialogResult.No)
                    {
                        return;
                    }
                }

                try
                {
                    foreach (DataRow row in dtExchange.Rows)
                    {
                        String   code           = row[3].ToString();
                        String[] temp           = code.Split('-');
                        String   category       = temp[0];
                        String   materialNumber = temp[1];
                        String   number         = temp[2];
                        String   functionState  = "";
                        //获取该工装功能状态
                        sql = "select * from tools where code='" + code + "' order by idTools DESC limit 1";
                        DataSet ds = connection.Select(sql);
                        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                        {
                            functionState = ds.Tables[0].Rows[0][15].ToString();
                        }

                        //更新工装数据库
                        sql = @"update tools set storageState='已出借',line='" + borrowLine + "',borrower='" + borrower + "',operator='" + operator1
                              + "',lendDuration='0' where code='" + code + "';";
                        if (connection.Update(sql))
                        {
                            //添加记录数据库
                            sql = @"insert into records 
                                   (code,category,materialNumber,number,functionState,operationType,operationDate,operationTime,operator,operatorName,terminal,line,borrower,borrowerName) 
                            values (
                                     '" + code + "'," +
                                  "'" + category + "'," +
                                  "'" + materialNumber + "'," +
                                  "'" + number + "'," +
                                  "'" + functionState + "'," +
                                  "'" + "以旧换新出借" + "'," +
                                  "'" + DateTime.Now.ToString("yyyy-MM-dd") + "'," +
                                  "'" + DateTime.Now.ToString("HH:mm:ss") + "'," +
                                  "'" + operator1 + "'," +
                                  "'" + operatorName + "'," +
                                  "'" + MainWindow.TerminalNumber + "'," +
                                  "'" + borrowLine + "'," +
                                  "'" + borrower + "'," +
                                  "'" + borrowerName + "');";
                            connection.Insert(sql);
                        }
                        else
                        {
                            MessageBox.Show("更新工装信息失败!");
                            return;
                        }
                    }

                    //更新人员信息库
                    CommonFunction.UpdatePersonalInfo(borrower, borrowerName, borrowerContact, borrowLine);
                    CommonFunction.UpdatePersonalInfo(operator1, operatorName, operatorContact);

                    MessageBox.Show("换新成功!");
                    this.Close();
                    toolsIn.ToolsReturn_CleanALL();
                    Program.mw.textBox_toolsReturn_code.Focus();
                    return;
                }
                catch
                {
                    MessageBox.Show("数据保存失败!");
                    return;
                }
            }
            else
            {
                MessageBox.Show("工装归还入库失败!");
                return;
            }
        }
Пример #2
0
        public void toolStripButton1_Click()                    //按下工具栏处第一个按钮(更改终端、新购入库、工装方式、工装上架、工装数据)
        {
            Program.mw.toolStripButton1.BackColor = System.Drawing.Color.LightSkyBlue;
            Program.mw.toolStripButton2.BackColor = System.Drawing.SystemColors.ActiveCaption;
            Program.mw.toolStripButton3.BackColor = System.Drawing.SystemColors.ActiveCaption;
            if (Program.mw.toolStripButton1.Text == "更改终端")
            {
                ClientManage clientWindow = new ClientManage();
                clientWindow.ShowDialog();
            }
            if (Program.mw.toolStripButton1.Text == "新购入库")
            {
                Program.mw.panel_newtoolsIn.Visible    = true;
                Program.mw.panel_toolsReturn.Visible   = false;
                Program.mw.panel_repairtoolsIn.Visible = false;
                Program.mw.panel_outByTools.Visible    = false;

                if (Program.mw.checkBox_newToolsIn_batch.Checked == false)                                //非批量入库
                {
                    Program.mw.textBox_newToolsIn_endCode.BackColor = System.Drawing.Color.LightGray;     //结尾编码变灰
                    Program.mw.textBox_newToolsIn_endCode.ReadOnly  = true;                               //结尾编码只读
                }
                Program.mw.textBox_newToolsIn_code.Focus();                                               //默认焦点置于二维码输入框

                ToolsIn ti = new ToolsIn();
                ti.drawListView_newToolsIn(Program.mw.listView_newToolsIn);
                ti.fillListView_newToolsIn(Program.mw.listView_newToolsIn);
            }
            if (Program.mw.toolStripButton1.Text == "工装方式")
            {
                Program.mw.panel_newtoolsIn.Visible    = false;
                Program.mw.panel_toolsReturn.Visible   = false;
                Program.mw.panel_repairtoolsIn.Visible = false;
                Program.mw.panel_outByTools.Visible    = true;

                int listViewWidth       = Screen.PrimaryScreen.Bounds.Width - Program.mw.listView_repairtoolsIn.Location.X * 2 - Program.mw.toolStrip1.Width;
                int listViewHeight      = Screen.PrimaryScreen.Bounds.Height - Program.mw.listView_repairtoolsIn.Location.Y - Program.mw.statusStrip1.Height - Program.mw.menuStrip1.Height - 85;
                int listViewColumnWidth = listViewWidth / 15;
                Program.mw.listView_outByTools.Size          = new System.Drawing.Size(listViewWidth, listViewHeight);
                Program.mw.listView_outByTools.Font          = new System.Drawing.Font("微软雅黑", 8F);
                Program.mw.listView_outByTools.GridLines     = true;
                Program.mw.listView_outByTools.View          = View.Details;
                Program.mw.listView_outByTools.HeaderStyle   = ColumnHeaderStyle.Clickable;                             //表头样式
                Program.mw.listView_outByTools.FullRowSelect = true;                                                    //表示在控件上,是否可以选择一整行
                Program.mw.listView_outByTools.Columns.Add("", 0, HorizontalAlignment.Center);                          //添加(列宽度、列的对齐方式)
                Program.mw.listView_outByTools.Columns.Add("工装编码", listViewColumnWidth, HorizontalAlignment.Center);    //添加(列宽度、列的对齐方式)
                Program.mw.listView_outByTools.Columns.Add("工装名称", listViewColumnWidth, HorizontalAlignment.Center);    //添加
                Program.mw.listView_outByTools.Columns.Add("物料号", listViewColumnWidth, HorizontalAlignment.Center);     //添加
                Program.mw.listView_outByTools.Columns.Add("功能状态", listViewColumnWidth, HorizontalAlignment.Center);    //添加(列宽度、列的对齐方式)
                Program.mw.listView_outByTools.Columns.Add("领用线体", listViewColumnWidth, HorizontalAlignment.Center);    //添加(列宽度、列的对齐方式)
                Program.mw.listView_outByTools.Columns.Add("领用工位", listViewColumnWidth, HorizontalAlignment.Center);    //添加
                Program.mw.listView_outByTools.Columns.Add("用途", listViewColumnWidth, HorizontalAlignment.Center);      //添加
                Program.mw.listView_outByTools.Columns.Add("库位", listViewColumnWidth, HorizontalAlignment.Center);      //添加
                Program.mw.listView_outByTools.Columns.Add("架位", listViewColumnWidth, HorizontalAlignment.Center);      //添加(列宽度、列的对齐方式)
                Program.mw.listView_outByTools.Columns.Add("层位", listViewColumnWidth, HorizontalAlignment.Center);      //添加(列宽度、列的对齐方式)
                Program.mw.listView_outByTools.Columns.Add("领用人", listViewColumnWidth, HorizontalAlignment.Center);     //添加
                Program.mw.listView_outByTools.Columns.Add("领用人姓名", listViewColumnWidth, HorizontalAlignment.Center);   //添加
                Program.mw.listView_outByTools.Columns.Add("领用人联系方式", listViewColumnWidth, HorizontalAlignment.Center); //添加
                Program.mw.listView_outByTools.Columns.Add("厂家", listViewColumnWidth, HorizontalAlignment.Center);      //添加(列宽度、列的对齐方式)
                Program.mw.listView_outByTools.Columns.Add("备注", listViewWidth - listViewColumnWidth * 14, HorizontalAlignment.Center);
            }
        }