예제 #1
0
        public void CancelOrder()
        {
            SOHeaderEntity header = IParent.GetFocusedBill();

            if (header == null)
            {
                MsgBox.Warn("请选择要“取消”的订单。");
                return;
            }
            //先从界面上判断一下,减少网络交互和数据库负载
            if (header.Status == "693")
            {
                MsgBox.Warn(string.Format("单据“{0}”已发车,不允许取消。", header.BillNO));
                return;
            }
            else if (header.CancelFlag == 1)
            {
                MsgBox.Warn(string.Format("单据“{0}”已经被“取消”,不允许多次执行。", header.BillNO));
                return;
            }
            if (MsgBox.AskOK(string.Format("确认要将单据“{0}”执行“取消”操作吗?", header.BillNO)) != DialogResult.OK)
            {
                return;
            }
            try
            {
                FrmTempAuthorize frmAuthorize = new FrmTempAuthorize("称重复核员");
                if (frmAuthorize.ShowDialog() == DialogResult.OK)
                {
                    //string errorStr = soDal.CancelBill(header.BillID, GlobeSettings.LoginedUser.UserName);
                    //if (string.IsNullOrEmpty(errorStr))
                    bool errorStr = CancelBill(header.BillID, GlobeSettings.LoginedUser.UserName,
                                               EUtilStroreType.WarehouseTypeToInt(GlobeSettings.LoginedUser.WarehouseType));
                    if (errorStr)
                    {
                        //成功,刷新界面即可,不再提示
                        Query(1, DateTime.Now, DateTime.Now);
                        IParent.RefreshHeaderGrid();
                        // 如果为整货仓,提示用户;如果该订单物流箱已接收,系统已将商品库存转移到900货位
                        if (GlobeSettings.LoginedUser.WarehouseType == EWarehouseType.整货仓)
                        {
                            MsgBox.OK("如果当前订单存在已接收的物流箱,系统会将散货商品转移到900-01-01货位。");
                        }
                        // 存储过程中已在 WM_SO_LOG 表里记录日志
                        //LogDal.Insert(ELogType.订单状态变更, GlobeSettings.LoginedUser.UserName, header.BillNO, "称重复核员:" + frmAuthorize.AuthUserCode, "出库单管理");
                    }
                    //else
                    //{
                    //    throw new Exception(errorStr);
                    //}
                }
            }
            catch (Exception ex)
            {
                MsgBox.Err(ex.Message);
            }
        }
