Exemplo n.º 1
0
        private void LoadNodeList()
        {
            try
            {
                btnSearch.Enabled = false;
                btnCancel.Enabled = false;
                Cursor.Current    = Cursors.WaitCursor;

                pnlNodeList.Controls.Clear();
                Application.DoEvents();
                int sum = 0;
                List <Model_Waybill_Node> list = new List <Model_Waybill_Node>();
                DataTable dt = WaybillServer.GetWaitUploadNode(10, out sum);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        Model_Waybill_Node n = new Model_Waybill_Node();
                        n.BaseIdk__BackingField      = row["ordernumber"].ToString();
                        n.Contentk__BackingField     = row["content"].ToString();
                        n.Idk__BackingField          = Convert.ToInt32(row["id"]);
                        n.operateAtk__BackingField   = Convert.ToDateTime(row["operateAt"]);
                        n.StorageIdk__BackingField   = Convert.ToInt32(row["storageId"]);
                        n.StorageNamek__BackingField = row["storageName"].ToString();
                        n.Arrivedk__BackingField     = (Enum_Arrived)Enum.ToObject(typeof(Enum_Arrived), Convert.ToInt32(row["Arrived"]));
                        list.Add(n);
                    }
                }
                if (list.Count > 0)
                {
                    for (int i = list.Count - 1; i >= 0; i--)
                    {
                        UCNode c = new UCNode(list[i]);
                        c.Dock = DockStyle.Top;
                        pnlNodeList.Controls.Add(c);
                    }
                    lblInfo.Text = "共" + sum + "条,列表为前10条,点击[刷新]查询";
                }
                else
                {
                    MessageBox.Show("未查询到待上报的节点!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败:" + ex.Message, "查询失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
            finally
            {
                Cursor.Current    = Cursors.Default;
                btnCancel.Enabled = true;
                btnSearch.Text    = "刷新(" + _WaitTime.ToString() + ")";
                timer1.Enabled    = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 保存节点到本地数据库
        /// </summary>
        private void SaveNode()
        {
            bool     result       = false;
            string   exceptionStr = string.Empty;
            string   content      = string.Empty;
            string   number       = txtOrderNumber.Text.Trim();
            DateTime dtNow        = DateTime.Now;

            try
            {
                if (ucConsignors1._SelectConSignor.ConsignorId == -1)
                {
                    try
                    {
                        ucConsignors1.AutoMatchConsignors(ref number);
                    }
                    catch (Exception ex)
                    {
                        exceptionStr = ex.Message;
                        MessageBox.Show(exceptionStr, "请选择供应商", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                        return;
                    }
                    //exceptionStr = "请选择供应商";
                    //MessageBox.Show("请选择是自运单还是第三方单", "请选择供应商", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                    //return;
                }
                FrmParent.ParentForm.CheckNumber(number, false);
                dtNow  = WaybillServer.AddNode(number, _StorageInfo.Id, _StorageInfo.storageName, lblContent.Text.Trim(), chbIsArrive.Checked, ucConsignors1._SelectConSignor.ConsignorId, _StorageInfo.Id, ref content);
                result = true;
                _SaveOkCount++;
                FrmParent.ParentForm.AddSaveOKNumber(_SaveOkCount);
                FrmParent.ParentForm.EndSleep();
            }
            catch (Exception ex)
            {
                exceptionStr = "保存失败";
                if (ex.Message.Contains("重复扫描"))
                {
                    exceptionStr = ex.Message;
                }
            }
            finally
            {
                if (result)
                {
                    FrmParent.ParentForm.AddScanNum(number, false);
                }
                ShowResult(result, true, exceptionStr);
                Common.SaveOptRecord(exceptionStr == string.Empty ? "保存运抵节点成功" : ("保存运抵节点失败," + exceptionStr), content, dtNow, number, ucConsignors1._SelectConSignor.ConsignorId);
                ucConsignors1.SelectedConsignors();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 上传节点
        /// </summary>
        private static void UploadNode()
        {
            ResultModelOfboolean      result = new ResultModelOfboolean();
            List <Model_Waybill_Node> list   = new List <Model_Waybill_Node>();
            string msg = string.Empty;
            string err = string.Empty;

            try
            {
                DataTable dt = WaybillServer.GetNotUploadNode(Common._MaxUploadNodeCount);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        Model_Waybill_Node n = new Model_Waybill_Node();
                        n.BaseIdk__BackingField      = row["ordernumber"].ToString();
                        n.Contentk__BackingField     = row["content"].ToString();
                        n.Idk__BackingField          = Convert.ToInt32(row["id"]);
                        n.operateAtk__BackingField   = Convert.ToDateTime(row["operateAt"]);
                        n.StorageIdk__BackingField   = Convert.ToInt32(row["storageId"]);
                        n.StorageNamek__BackingField = row["storageName"].ToString();
                        n.Arrivedk__BackingField     = (Enum_Arrived)Enum.ToObject(typeof(Enum_Arrived), Convert.ToInt32(row["Arrived"]));
                        list.Add(n);
                        msg = n.BaseIdk__BackingField;
                    }
                    FrmParent.ParentForm.SetNewInfo("正在上报节点" + msg + ",请稍候...", null);
                    result = Common._PdaServer.UploadWaybill_Node(list.ToArray());
                }
            }
            catch (Exception ex)
            {
                err = ex.Message;
                throw ex;
            }
            finally
            {
                if (result.Data)
                {
                    WaybillServer.DeleteUploadSuccessNode(list.Select(l => l.Idk__BackingField.ToString()).ToList());
                }
                else if (string.IsNullOrEmpty(err))
                {
                    err = result.Message;
                }
                err = err == null ? string.Empty : err;
                FrmParent.ParentForm.SetNewInfo(string.Format("{0}{1} {2}", (msg.Length == 0 ? "没有待上报的节点." : "上报节点"), msg, (err.Length == 0 ? (msg.Length == 0 ? "" : "成功") : "失败 " + err)), err.Length == 0);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 保存节点到本地数据库
        /// </summary>
        private void SaveNode()
        {
            bool   result       = false;
            string exceptionStr = string.Empty;

            try
            {
                WaybillServer.AddNode(txtOrderNumber.Text.Trim(), _StorageInfo.Id, _StorageInfo.storageName, lblContent.Text.Trim(), chbIsArrive.Checked);
                result = true;
            }
            catch (Exception ex)
            {
                exceptionStr = "保存数据出错:[" + ex.Message + "]";
            }
            ShowResult(result, true, exceptionStr);
        }
Exemplo n.º 5
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     FrmParent.ParentForm.ResetReturnDelay();
     if (CheckInput() && FrmParent.ParentForm._UCRecevInfo.CheckInput() && FrmParent.ParentForm._UCSenderInfo.CheckInput())
     {
         string   saveErr   = string.Empty;
         string   content   = string.Empty;
         DateTime orderTime = DateTime.Now;
         try
         {
             string number = txtOrderNumber.Text.Trim();
             FrmParent.ParentForm.CheckNumber(number, false);
             Customer sc          = FrmParent.ParentForm._UCSenderInfo._CustomerInfo;
             Customer rc          = FrmParent.ParentForm._UCRecevInfo._CustomerInfo;
             int      sId         = (int)sc.Id;                             // Convert.ToInt32(cboSenderCustomer.SelectedValue);
             string   sOrg        = sc.FullName;                            // cboSenderCustomer.Text.Trim();
             string   sPerson     = sc.ContactPerson;                       // txtSenderName.Text.Trim();
             string   sTel        = sc.ContactTel;                          // txtSenderPhone.Text.Trim();
             string   sAddress    = sc.ContactAddress;                      // cboSenderPId.Text + cboSenderCId.Text + txtSenderAddress.Text.Trim();
             string   rId         = rc.Id == 0 ? "NULL" : rc.Id.ToString(); // cboReceiverCustomer.SelectedIndex < 1 ? "NULL" : cboReceiverCustomer.SelectedValue.ToString();
             string   rOrg        = rc.FullName;                            // cboReceiverCustomer.Text.Trim();
             string   rPerson     = rc.ContactPerson;                       // txtReceiverName.Text.Trim();
             string   rTel        = rc.ContactTel;                          // txtReceiverPhone.Text.Trim();
             string   rAddress    = rc.ContactAddress;                      // cboReceiverPId.Text + cboReceiverCId.Text + txtReceiverAddress.Text.Trim();
             int      bCount      = (int)nudCount.Value;
             string   storageName = Common._StorageName;
             orderTime = WaybillServer.AddOrder(number, sId, sOrg, sPerson, sTel, sAddress, rId, rOrg, rPerson, rTel, rAddress, bCount, storageName, Common._Destination, ref content);
             FrmParent.ParentForm.EndSleep();
         }
         catch (Exception ex)
         {
             saveErr = ex.Message;
             MessageBox.Show(ex.Message, "创建运单失败", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
         }
         finally
         {
             txtOrderNumber.Focus();
             Common.SaveOptRecord(saveErr == string.Empty ? "创建运单成功" : ("创建运单失败:" + saveErr), content, orderTime, txtOrderNumber.Text.Trim(), 0);
             if (saveErr == string.Empty)
             {
                 FrmParent.ParentForm.AddScanNum(txtOrderNumber.Text.Trim(), false);
                 MessageBox.Show("添加成功,您可以继续扫码添加!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
             }
             txtOrderNumber.Text = string.Empty;
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// 上传图片
        /// </summary>
        private static void UploadPic()
        {
            ResultModelOfboolean       result   = new ResultModelOfboolean();
            Model_Waybill_Postback_Pic picModel = new Model_Waybill_Postback_Pic();
            DateTime      postbackTime          = DateTime.Now;
            List <object> picBytesList          = new List <object>();
            string        msg = string.Empty;
            string        err = string.Empty;

            try
            {
                DataTable dt = WaybillServer.GetPostBackPic();
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataRow row = dt.Rows[0];
                    picModel.Idk__BackingField      = Convert.ToInt32(row["id"]);
                    picModel.BaseIdk__BackingField  = row["baseId"].ToString();
                    picModel.PicNamek__BackingField = row["picName"].ToString();
                    postbackTime = Convert.ToDateTime(row["postbackTime"]);
                    //获取图片信息
                    foreach (string picPath in picModel.PicNamek__BackingField.Split('|'))
                    {
                        picBytesList.Add(GetGZipPicBytes(picPath));
                    }
                    msg = picModel.PicNamek__BackingField.Split('\\').Last();
                    FrmParent.ParentForm.SetNewInfo("正在上报图片" + msg + ",请稍候...", null);
                    result = Common._PdaServer.UploadWaybill_Postback(picModel, postbackTime, true, picBytesList.ToArray());
                }
            }
            catch (Exception ex)
            {
                try
                {
                    if (ex.Message.Contains("未能找到文件"))
                    {
                        WaybillServer.DeleteUploadSuccessPostback(picModel.Idk__BackingField);
                    }
                }
                catch
                {
                }
                err = ex.Message;
                throw ex;
            }
            finally
            {
                if (result.Data && picBytesList.Count > 0)
                {
                    //删除图片
                    foreach (string picPath in picModel.PicNamek__BackingField.Split('|'))
                    {
                        File.Delete(picPath);
                    }
                    //删除数据
                    WaybillServer.DeleteUploadSuccessPostback(picModel.Idk__BackingField);
                }
                else if (string.IsNullOrEmpty(err))
                {
                    err = result.Message;
                }
                err = err == null ? string.Empty : err;
                FrmParent.ParentForm.SetNewInfo(string.Format("{0}{1} {2}", (msg.Length == 0 ? "没有待上报的图片." : "上报图片"), msg, (err.Length == 0 ? (msg.Length == 0 ? "" : "成功") : "失败 " + err)), err.Length == 0);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 上传第三方运单号
        /// </summary>
        private static int UploadThirdOrder()
        {
            ResultModelOfint result = new ResultModelOfint();
            //List<Model_Huadong_Tms_Order> list = new List<Model_Huadong_Tms_Order>();
            string msg = string.Empty;
            string err = string.Empty;
            Model_ThirdPartOrder hdOrder = null;

            try
            {
                //根据每次查询运单数量为条件查询几条信息
                DataTable dt = HuadongTmsOrderServer.GethuadongTmsOrder(Common._MaxUploadOrderCount);
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataRow row = dt.Rows[0];
                    hdOrder = new Model_ThirdPartOrder();
                    hdOrder.Idk__BackingField         = Convert.ToInt32(row["id"]);
                    hdOrder.RelationIdk__BackingField = row["relationId"].ToString();
                    hdOrder.OperateAtk__BackingField  = row["OperateAt"].ToString();
                    int consignorId = 0;
                    if ((row["consignorId"] is DBNull) == false)
                    {
                        consignorId = Convert.ToInt32(row["consignorId"]);
                    }
                    if (_isContinue)
                    {
                        return(0);
                    }
                    FrmParent.ParentForm.SetNewInfo("正在上报第三方运单" + hdOrder.RelationIdk__BackingField + ",请稍候...", null);
                    result = Common._PdaServer.UploadThirdOrderForCustomer(hdOrder, consignorId, true);

                    //foreach (DataRow row in dt.Rows)
                    //{
                    //    Model_Huadong_Tms_Order huadong = new Model_Huadong_Tms_Order();
                    //    huadong.Idk__BackingField = Convert.ToInt32(row["id"]);
                    //    huadong.RelationIdk__BackingField = row["relationId"].ToString();
                    //    list.Add(huadong);
                    //    msg = huadong.RelationIdk__BackingField;
                    //}
                    //FrmParent.ParentForm.SetNewInfo("正在上报第三方运单" + msg + ",请稍候...", null);
                    ////后台接口,上传数据
                    //result = Common._PdaServer.UploadHuadongTmsOrder(list.ToArray());
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                err = ex.Message;
                throw ex;
            }
            finally
            {
                if (result.Data == 1 || result.Data == 2)
                {
                    HuadongTmsOrderServer.DeleteUploadHuadongTmsOrder(new List <string>()
                    {
                        hdOrder.RelationIdk__BackingField
                    });
                    if (result.Data == 2 && hdOrder != null)
                    {
                        WaybillServer.DeleteThirdNodeByOptAt(hdOrder.RelationIdk__BackingField, hdOrder.OperateAtk__BackingField);
                    }
                }
                else if (string.IsNullOrEmpty(err))
                {
                    err = result.Message;
                }
                err = err == null ? string.Empty : err;
                FrmParent.ParentForm.SetNewInfo(string.Format("{0}{1} {2}", (msg.Length == 0 ? "没有待上报的第三方运单." : "上报第三方运单"), msg, (err.Length == 0 ? (msg.Length == 0 ? "" : "成功") : "失败 " + err)), err.Length == 0);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 保存签收图片
        /// </summary>
        private void btnSavePic_Click(object sender, EventArgs e)
        {
            FrmParent.ParentForm.ResetReturnDelay();
            //if (txtOrderNumber.Text.Trim().Length != 12)
            string number = txtOrderNumber.Text.Trim();

            if (number == string.Empty)
            {
                MessageBox.Show("请通过扫描或手工录入正确的运单编号!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                return;
            }
            if (btnCamera.Text == "拍摄")
            {
                MessageBox.Show("请完成当前照片的拍摄或按[-]删除掉再保存!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                return;
            }
            if (MessageBox.Show(string.Format("编号[{0}] 图片[{1}]张", number, lbPicList.Items.Count), "确定要保存吗?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
            {
                return;
            }
            bool   result       = true;
            string exceptionStr = string.Empty;

            try
            {
                if (ucConsignors1._SelectConSignor.ConsignorId == -1)
                {
                    try
                    {
                        ucConsignors1.AutoMatchConsignors(ref number);
                    }
                    catch (Exception ex)
                    {
                        result       = false;
                        exceptionStr = ex.Message;
                        MessageBox.Show(exceptionStr, "请选择供应商", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                        return;
                    }
                    //result = false;
                    //exceptionStr = "请选择供应商";
                    //MessageBox.Show("请选择是自运单还是第三方单", "请选择供应商", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                    //return;
                }
                //检查缓存文件
                List <FileInfo> fileList = new List <FileInfo>();
                foreach (PicNameAndPath item in lbPicList.Items)
                {
                    try
                    {
                        fileList.Add(new FileInfo(item.PicPath + ".jpg"));
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("获取缓存图片[" + item.PicName + "]出错:[" + ex.Message + "]");
                    }
                }
                //创建保存路径
                string savePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase.ToString()) + "\\postback\\";
                if (!Directory.Exists(savePath))
                {
                    Directory.CreateDirectory(savePath);
                }
                List <string> filePathList = new List <string>();
                //移动缓存文件
                foreach (FileInfo fi in fileList)
                {
                    try
                    {
                        string newFileName = savePath + fi.Name;
                        fi.MoveTo(newFileName);
                        filePathList.Add(newFileName);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("保存缓存图片[" + fi.Name + "]出错:[" + ex.Message + "]");
                    }
                }
                //保存文件路径
                string   content = string.Empty;
                DateTime dtNow   = DateTime.Now;
                try
                {
                    //SaveNode();
                    txtOrderNumber.Text = number;
                    dtNow = WaybillServer.AddPostBack(number, filePathList, ucConsignors1._SelectConSignor.ConsignorId, ref content);
                    Common.SaveOptRecord("保存签收图片成功", content, dtNow, number, ucConsignors1._SelectConSignor.ConsignorId);
                    FrmParent.ParentForm.EndSleep();
                }
                catch (Exception ex)
                {
                    Common.SaveOptRecord("保存签收图片失败:" + ex.Message, content, dtNow, number, ucConsignors1._SelectConSignor.ConsignorId);
                    throw new Exception("保存失败:[" + ex.Message + "]");
                }
                InitPhoto();
            }
            catch (Exception ex)
            {
                result       = false;
                exceptionStr = ex.Message;
                //exceptionStr = "保存失败";
                //if (ex.Message.Contains("重复扫描"))
                //    exceptionStr = ex.Message;
            }
            finally
            {
                ShowResult(result, false, exceptionStr);
                ucConsignors1.SelectedConsignors();
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 保存签收图片
        /// </summary>
        private void btnSavePic_Click(object sender, EventArgs e)
        {
            //if (txtOrderNumber.Text.Trim().Length != 12)
            if (txtOrderNumber.Text.Trim() == string.Empty)
            {
                MessageBox.Show("请通过扫描或手工录入正确的运单编号!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                return;
            }
            if (btnCamera.Text == "拍摄")
            {
                MessageBox.Show("请完成当前照片的拍摄或按[-]删除掉再保存!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                return;
            }
            if (MessageBox.Show(string.Format("编号[{0}] 图片[{1}]张", txtOrderNumber.Text.Trim(), lbPicList.Items.Count), "确定要保存吗?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
            {
                return;
            }
            bool   result       = true;
            string exceptionStr = string.Empty;

            try
            {
                //检查缓存文件
                List <FileInfo> fileList = new List <FileInfo>();
                foreach (PicNameAndPath item in lbPicList.Items)
                {
                    try
                    {
                        fileList.Add(new FileInfo(item.PicPath));
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("获取缓存图片[" + item.PicName + "]出错:[" + ex.Message + "]");
                    }
                }
                //创建保存路径
                string savePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase.ToString()) + "\\postback\\";
                if (!Directory.Exists(savePath))
                {
                    Directory.CreateDirectory(savePath);
                }
                List <string> filePathList = new List <string>();
                //移动缓存文件
                foreach (FileInfo fi in fileList)
                {
                    try
                    {
                        string newFileName = savePath + fi.Name;
                        fi.MoveTo(newFileName);
                        filePathList.Add(newFileName);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("保存缓存图片[" + fi.Name + "]出错:[" + ex.Message + "]");
                    }
                }
                //保存文件路径
                try
                {
                    WaybillServer.AddPostBack(txtOrderNumber.Text.Trim(), filePathList);
                }
                catch (Exception ex)
                {
                    throw new Exception("保存数据出错:[" + ex.Message + "]");
                }
                InitPhoto();
            }
            catch (Exception ex)
            {
                result       = false;
                exceptionStr = ex.Message;
            }
            finally
            {
                ShowResult(result, false, exceptionStr);
            }
        }