Example #1
0
        //投快递
        private void button_SendPKG_Click(object sender, EventArgs e)
        {
            string SD_usr_phone = textBox_SD_usr_phone.Text.Trim();
            string SD_exp_no = textBox_SD_express_No.Text.Trim();
            string SD_usr_name = "王";
            string boxDX = comboBox_size.Text.Trim();

            if(SD_usr_phone=="" || SD_exp_no=="") //输入规则检查
            {
                label_SendPKG_status.Text = "输入有误,请重新输入!";
                return ;
            }
            if (textBox_SD_usr_name.Text.Trim() != "")
            {
                SD_usr_name = textBox_SD_usr_name.Text.Trim();
            }

            //返回合适的空箱子
            boxDX = "1";
            string BoxID=MyBox.FindBox(boxDX);
            if (BoxID == "") //无合适箱子
            {
                label_SendPKG_status.Text = "该规格箱子已满,请重新选择!";
            }
            else
            {

                //打开箱子
                if(MyBox.OpenBox(BoxID)) //打开成功,成功存包
                {
                    #region
                    //语音提示

                    //产生8位随机提取码
                    Encrypt eBoxEncrypt=new Encrypt();
                    string SD_usr_Code=eBoxEncrypt.GenUserCode();
                    DateTime TimeNow= System.DateTime.Now.ToLocalTime();

                    try
                    {
                        OleCon = new OleDbConnection(strcon);
                        OleCon.Open();
                        //更新存包记录数据库
                        string sql = String.Format("Insert into PKG_RECORD(Ebox_No,User_phone,User_Code,Postman_No,Box_ID,Time_Save,Exp_Num) Values('{0}','{1}','{2}','{3}','{4}',#{5:G}#,'{6}')", Ebox_No, SD_usr_phone, SD_usr_Code, Login_PSTM_phone, BoxID, TimeNow, SD_exp_no);
                        OleCom = new OleDbCommand(sql, OleCon);
                        int PassOk = OleCom.ExecuteNonQuery();
                        Console.WriteLine(PassOk);

                        //更新箱子信息数据库
                        //更新box_manage数据库,设置对应箱子为满
                        sql = "Update BOX_MANAGE Set  BOX_MANAGE.Empty_State=false,BOX_MANAGE.Time_update=#" +TimeNow + "# where BOX_MANAGE.Box_ID='" + BoxID + "'";
                        OleCom = new OleDbCommand(sql, OleCon);
                        int ReturnVal = OleCom.ExecuteNonQuery();
                        Console.WriteLine(ReturnVal);

                    }
                    catch(Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    finally
                    {
                        OleCon.Close();
                    }

                    //更新空箱数
                    Box_Num_used += 1;
                    Box_Used_amount += 1;

                    //更新快递员余额数据库
                    ebox_webservice.ebox_serviceSoapClient ebox_webserver = new ebox_webservice.ebox_serviceSoapClient();
                    Login_PSTM_balance=ebox_webserver.Postman_Spend(Login_PSTM_phone,1);
                    toolStripStatusLabel1.Text = "快递员:" + Login_PSTM_phone + ", 欢迎您!  余额:" + Login_PSTM_balance.ToString();

                    //超时计时开始
                    label_SendPKG_status.Text = BoxID+"箱已打开,请存入包裹,关好箱门!";
                    textBox_SD_usr_phone.Text = "";
                    textBox_SD_express_No.Text = "";

                    ShowEboxStatus();
                    #endregion
                }
                else //打开失败
                {
                    label_SendPKG_status.Text = "打开箱子失败,请重新选择!";
                }
            }
        }