예제 #2
0
        private bool Save()
        {
            FrmTempAuthorize frmAuthorize = new FrmTempAuthorize("称重复核员");

            if (frmAuthorize.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            if (!IsFieldValueValid())
            {
                return(false);
            }

            try
            {
                bool   isCreateNew = (unitGrpEntity == null);
                string skuCode     = listSku.EditValue.ToString();
                string skuLevel    = txtSkuLevel.Text.Trim();
                //int result = ugDal.Save(listUnit1.EditValue.ToString(), ConvertUtil.ToInt(txtCount.Text.Trim()), skuCode, txtBarcode.Text.Trim(), ConvertUtil.ToDecimal(txtWeight.Text.Trim()),
                //    ConvertUtil.ToDecimal(txtChang.Text.Trim()), ConvertUtil.ToDecimal(txtKuan.Text.Trim()), ConvertUtil.ToDecimal(txtGao.Text.Trim()), comboIsActive.Text, this.unitGrpEntity == null ? 0 : this.unitGrpEntity.ID, isCreateNew);
                //if (result == 0)
                //{
                //    string warnMsg = string.Format("未成功更新物料 {0} 层级为 {1} 的包装关系信息,\r\n最可能的原因:未维护当前物料层级的包装关系基础信息或者该包装关系没启用,\r\n请联系技术人员进行维护。", skuCode, skuLevel);
                //    MsgBox.Warn(warnMsg);
                //    return false;
                //}
                //if (result == -1)
                //{
                //    MsgBox.Warn("编号已经存在,请改为其他的编号。");
                //    return false;
                //}
                bool ret = SaveUpdateUmSku(listUnit1.EditValue.ToString(), ConvertUtil.ToInt(txtCount.Text.Trim()), skuCode, txtBarcode.Text.Trim(), ConvertUtil.ToDecimal(txtWeight.Text.Trim()),
                                           ConvertUtil.ToDecimal(txtChang.Text.Trim()), ConvertUtil.ToDecimal(txtKuan.Text.Trim()), ConvertUtil.ToDecimal(txtGao.Text.Trim()), comboIsActive.Text, this.unitGrpEntity == null ? 0 : this.unitGrpEntity.ID, isCreateNew);
                if (ret)
                {
                    Insert(ELogType.修改包装关系, String.Format("操作人:{0};授权人:{1}", GlobeSettings.LoginedUser.UserName, frmAuthorize.AuthUserCode), skuCode, "包装关系");

                    if (DataSourceChanged != null)
                    {
                        DataSourceChanged(null, null);
                    }

                    return(true);
                }
            }
            catch (Exception ex)
            {
                MsgBox.Err(ex.Message);
                return(false);
            }

            return(false);
        }
예제 #3
0
        public void SetBillState()
        {
            SOHeaderEntity header = IParent.GetFocusedBill();

            if (header == null)
            {
                MsgBox.Warn("请选中要设置为“等待发货”的行。");
                return;
            }
            if (header.Status != "61")
            {
                MsgBox.Warn("只有等待拣配的订单才能设置等待装车。");
                return;
            }
            try
            {
                using (FrmTempAuthorize frmAuto = new FrmTempAuthorize("称重复核员"))
                {
                    if (frmAuto.ShowDialog() == DialogResult.OK)
                    {
                        //int ret = soDal.SetBillStates(header.BillID, "66", 0);
                        //if (ret > 0)
                        bool ret = SetBillStatesSend(header.BillID, "66", 0, GlobeSettings.LoginedUser.UserName);
                        if (ret)
                        {
                            Query(1, DateTime.Now, DateTime.Now);
                        }
                        else
                        {
                            MsgBox.Warn("该订单已经生成拣货任务,必须按照流程完成订单。");
                        }
                        //LogDal.Insert(ELogType.订单状态变更, GlobeSettings.LoginedUser.UserName, header.BillNO, "手动[等待装车]", "出库单管理");
                    }
                }
            }
            catch (Exception ex)
            {
                MsgBox.Err(ex.Message);
            }
        }
예제 #4
0
        /// <summary>
        /// 散货称重 主流程
        /// </summary>
        private void SaveAndPrint()
        {
            string strWeight = lblCurrentWright.Text;
            string ctCode = txtBox.Text.Trim();
            string customer = "", billNO = "", address = "", contact = "";
            int    billID;
            int    cancelFlag = 0;

            decimal weight = 0, containerWeight = 0;

            txtBox.Text    = "";
            lblCtCode.Text = ctCode;

            //确认读取的电子称重量是否有效
            try
            {
                weight = ConvertUtil.ToDecimal(strWeight);
                if (weight <= 0)
                {
                    lblMsg.Show("读取的称重数据无效,必须为大于0的数值。", false);
                    return;
                }

                //转换为克,更精确
                weight = weight * 1000;
            }
            catch (Exception ex)
            {
                lblMsg.Show(ex.Message, false);
                return;
            }

            //开始处理保存到数据库
            try
            {
                //获取物流箱绑定的订单信息
                DataTable dt = this.soDal.GetSOBillMsg(ctCode);
                if (dt == null || dt.Rows.Count == 0)
                {
                    lblMsg.Show("该物流箱未绑定订单!", false);
                    return;
                }

                DataRow row = dt.Rows[0];

                //本单拣货必须全部完成才可以称重
                string billState = ConvertUtil.ToString(row["BILL_STATE"]);

                billID          = ConvertUtil.ToInt(row["BILL_HEAD_ID"].ToString());
                customer        = ConvertUtil.ToString(row["C_NAME"]);
                address         = ConvertUtil.ToString(row["ADDRESS"]);
                contact         = ConvertUtil.ToString(row["CONTACT"]);
                containerWeight = ConvertUtil.ToDecimal(row["CT_WEIGHT"]) / 1000;
                billNO          = ConvertUtil.ToString(row["BILL_NO"]);
                cancelFlag      = ConvertUtil.ToInt(row["CANCEL_FLAG"]); // 取消标记
                if (cancelFlag == 1 && soDal.GetWeightRecordsCountByBillID(billID, ctCode) == 0)
                {
                    lblMsg.Show("该订单已取消,不允许再称重", false);
                    return;
                }
                lblBillNO.Text = billNO;

                DataTable dtContaner = ShowContainerSku(billID, ctCode);
                decimal   netWeight  = ConvertUtil.ToDecimal(dtContaner.Compute("SUM(LINE_WEIGHT)", null)) / 1000;
                lblCalcWeight.Text = string.Format("{0:f2}={1:f2}+{2:f2}", netWeight + containerWeight, netWeight, containerWeight);

                ////判断整货完毕进行称重
                //if (billState != BaseCodeConstant.SO_WAIT_WEIGHT && billState != BaseCodeConstant.SO_WAIT_LOADING)
                //{
                //    lblMsg.Show("该物流箱绑定订单拣货尚未全部完成!", false);
                //    return;
                //}

                //读取箱子的序号以及是否为最后一个箱子,还要防止重复称重
                int ctWeightIndex;
                int ctTotalCount;
                //decimal lastWeight = 0;
                int result = this.soDal.SaveCheckWeightWLX(ctCode, weight, GlobeSettings.LoginedUser.UserCode, null, out ctWeightIndex, out ctTotalCount);
                if (result == -1)
                {
                    lblMsg.Show("该物流箱未绑定订单!", false);
                    return;
                }
                if (result == -3)
                {
                    lblMsg.Show("订单散货任务尚未完成,请稍后再称重该订单的物流箱!", false);
                    return;
                }
                else if (result == 1) //表示已称重过,重量更新了,补打一张标签
                {
                    lblMsg.Show("补打标签。", true);
                    PrintLabel(ctCode, ctTotalCount, ctWeightIndex, customer, address, contact, billNO, billID, lblCurrentWright.Text);
                }
                else if (result == 2) //表示不是最后一个箱子,保存成功了,不用打印
                {
                    //什么也不用干
                }
                else if (result == 3) //最后一个箱子,需要打印标签
                {
                    PrintBill(billID, customer, address, contact, billNO);
                }
                else if (result == -2) //最后一个箱子,重量有问题,需要打印标签
                {
                    ShowBillContainers(billID, weight / 1000);

                    FrmTempAuthorize frm = new FrmTempAuthorize("称重复核员");
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        result = this.soDal.SaveCheckWeightWLX(ctCode, weight,
                                                               GlobeSettings.LoginedUser.UserCode, frm.AuthUserCode, out ctWeightIndex, out ctTotalCount);

                        if (result > 0)
                        {
                            PrintBill(billID, customer, address, contact, billNO);
                        }
                    }
                }
                else
                {
                    lblMsg.Show("未知错误!", false);
                }

                ShowBillContainers(billID, 0);
                lblCtCode.Text = ctCode;
                Clear();
            }
            catch (Exception ex)
            {
                MsgBox.Err(ex.Message);
                txtBox.SelectAll();
            }
        }
예제 #5
0
        /// <summary>
        /// 车次整货称重主流程
        /// </summary>
        private void Save()
        {
            string strWeight = lblCurrentWeight.Text; //实际称的重
            string ctCode    = txtBoxForContainerCode.Text.Trim();

            lblCtCode.Text = ctCode;

            txtBoxForContainerCode.SelectAll();   //扫描后选择待下次扫描替换
            txtBoxForContainerCode.Focus();

            //确认读取的电子称重量是否有效
            try
            {
                realWeight = ConvertUtil.ToDecimal(strWeight);
                if (realWeight <= 0)
                {
                    lblMsg.Show("读取的电子称数据无效,必须为大于0的数值,请联系管理员。", false);
                    return;
                }

                //转换为克,更精确
                realWeight = realWeight * 1000;
            }
            catch (Exception ex)
            {
                lblMsg.Show(ex.Message, false);
                return;
            }

            try
            {
                if (lookUpEditForVehicles.Text == "")
                {
                    lblMsg.Show("请选择车辆。", false);
                    return;
                }

                if (!ctCode.StartsWith("30") || ctCode == "" || ctCode.Length <= 2)
                {
                    lblMsg.Show("请扫描托盘!", false);
                    return;
                }

                //先刷新一下最新托盘列表
                ReloadContainers();

                //获得当前托盘所关联的订单信息
                soHeader = this.soWeightDal.GetBillInfoByContainer(ctCode);
                if (soHeader == null)
                {
                    lblMsg.Show("该托盘没有相关的订单信息,请检查。", false);
                    return;
                }

                //如果查到对应的单据,就显示到界面上,无法后面的验证是否有问题
                ShowBillInfo(soHeader);

                //判断单据状态是否为等待称重65以及66(等待装车,有可能称重出现了问题,需要重新称,只要没有发出去就应该允许重新称重)
                if (soHeader.Status != "65" && soHeader.Status != "66")
                {
                    lblMsg.Show("该托盘所属订单的状态不是等待称重或等待装车,请检查。", false);
                    return;
                }

                //获得当前托盘相关的 车次(如"SO2015081801050858")
                string tuoPanVehicleNo = this.soWeightDal.GetVehicleTripByCurrentContainer(ctCode);
                if (tuoPanVehicleNo == null)
                {
                    lblMsg.Show("该托盘没有相关车次信息,请检查。", false);
                    return;
                }

                string displayVehicleNo = this.lblVehicleNo.Text.Trim(); //界面显示的车次
                if (displayVehicleNo.Length < 16)                        //(首单的车次)车次称重完毕后需要设置为空
                {
                    lblVehicleNo.Text = displayVehicleNo = tuoPanVehicleNo;
                    this.lookUpEditForVehicles.Enabled = false;
                    //显示当前车次所有散货的预估件数
                    lblBulkNum.Text = ConvertUtil.ToString(this.soWeightDal.GetSoBillIdsByVehicleNo(displayVehicleNo));
                }
                this.vehicleTripContainers = ShowVehicleTripContainers(tuoPanVehicleNo, soHeader.BillID, ctCode, realWeight / 1000);

                if (tuoPanVehicleNo != displayVehicleNo)  //是否同车次
                {
                    lblMsg.Show(string.Format("托盘所属订单的车次[{0}]不在当前车次内,请检查。", tuoPanVehicleNo), false);
                    return;
                }

                //如果上一个单据称重没有全部完成,不能换单据
                if (BillID != -1 && BillID != soHeader.BillID)
                {
                    lblMsg.Show("上一个单据未完成称重,请检查。", false);
                    return;
                }

                this.BillID = soHeader.BillID;

                //当前车辆信息
                VehicleEntity vehicle = this.soWeightDal.GetVehicleIDByNO(Nodes.Utils.ConvertUtil.ToString(lookUpEditForVehicles.EditValue));
                //获得系统设置的标准偏差
                decimal diffSet = Nodes.Utils.ConvertUtil.ToDecimal(soWeightDal.GetSystemDiffSet("物流箱标准偏差"));
                //称重复核员
                string authUserCode = string.Empty;
                //检查是否有散件
                bool hasCase2 = true;

                //记录当前单据的所有托盘数量
                //tuoPanAllNum = this.vehicleTripContainers.Select("CT_TYPE = 50").Length;
                tuoPanAllNumByBill = this.vehicleTripContainers.Select(string.Format("BILL_ID = '{0}'", soHeader.BillID)).Length;

                bool isLastTuoPan = false;
                //查看是否为最后一个托盘
                if (tuoPanAllNumByBill - tuoPanWeightedByBill.Count == 1 && !tuoPanWeightedByBill.Contains(ctCode))
                {
                    isLastTuoPan = true;
                }

                if (isLastTuoPan)
                {
                    //检查是否超出偏差,超出偏差,要复核
                    decimal diffNow = Nodes.Utils.ConvertUtil.ToDecimal(lblDiffByPallet.Text) * 1000;
                    if (Math.Abs(diffNow) > diffSet)
                    {
                        lblMsg.Show("重量偏差过大!请检查。", false);
                        FrmTempAuthorize fta = new FrmTempAuthorize("称重复核员");
                        if (fta.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                        authUserCode = fta.AuthUserCode;
                    }

                    CheckUpdateAndLog(authUserCode, ctCode, vehicle.VehicleCode, tuoPanVehicleNo);

                    //检查是否有散件
                    hasCase2 = this.soWeightDal.IsHasCase2(this.BillID);
                    if (!hasCase2)
                    {
                        //更新全整货订单状态
                        this.soWeightDal.UpdateCurrentBillState(this.BillID, vehicle.ID, "66");
                    }
                    else
                    {
                        //只关联车辆
                        this.soWeightDal.UpdateCurrentBillState(this.BillID, vehicle.ID);
                    }

                    //写入出库单日志
                    this.soWeightDal.InsertSoLog(this.BillID, "整货称重完毕", DateTime.Now, GlobeSettings.LoginedUser.UserName);

                    lblMsg.Show("通过,订单称重完毕!", true);

                    //检验已称重托盘并循环判断是否重复,不重复的加入当前车次已称重托盘
                    foreach (string item in tuoPanWeightedByBill)
                    {
                        if (!tuoPanWeightedByCar.Contains(item))
                        {
                            tuoPanWeightedByCar.Add(item);
                        }
                    }

                    //当前车次的托盘 全部称重完毕
                    if (tuoPanWeightedByCar.Count == vehicleTripContainers.Rows.Count)
                    {
                        MessageBox.Show("当前车次的整货全部称重完毕,请在手持[散货装车]上确认车辆物流箱。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        lookUpEditForVehicles.Enabled = true;
                        //初始化Car级数据
                        lookUpEditForVehicles.EditValue = null;
                        lblVehicleNo.Text   = string.Empty;
                        lblBulkNum.Text     = "0";
                        tuoPanWeightedByCar = new List <string>();
                    }

                    //初始化Bill级数据
                    InitWeightShowInfo();
                }
                else  //不是最后一个托盘
                {
                    //检查是否超出偏差,超出偏差,要复核
                    decimal diffNow = Nodes.Utils.ConvertUtil.ToDecimal(lblDiffByPallet.Text) * 1000;
                    if (Math.Abs(diffNow) > diffSet)
                    {
                        lblMsg.Show("重量偏差过大!请检查。", false);
                        FrmTempAuthorize fta = new FrmTempAuthorize("称重复核员");
                        if (fta.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                        authUserCode = fta.AuthUserCode;
                    }

                    CheckUpdateAndLog(authUserCode, ctCode, vehicle.VehicleCode, tuoPanVehicleNo);

                    //初始化TuoPan级数据
                    txtBoxForContainerCode.Text = string.Empty;
                    lblCurrentWeight.Text       = "0";
                    //lblCalcWeight.Text = "0";
                    lblDiffByPallet.Text = "0";

                    lblMsg.Show("通过,请扫描当前订单的下一个托盘。", true);
                }//end if (isLastTuoPan)
            }
            catch (Exception ex)
            {
                MsgBox.Err(ex.Message);
            }
        }