Ejemplo n.º 1
0
        public string Order_QRCode_URL = "";                //外部查看连接

        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                ordertype = HTTPRequest.GetInt("ordertype", 0);
                orderid   = HTTPRequest.GetInt("orderid", 0);

                Act     = Utils.ChkSQL(HTTPRequest.GetString("Act")).Trim();
                format  = HTTPRequest.GetString("format");
                IsFirst = (HTTPRequest.GetString("IsFirst").Trim() != "") ? Convert.ToBoolean(HTTPRequest.GetString("IsFirst").Trim()) : false;;

                if (ordertype > 0 && Act != "")
                {
                    #region 权限判断
                    switch (ordertype)
                    {
                    case 1:                    //采购入库=1
                        if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-1-1") || CheckUserPopedoms("3-3-4-1-2"))
                        {
                            switch (Act)
                            {
                            case "8":
                            case "v":
                                if (ispost)
                                {
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-1-2"))
                                    {
                                        oi = Orders.GetOrderInfoModel(this.orderid);

                                        if (oi != null)
                                        {
                                            if (oi.oSteps == 2 || oi.oSteps == 3)
                                            {
                                            }
                                            else
                                            {
                                                AddErrLine("无法 添加 记录,单据状态限制!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,无法 操作 列表!");
                                    }
                                }
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-1-1"))
                                {
                                    OrderWorkingType = 8;
                                }
                                else
                                {
                                    AddErrLine("权限不足,无法 查看 列表!");
                                }
                                break;
                            }
                        }
                        else
                        {
                            AddErrLine("权限不足,无法浏览 采购入库单 列表!");
                        }
                        break;

                    case 2:                    //采购退货=2
                        if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-2-1") || CheckUserPopedoms("3-3-4-2-2"))
                        {
                            switch (Act)
                            {
                            case "8":
                            case "v":
                                if (ispost)
                                {
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-2-2"))
                                    {
                                        oi = Orders.GetOrderInfoModel(this.orderid);

                                        if (oi != null)
                                        {
                                            if (oi.oSteps == 2 || oi.oSteps == 3)
                                            {
                                            }
                                            else
                                            {
                                                AddErrLine("无法 添加 记录,单据状态限制!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,无法 操作 列表!");
                                    }
                                }
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-2-1"))
                                {
                                    OrderWorkingType = 8;
                                }
                                else
                                {
                                    AddErrLine("权限不足,无法 查看 列表!");
                                }
                                break;
                            }
                        }
                        else
                        {
                            AddErrLine("权限不足,无法浏览 采购退货单 列表!");
                        }
                        break;

                    case 3:                    //销售发货=3
                        if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-3-1") || CheckUserPopedoms("3-3-4-3-2"))
                        {
                            switch (Act)
                            {
                            case "8":
                            case "v":
                                if (ispost)
                                {
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-3-2"))
                                    {
                                        oi = Orders.GetOrderInfoModel(this.orderid);

                                        if (oi != null)
                                        {
                                            if (oi.oSteps == 2 || oi.oSteps == 3)
                                            {
                                            }
                                            else
                                            {
                                                AddErrLine("无法 添加 记录,单据状态限制!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,无法 操作 列表!");
                                    }
                                }
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-3-1"))
                                {
                                    OrderWorkingType = 8;
                                }
                                else
                                {
                                    AddErrLine("权限不足,无法 查看 列表!");
                                }
                                break;
                            }
                        }
                        else
                        {
                            AddErrLine("权限不足,无法浏览 销售发货单 列表!");
                        }
                        break;

                    case 4:                    //销售退货=4
                        if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-4-1") || CheckUserPopedoms("3-3-4-4-2"))
                        {
                            switch (Act)
                            {
                            case "8":
                            case "v":
                                if (ispost)
                                {
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-4-2"))
                                    {
                                        oi = Orders.GetOrderInfoModel(this.orderid);

                                        if (oi != null)
                                        {
                                            if (oi.oSteps == 2 || oi.oSteps == 3)
                                            {
                                            }
                                            else
                                            {
                                                AddErrLine("无法 添加 记录,单据状态限制!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,无法 操作 列表!");
                                    }
                                }
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-4-1"))
                                {
                                    OrderWorkingType = 8;
                                }
                                else
                                {
                                    AddErrLine("权限不足,无法 查看 列表!");
                                }
                                break;
                            }
                        }
                        else
                        {
                            AddErrLine("权限不足,无法浏览 销售退货单 列表!");
                        }
                        break;

                    case 5:                    //赠品=5
                        if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-5-1") || CheckUserPopedoms("3-3-4-5-2"))
                        {
                            switch (Act)
                            {
                            case "8":
                            case "v":
                                if (ispost)
                                {
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-5-2"))
                                    {
                                        oi = Orders.GetOrderInfoModel(this.orderid);

                                        if (oi != null)
                                        {
                                            if (oi.oSteps == 2 || oi.oSteps == 3)
                                            {
                                            }
                                            else
                                            {
                                                AddErrLine("无法 添加 记录,单据状态限制!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,无法 操作 列表!");
                                    }
                                }
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-5-1"))
                                {
                                    OrderWorkingType = 8;
                                }
                                else
                                {
                                    AddErrLine("权限不足,无法 查看 列表!");
                                }
                                break;
                            }
                        }
                        else
                        {
                            AddErrLine("权限不足,无法浏览 赠品单 列表!");
                        }
                        break;

                    case 6:                    //样品=6
                        if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-6-1") || CheckUserPopedoms("3-3-4-6-2"))
                        {
                            switch (Act)
                            {
                            case "8":
                            case "v":
                                if (ispost)
                                {
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-6-2"))
                                    {
                                        oi = Orders.GetOrderInfoModel(this.orderid);

                                        if (oi != null)
                                        {
                                            if (oi.oSteps == 2 || oi.oSteps == 3)
                                            {
                                            }
                                            else
                                            {
                                                AddErrLine("无法 添加 记录,单据状态限制!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,无法 操作 列表!");
                                    }
                                }
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-6-1"))
                                {
                                    OrderWorkingType = 8;
                                }
                                else
                                {
                                    AddErrLine("权限不足,无法 查看 列表!");
                                }
                                break;
                            }
                        }
                        else
                        {
                            AddErrLine("权限不足,无法浏览 样品单 列表!");
                        }
                        break;

                    case 7:                    //代购=7
                        if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-7-1") || CheckUserPopedoms("3-3-4-7-2"))
                        {
                            switch (Act)
                            {
                            case "8":
                            case "v":
                                if (ispost)
                                {
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-7-2"))
                                    {
                                        oi = Orders.GetOrderInfoModel(this.orderid);

                                        if (oi != null)
                                        {
                                            if (oi.oSteps == 2 || oi.oSteps == 3)
                                            {
                                            }
                                            else
                                            {
                                                AddErrLine("无法 添加 记录,单据状态限制!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,无法 操作 列表!");
                                    }
                                }
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-7-1"))
                                {
                                    OrderWorkingType = 8;
                                }
                                else
                                {
                                    AddErrLine("权限不足,无法 查看 列表!");
                                }
                                break;
                            }
                        }
                        else
                        {
                            AddErrLine("权限不足,无法浏览 代购单 列表!");
                        }
                        break;

                    case 8:                    //库存调整=8
                        if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-8-1") || CheckUserPopedoms("3-3-4-8-2"))
                        {
                            switch (Act)
                            {
                            case "8":
                            case "v":
                                if (ispost)
                                {
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-8-2"))
                                    {
                                        oi = Orders.GetOrderInfoModel(this.orderid);

                                        if (oi != null)
                                        {
                                            if (oi.oSteps == 2 || oi.oSteps == 3)
                                            {
                                            }
                                            else
                                            {
                                                AddErrLine("无法 添加 记录,单据状态限制!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,无法 操作 列表!");
                                    }
                                }
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-8-1"))
                                {
                                    OrderWorkingType = 8;
                                }
                                else
                                {
                                    AddErrLine("权限不足,无法 查看 列表!");
                                }
                                break;
                            }
                        }
                        else
                        {
                            AddErrLine("权限不足,无法浏览 库存调整单 列表!");
                        }
                        break;

                    case 9:                    //库存调拨=9
                        if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-8-1") || CheckUserPopedoms("3-3-4-8-2"))
                        {
                            switch (Act)
                            {
                            case "8":
                            case "v":
                                if (ispost)
                                {
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-8-2"))
                                    {
                                        oi = Orders.GetOrderInfoModel(this.orderid);

                                        if (oi != null)
                                        {
                                            if (oi.oSteps == 2 || oi.oSteps == 3)
                                            {
                                            }
                                            else
                                            {
                                                AddErrLine("无法 添加 记录,单据状态限制!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,无法 操作 列表!");
                                    }
                                }
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-8-1"))
                                {
                                    OrderWorkingType = 8;
                                }
                                else
                                {
                                    AddErrLine("权限不足,无法 查看 列表!");
                                }
                                break;
                            }
                        }
                        else
                        {
                            AddErrLine("权限不足,无法浏览 库存调拨单 列表!");
                        }
                        break;

                    case 10:                    //坏货=10
                        if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-8-1") || CheckUserPopedoms("3-3-4-8-2"))
                        {
                            switch (Act)
                            {
                            case "8":
                            case "v":
                                if (ispost)
                                {
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-8-2"))
                                    {
                                        oi = Orders.GetOrderInfoModel(this.orderid);

                                        if (oi != null)
                                        {
                                            if (oi.oSteps == 2 || oi.oSteps == 3)
                                            {
                                            }
                                            else
                                            {
                                                AddErrLine("无法 添加 记录,单据状态限制!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,无法 操作 列表!");
                                    }
                                }
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-8-1"))
                                {
                                    OrderWorkingType = 8;
                                }
                                else
                                {
                                    AddErrLine("权限不足,无法 查看 列表!");
                                }
                                break;
                            }
                        }
                        else
                        {
                            AddErrLine("权限不足,无法浏览 坏货单 列表!");
                        }
                        break;

                    case 11:                    //换货=11
                        if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-8-1") || CheckUserPopedoms("3-3-4-8-2"))
                        {
                            switch (Act)
                            {
                            case "8":
                            case "v":
                                if (ispost)
                                {
                                    if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-8-2"))
                                    {
                                        oi = Orders.GetOrderInfoModel(this.orderid);

                                        if (oi != null)
                                        {
                                            if (oi.oSteps == 2 || oi.oSteps == 3)
                                            {
                                            }
                                            else
                                            {
                                                AddErrLine("无法 添加 记录,单据状态限制!");
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("参数错误!");
                                        }
                                    }
                                    else
                                    {
                                        AddErrLine("权限不足,无法 操作 列表!");
                                    }
                                }
                                if (CheckUserPopedoms("X") || CheckUserPopedoms("3-3-4-8-1"))
                                {
                                    OrderWorkingType = 8;
                                }
                                else
                                {
                                    AddErrLine("权限不足,无法 查看 列表!");
                                }
                                break;
                            }
                        }
                        else
                        {
                            AddErrLine("权限不足,无法浏览 换货单 列表!");
                        }
                        break;

                    case 12:                    //修正数据
                        if (CheckUserPopedoms("X") || CheckUserPopedoms("7-2-1-5-7-1"))
                        {
                            IsEditData = true;
                        }
                        else
                        {
                            AddErrLine("权限不足,无法进行数据调整操作!");
                        }
                        break;
                    }

                    #endregion
                }
                else
                {
                    AddErrLine("参数错误,请返回!");
                }

                if (!IsErr())
                {
                    oOrderDateTime = (HTTPRequest.GetString("oOrderDateTime").Trim() != "") ? Convert.ToDateTime(Utils.ChkSQL(HTTPRequest.GetString("oOrderDateTime"))) : DateTime.Now;
                    string _OrderListDataJson = HTTPRequest.GetString("OrderListDataJson");
                    OrderWorkingLogMsg = Utils.ChkSQL(HTTPRequest.GetString("OrderWorkingLogMsg"));
                    string _splRemake = Utils.ChkSQL(HTTPRequest.GetString("splRemake"));
                    // oi = new OrderInfo();
                    switch (Act)
                    {
                        #region 查看,修改
                    case "v":
                    case "e":
                        oi = Orders.GetOrderInfoModel(orderid);
                        if (!ispost)
                        {
                            if (oi != null)
                            {
                                //CertificateList = Certificates.GetCertificateInfoList(" cObject=1 and cObjectID=" + oi.OrderID + " and cState=0 order by cDateTime desc").Tables[0];
                                PrepayMoney    = Certificates.GetPrepayMoneyByOrderID(oi.OrderID);
                                oOrderDateTime = oi.oOrderDateTime;

                                //是否为网购订单
                                _ms = M_Utils.GetM_SendGoodsInfoModelByOrderID(oi.OrderID);
                                if (_ms != null)
                                {
                                    IsMOrder = true;
                                }

                                //未审核,可修改
                                if (oi.oSteps == 1)
                                {
                                    this.ShowEdit = true;
                                    ShowTree      = true;
                                    IsVerify      = true;
                                }
                                else
                                {
                                    if (oi.oType != 11)                                    //非换货单可修改
                                    {
                                        if (oi.oPrepay == 1)
                                        {
                                            //是否已完成预付操作
                                            IsPrepayOK = Certificates.CheckCertificateByOrderID(oi.OrderID);
                                        }
                                        else
                                        {
                                            IsPrepayOK = true;
                                        }

                                        //已审核已发货
                                        if (oi.oSteps == 3)
                                        {
                                            this.ShowEdit = true;
                                        }
                                        else if (oi.oSteps >= 4)
                                        {
                                            //已经收货,已验收,已对账
                                            IsNOFull = Orders.CheckOrderIsFull(oi.OrderID);
                                        }
                                    }
                                    else
                                    {
                                        IsPrepayOK    = true;
                                        this.ShowEdit = false;
                                    }
                                }
                                OrderListDataJsonStr = "";                                //{"OrderListJson":[{"OrderListID":0,"OrderID":0,"StorageID":0,"ProductsID":0,"oQuantity":0,"oPrice":0,"oMoney":0,"StoresSupplierID":0,"IsPromotions":0,"oWorkType":0,"oAppendTime":"\/Date(1289206775426+0800)\/","OrderFieldValueInfo":[{"OrderFieldValueID":0,"OrderFieldID":0,"OrderListID":0,"oFieldValue":null,"IsVerify":0,"oAppendTime":"\/Date(1289206775426+0800)\/"}]}]}
                                string OrderFieldValueStr = "";
                                string tSteps             = "";
                                string tSteps_b           = "";

                                Order_QRCode_URL = "" + config.Sysurl + "/o-" + oi.OrderID + ".aspx?rc=" + Utils.UrlEncode(DES.Encode(oi.LastPrintDateTime.ToString() + "|" + oi.oOrderNum, config.Passwordkey)).Trim();


                                if (IsFirst)                                //输出原始单据
                                {
                                    tSteps   = " oWorkType=0";
                                    tSteps_b = " IsVerify=0";
                                }
                                else
                                {
                                    tSteps   = ((oi.oSteps == 1) ? " oWorkType=0" : " oWorkType<>0").ToString();
                                    tSteps_b = ((oi.oSteps == 1) ? " IsVerify=0" : " IsVerify<>0").ToString();
                                }

                                //取已收发列表
                                DataTable Storage_Order = tbStorageProductLogInfo.GetStorageProductLogListINOrderList(oi.OrderID).Tables[0];
                                if (Storage_Order != null)
                                {
                                    foreach (DataRow dr_Storage_Order in Storage_Order.Rows)
                                    {
                                        StorageOrderList += "{\"OrderListID\":" + dr_Storage_Order["OrderListID"].ToString() + "," +
                                                            "\"StorageID\":" + dr_Storage_Order["StorageID"].ToString() + "," +
                                                            "\"ProductsID\":" + dr_Storage_Order["ProductsID"].ToString() + "," +
                                                            "\"pQuantity\":" + dr_Storage_Order["pQuantity"].ToString() + "},";
                                    }
                                    if (StorageOrderList != "")
                                    {
                                        StorageOrderListJsonStr = "{\"StorageOrderList\":[" + Utils.ReSQLSetTxt(StorageOrderList) + "]}";
                                    }
                                }

                                //取单据列表
                                DataTable OrderListData = Orders.GetOrderListInfoList(" OrderID=" + oi.OrderID + " and " + tSteps + " order by OrderListID asc").Tables[0];
                                if (OrderListData != null)
                                {
                                    foreach (DataRow dr_OrderListData in OrderListData.Rows)
                                    {
                                        OrderFieldValueStr = "";
                                        DataTable OrderFieldValueData = Orders.GetOrderFieldValueInfoList(" OrderListID=" + dr_OrderListData["OrderListID"].ToString() + "and " + tSteps_b).Tables[0];
                                        foreach (DataRow dr_OrderFieldValueData in OrderFieldValueData.Rows)
                                        {
                                            OrderFieldValueStr += "{\"OrderFieldValueID\":" + dr_OrderFieldValueData["OrderFieldValueID"].ToString() + ",\"OrderFieldID\":" + dr_OrderFieldValueData["OrderFieldID"].ToString() + ",\"OrderListID\":" + dr_OrderFieldValueData["OrderListID"].ToString() + ",\"oFieldValue\":\"" + dr_OrderFieldValueData["oFieldValue"].ToString() + "\",\"IsVerify\":" + dr_OrderFieldValueData["IsVerify"].ToString() + ",\"oAppendTime\":\"" + dr_OrderFieldValueData["oAppendTime"].ToString() + "\"},";
                                        }
                                        if (OrderFieldValueStr != "")
                                        {
                                            OrderFieldValueStr = ",\"OrderFieldValueInfo\":[" + Utils.ReSQLSetTxt(OrderFieldValueStr) + "]";
                                        }
                                        OrderListDataJsonStr += "{\"OrderListID\":" + dr_OrderListData["OrderListID"].ToString() + "," +
                                                                "\"OrderID\":" + dr_OrderListData["OrderID"].ToString() + "," +
                                                                "\"StorageID\":" + dr_OrderListData["StorageID"].ToString() + "," +
                                                                "\"StorageName\":\"" + dr_OrderListData["StorageName"].ToString() + "\"," +
                                                                "\"ProductsID\":" + dr_OrderListData["ProductsID"].ToString() + "," +
                                                                "\"ProductsName\":\"" + Utils.ReplaceString(Utils.ReplaceString(dr_OrderListData["ProductsName"].ToString(), "'", "\\'", false), "\"", "\\\"", false) + "\"," +
                                                                "\"oQuantity\":" + dr_OrderListData["oQuantity"].ToString() + "," +
                                                                "\"oPrice\":" + dr_OrderListData["oPrice"].ToString() + "," +
                                                                "\"oMoney\":" + dr_OrderListData["oMoney"].ToString() + "," +
                                                                "\"StoresSupplierID\":" + dr_OrderListData["StoresSupplierID"].ToString() + "," +
                                                                "\"IsPromotions\":" + dr_OrderListData["IsPromotions"].ToString() + "," +
                                                                "\"oWorkType\":" + dr_OrderListData["oWorkType"].ToString() + "," +
                                                                "\"IsGifts\":" + dr_OrderListData["IsGifts"].ToString() + "," +
                                                                "\"oAppendTime\":\"" + dr_OrderListData["oAppendTime"].ToString() + "\"," +
                                                                "\"PriceClassID\":\"" + dr_OrderListData["PriceClassID"].ToString() + "\" " + OrderFieldValueStr + "},";
                                    }
                                    if (OrderListDataJsonStr.Trim() != "")
                                    {
                                        OrderListDataJsonStr = "{\"OrderListJson\":[" + Utils.ReSQLSetTxt(OrderListDataJsonStr) + "]}";
                                    }
                                }
                            }
                            else
                            {
                                AddErrLine("参数错误,单据列表不存在!");
                            }
                        }
                        break;
                        #endregion
                    }
                    if (ispost)
                    {
                        if (!IsEditData)
                        {
                            //非作废单据
                            if (oi.oState != 1)
                            {
                                if (oi.oSteps == 2 || oi.oSteps == 3)
                                {
                                }
                            }
                            else
                            {
                                AddErrLine("此单已作废,无法修改!");
                                AddScript("window.setTimeout('history.back(1);',2000);");
                            }
                        }
                        else
                        {
                            oi = new OrderInfo();
                        }

                        if (!IsErr())
                        {
                            //增加发货记录
                            spl.StorageID     = 0;                        //暂留无用
                            spl.StaffID       = this.userid;
                            spl.OrderID       = oi.OrderID;
                            spl.splRemake     = _splRemake;
                            spl.splAppendTime = DateTime.Now;


                            //Response.Write (_OrderListDataJson);
                            //	Response.End ();

                            spl.StorageOrderListDataJson = (StorageOrderListDataJson)JavaScriptConvert.DeserializeObject(_OrderListDataJson, typeof(StorageOrderListDataJson));

                            int StorageProductLogDataID = tbStorageProductLogInfo.AddStorageProductLogInfo(spl);

                            if (StorageProductLogDataID > 0)
                            {
                                AddMsgLine("保存成功!");

                                //更新当前在途库存情况
                                if (oi.oSteps == 2)
                                {
                                    oi.oSteps = 3;
                                    Orders.UpdateOrderInfo(oi);

                                    tbProductsInfo.UpdateProductsStorageByOrderID(orderid);

                                    OrderWorkingLogInfo owl = new OrderWorkingLogInfo();
                                    owl.OrderID     = oi.OrderID;
                                    owl.UserID      = this.userid;
                                    owl.oType       = 3;
                                    owl.oMsg        = OrderWorkingLogMsg;
                                    owl.pAppendTime = DateTime.Now;

                                    Orders.AddOrderWorkingLogInfo(owl);


                                    try
                                    {
                                        #region 发送邮件给收货人员
                                        //oi = Orders.GetOrderInfoModel(OrderID);
                                        switch (oi.oType)
                                        {
                                        case 1:                                        //采购入库
                                            UsersUtils.SendUserMailByPopedom("3-1-1-4", "采购入库单 等待收货处理,单号:" + oi.oOrderNum, "采购入库单 等待收货处理,单号:" + oi.oOrderNum);
                                            break;

                                        case 2:                                        //采购退货
                                            UsersUtils.SendUserMailByPopedom("3-1-2-4", "采购退货单 等待收货处理,单号:" + oi.oOrderNum, "采购退货单 等待收货处理,单号:" + oi.oOrderNum);
                                            break;

                                        case 3:                                        //销售发货
                                            UsersUtils.SendUserMailByPopedom("3-2-1-4", "销售发货单 等待收货处理,单号:" + oi.oOrderNum, "销售发货单 等待收货处理,单号:" + oi.oOrderNum);
                                            break;

                                        case 4:                                        //销售退货
                                            UsersUtils.SendUserMailByPopedom("3-2-2-4", "销售退货单 等待收货处理,单号:" + oi.oOrderNum, "销售退货单 等待收货处理,单号:" + oi.oOrderNum);
                                            break;

                                        case 5:                                        //赠品
                                            UsersUtils.SendUserMailByPopedom("3-2-3-4", "赠品单 等待收货处理,单号:" + oi.oOrderNum, "赠品单 等待收货处理,单号:" + oi.oOrderNum);
                                            break;

                                        case 6:                                        //样品
                                            UsersUtils.SendUserMailByPopedom("3-2-4-4", "样品单 等待收货处理,单号:" + oi.oOrderNum, "样品单 等待收货处理,单号:" + oi.oOrderNum);
                                            break;

                                        case 7:                                        //代购
                                            UsersUtils.SendUserMailByPopedom("3-2-5-4", "代购单 等待收货处理,单号:" + oi.oOrderNum, "代购单 等待收货处理,单号:" + oi.oOrderNum);
                                            break;

                                        case 11:                                        //换货
                                            UsersUtils.SendUserMailByPopedom("3-2-6-4", "换货单 等待收货处理,单号:" + oi.oOrderNum, "换货单 等待收货处理,单号:" + oi.oOrderNum);
                                            break;

                                        case 10:                                        //坏货
                                            UsersUtils.SendUserMailByPopedom("3-3-3-4", "坏货单 等待收货处理,单号:" + oi.oOrderNum, "坏货单 等待收货处理,单号:" + oi.oOrderNum);
                                            break;

                                        case 8:                                        //库存调整
                                            UsersUtils.SendUserMailByPopedom("3-3-1-4", "库存调整单 等待收货处理,单号:" + oi.oOrderNum, "库存调整单 等待收货处理,单号:" + oi.oOrderNum);
                                            break;

                                        case 9:                                        //库存调拨
                                            UsersUtils.SendUserMailByPopedom("3-3-2-4", "库存调拨单 等待收货处理,单号:" + oi.oOrderNum, "库存调拨单 等待收货处理,单号:" + oi.oOrderNum);
                                            break;
                                        }
                                        #endregion


                                        switch (oi.oType)
                                        {
                                        case 3:
                                        case 4:
                                        case 5:
                                        case 6:
                                            #region 发邮件给业务员
                                            if (oi.StaffID != 0)
                                            {
                                                tbStaffInfo.SendMailToStaff(oi.StaffID, tbStoresInfo.GetStoresInfoModel(oi.StoresSupplierID).sName + "," + GetOrderType(oi.oType.ToString()) + "单:" + oi.oOrderNum + "已发货.", "客户:" + tbStoresInfo.GetStoresInfoModel(oi.StoresSupplierID).sName + ",的" + GetOrderType(oi.oType.ToString()) + "单,单号:" + oi.oOrderNum + "已发货等待收货,请注意跟踪.<br>单据处理情况:" + config.Sysurl + "/o-" + oi.OrderID + ".aspx?rc=" + Utils.UrlEncode(DES.Encode(oi.LastPrintDateTime.ToString() + "|" + oi.oOrderNum, config.Passwordkey)).Trim());
                                            }
                                            #endregion

                                            #region 给客户发邮件
                                            tbStoresInfo.SendMailToStores(oi.StoresSupplierID, GetOrderType(oi.oType.ToString()) + "单 已发货,单号:" + oi.oOrderNum, GetOrderType(oi.oType.ToString()) + "单 已发货,单号:" + oi.oOrderNum);
                                            #endregion
                                            break;
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        AddErrLine(ex.Message);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
            if (format == "json")
            {
                Response.ClearContent();
                Response.Buffer          = true;
                Response.ExpiresAbsolute = System.DateTime.Now.AddYears(-1);
                Response.Expires         = 0;

                Response.Charset         = "utf-8";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
                Response.ContentType     = "application/json";
                string Json_Str = "{\"results\": {\"msg\":\"" + this.msgbox_text + "\",\"state\":\"" + (!IsErr()).ToString() + "\"}" + MS_Json + "}";
                Response.Write(Json_Str);
                Response.End();
            }
        }
Ejemplo n.º 2
0
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            if (this.userid > 0)
            {
                if (CheckUserPopedoms("X") || CheckUserPopedoms("8-3-2-1"))
                {
                    Act = HTTPRequest.GetString("Act");
                    m_TradeInfoID_Str = HTTPRequest.GetString("m_TradeInfoID");
                    if (m_TradeInfoID_Str.Trim() != "")
                    {
                        m_TradeInfoID_Str = Utils.ReSQLSetTxt("," + m_TradeInfoID_Str + ",");

                        if (ispost)
                        {
                            OrderInfo oi = new OrderInfo();

                            string receiver_state    = Utils.ChkSQL(HTTPRequest.GetString("receiver_state"));
                            string receiver_city     = Utils.ChkSQL(HTTPRequest.GetString("receiver_city"));
                            string receiver_district = Utils.ChkSQL(HTTPRequest.GetString("receiver_district"));
                            string receiver_address  = Utils.ChkSQL(HTTPRequest.GetString("receiver_address"));
                            string receiver_zip      = Utils.ChkSQL(HTTPRequest.GetString("receiver_zip"));
                            string receiver_name     = Utils.ChkSQL(HTTPRequest.GetString("receiver_name"));
                            string receiver_mobile   = Utils.ChkSQL(HTTPRequest.GetString("receiver_mobile"));
                            string receiver_phone    = Utils.ChkSQL(HTTPRequest.GetString("receiver_phone"));

                            string from_name     = Utils.ChkSQL(HTTPRequest.GetString("from_name"));
                            string from_state    = Utils.ChkSQL(HTTPRequest.GetString("from_state"));
                            string from_city     = Utils.ChkSQL(HTTPRequest.GetString("from_city"));
                            string from_district = Utils.ChkSQL(HTTPRequest.GetString("from_district"));
                            string from_address  = Utils.ChkSQL(HTTPRequest.GetString("from_address"));
                            string from_zip      = Utils.ChkSQL(HTTPRequest.GetString("from_zip"));
                            string from_mobile   = Utils.ChkSQL(HTTPRequest.GetString("from_mobile"));
                            string from_phone    = Utils.ChkSQL(HTTPRequest.GetString("from_phone"));


                            int    ExpName = HTTPRequest.GetInt("ExpName", 0);
                            string ExpNO   = Utils.ChkSQL(HTTPRequest.GetString("ExpNO"));
                            string tMsg    = Utils.ChkSQL(HTTPRequest.GetString("tMsg"));

                            int    m_SendGoodsID      = HTTPRequest.GetInt("m_SendGoodsID", 0);
                            string _OrderListDataJson = HTTPRequest.GetString("OrderListDataJson");

                            //创建发货单
                            if (Act == "Add")
                            {
                                try {
                                    oi.oOrderNum = "----------";// Orders.GetNewOrderNum();
                                    //if (!Orders.ExistsOrderInfo(oi.oOrderNum))
                                    {
                                        oi.oType             = 3;                                      //销售发货单
                                        oi.StoresID          = M_Config.StoresID;                      //系统客户编号
                                        oi.oCustomersName    = M_Config.StoresName;                    //客户名称,
                                        oi.oCustomersContact = receiver_name;                          //联系人
                                        oi.oCustomersTel     = receiver_mobile + "," + receiver_phone; //联系电话
                                        oi.oCustomersAddress = receiver_address;                       //地址
                                        oi.oCustomersOrderID = m_TradeInfoID_Str;                      //客户订单号
                                        oi.oCustomersNameB   = "";
                                        oi.StaffID           = 0;                                      //业务员暂留空
                                        oi.UserID            = this.userid;
                                        oi.oAppendTime       = DateTime.Now;
                                        oi.oOrderDateTime    = DateTime.Now;
                                        oi.oState            = 0;
                                        oi.oSteps            = 1;
                                        oi.oPrepay           = 0;
                                        oi.OrderListDataJson = (OrderListDataJson)JavaScriptConvert.DeserializeObject(_OrderListDataJson, typeof(OrderListDataJson));
                                        int OrderID = Orders.AddOrderInfoAndList(oi);
                                        if (OrderID > 0)
                                        {
                                            OrderWorkingLogInfo owl = new OrderWorkingLogInfo();
                                            owl.OrderID     = OrderID;
                                            owl.UserID      = this.userid;
                                            owl.oType       = 0;
                                            owl.oMsg        = M_Config.StoresName + "-" + M_Config.m_Name + ",下单:" + m_TradeInfoID_Str;
                                            owl.pAppendTime = DateTime.Now;

                                            Orders.AddOrderWorkingLogInfo(owl);

                                            //网店发货单
                                            SendGoods.m_ConfigInfoID    = M_Config.m_ConfigInfoID;
                                            SendGoods.OrderID           = OrderID;
                                            SendGoods.m_TradeInfoID     = m_TradeInfoID_Str;
                                            SendGoods.receiver_name     = receiver_name;
                                            SendGoods.receiver_state    = receiver_state;
                                            SendGoods.receiver_city     = receiver_city;
                                            SendGoods.receiver_district = receiver_district;
                                            SendGoods.receiver_address  = receiver_address;
                                            SendGoods.receiver_zip      = receiver_zip;
                                            SendGoods.receiver_mobile   = receiver_mobile;
                                            SendGoods.receiver_phone    = receiver_phone;
                                            SendGoods.from_name         = M_Config.StoresName;
                                            SendGoods.from_state        = from_state;
                                            SendGoods.from_city         = from_city;
                                            SendGoods.from_district     = from_district;
                                            SendGoods.from_address      = from_address;
                                            SendGoods.from_zip          = from_zip;
                                            SendGoods.from_mobile       = from_mobile;
                                            SendGoods.from_phone        = from_phone;
                                            SendGoods.mExpName          = ExpName;
                                            SendGoods.mExpNO            = ExpNO;
                                            SendGoods.mMemo             = tMsg;
                                            SendGoods.mState            = 0;
                                            SendGoods.mAppendTime       = DateTime.Now;

                                            m_SendGoodsID = M_Utils.AddM_SendGoodsInfo(SendGoods);
                                            if (m_SendGoodsID > 0)
                                            {
                                                AddMsgLine("单据创建成功!<p class=\"SendGood\"><br>查看发货单据?-><a href=\"javascript:void(0);\" onclick=\"javascript:OrderDO.Show(" + OrderID + ");\">查看</a></p>");
                                                #region 发送邮件给审核人员
                                                try
                                                {
                                                    oi = Orders.GetOrderInfoModel(OrderID);
                                                    UsersUtils.SendUserMailByPopedom("3-2-1-2", "销售发货单 需审核,单号:" + oi.oOrderNum, "销售发货单 需审核,单号:" + oi.oOrderNum);
                                                }
                                                catch
                                                {
                                                }
                                                #endregion
                                            }
                                            else //网店订单生成失败,作废系统订单
                                            {
                                                oi = Orders.GetOrderInfoModel(OrderID);

                                                oi.oState = 1;
                                                Orders.UpdateOrderInfo(oi);

                                                tbProductsInfo.UpdateProductsStorageByOrderID(OrderID);//更新当前在途库存情况

                                                OrderWorkingLogInfo _owl = new OrderWorkingLogInfo();
                                                owl.OrderID     = oi.OrderID;
                                                owl.UserID      = this.userid;
                                                owl.oType       = -1;
                                                owl.oMsg        = "网店订单生成失败,系统自动作废发货单!网店单号:" + m_TradeInfoID_Str;
                                                owl.pAppendTime = DateTime.Now;

                                                Orders.AddOrderWorkingLogInfo(owl);
                                            }
                                        }
                                        else
                                        {
                                            AddErrLine("新建单据失败,请重试!");
                                        }
                                    }
                                    //else
                                    {
                                        //    AddErrLine("发货单据号重复,单据添加失败,请重试!");
                                    }
                                }
                                finally
                                {
                                    oi = null;
                                }
                            }
                            //修改操作
                            if (Act == "Edit")
                            {
                                int m_TradeInfoID = HTTPRequest.GetInt("m_TradeInfoID", 0);
                                SendGoods = M_Utils.GetM_SendGoodsInfoModelBym_TradeInfoID(m_TradeInfoID);
                                if (SendGoods != null)
                                {
                                    oi = Orders.GetOrderInfoModel(SendGoods.OrderID);
                                    oi.oCustomersContact = receiver_name;                          //联系人
                                    oi.oCustomersTel     = receiver_mobile + "," + receiver_phone; //联系电话
                                    oi.oCustomersAddress = receiver_address;                       //地址

                                    oi.StaffID = 0;                                                //业务员暂留空

                                    oi.OrderListDataJson = (OrderListDataJson)JavaScriptConvert.DeserializeObject(_OrderListDataJson, typeof(OrderListDataJson));
                                    if (Orders.UpdateOrderInfoAndList(oi))
                                    {
                                        OrderWorkingLogInfo owl = new OrderWorkingLogInfo();
                                        owl.OrderID     = oi.OrderID;
                                        owl.UserID      = this.userid;
                                        owl.oType       = 1;
                                        owl.oMsg        = "网购订单修改操作!";
                                        owl.pAppendTime = DateTime.Now;

                                        Orders.AddOrderWorkingLogInfo(owl);

                                        SendGoods.receiver_name     = receiver_name;
                                        SendGoods.receiver_state    = receiver_state;
                                        SendGoods.receiver_city     = receiver_city;
                                        SendGoods.receiver_district = receiver_district;
                                        SendGoods.receiver_address  = receiver_address;
                                        SendGoods.receiver_zip      = receiver_zip;
                                        SendGoods.receiver_mobile   = receiver_mobile;
                                        SendGoods.receiver_phone    = receiver_phone;
                                        SendGoods.from_name         = M_Config.StoresName;
                                        SendGoods.from_state        = from_state;
                                        SendGoods.from_city         = from_city;
                                        SendGoods.from_district     = from_district;
                                        SendGoods.from_address      = from_address;
                                        SendGoods.from_zip          = from_zip;
                                        SendGoods.from_mobile       = from_mobile;
                                        SendGoods.from_phone        = from_phone;
                                        SendGoods.mExpName          = ExpName;
                                        SendGoods.mExpNO            = ExpNO;
                                        SendGoods.mMemo             = tMsg;

                                        M_Utils.UpdateM_SendGoodsInfo(SendGoods);

                                        AddMsgLine("更新成功!");
                                    }
                                    else
                                    {
                                        AddErrLine("发货单更新失败!");
                                    }
                                }
                                else
                                {
                                    AddErrLine("参数错误!");
                                }
                            }
                        }
                        else
                        {
                            Sender = tbStoresInfo.GetStoresInfoModel(M_Config.StoresID);

                            if (Act == "Edit")
                            {
                                //取 TradeID
                                int m_TradeInfoID = HTTPRequest.GetInt("m_TradeInfoID", 0);
                                SendGoods = M_Utils.GetM_SendGoodsInfoModelBym_TradeInfoID(m_TradeInfoID);
                                if (SendGoods != null)
                                {
                                    SendGoods.m_TradeInfoID = Utils.ReSQLSetTxt("0," + SendGoods.m_TradeInfoID + ",");
                                    tList = M_Utils.GetM_TradeInfoList(" m_ConfigInfoID=" + M_Config.m_ConfigInfoID + " and m_TradeInfoID in(" + SendGoods.m_TradeInfoID + ")").Tables[0];
                                    oList = M_Utils.GetM_OrderInfoList(" m_ConfigInfoID=" + M_Config.m_ConfigInfoID + " and m_TradeInfoID in(" + SendGoods.m_TradeInfoID + ")").Tables[0];

                                    DataTable OrderListData = Orders.GetOrderListInfoList(" OrderID=" + SendGoods.OrderID + " and oWorkType=1 order by OrderListID asc").Tables[0];
                                    if (OrderListData != null)
                                    {
                                        foreach (DataRow dr_OrderListData in OrderListData.Rows)
                                        {
                                            OrderListDataJsonStr += "{\"OrderListID\":" + dr_OrderListData["OrderListID"].ToString() + "," +
                                                                    "\"OrderID\":" + dr_OrderListData["OrderID"].ToString() + "," +
                                                                    "\"StorageID\":" + dr_OrderListData["StorageID"].ToString() + "," +
                                                                    "\"StorageName\":\"" + dr_OrderListData["StorageName"].ToString() + "\"," +
                                                                    "\"ProductsID\":" + dr_OrderListData["ProductsID"].ToString() + "," +
                                                                    "\"ProductsName\":\"" + dr_OrderListData["ProductsName"].ToString() + "\"," +
                                                                    "\"oQuantity\":" + dr_OrderListData["oQuantity"].ToString() + "," +
                                                                    "\"oPrice\":" + dr_OrderListData["oPrice"].ToString() + "," +
                                                                    "\"oMoney\":" + dr_OrderListData["oMoney"].ToString() + "," +
                                                                    "\"StoresSupplierID\":" + dr_OrderListData["StoresSupplierID"].ToString() + "," +
                                                                    "\"IsPromotions\":" + dr_OrderListData["IsPromotions"].ToString() + "," +
                                                                    "\"oWorkType\":" + dr_OrderListData["oWorkType"].ToString() + "," +
                                                                    "\"IsGifts\":" + dr_OrderListData["IsGifts"].ToString() + "," +
                                                                    "\"PriceClassID\":" + dr_OrderListData["PriceClassID"].ToString() + "," +
                                                                    "\"oAppendTime\":\"" + dr_OrderListData["oAppendTime"].ToString() + "\"},";
                                        }
                                        if (OrderListDataJsonStr.Trim() != "")
                                        {
                                            OrderListDataJsonStr = "{\"OrderListJson\":[" + Utils.ReSQLSetTxt(OrderListDataJsonStr) + "]}";
                                        }
                                    }
                                }
                                else
                                {
                                    AddErrLine("该交易的发货单不存在!");
                                }
                            }
                            else
                            {
                                oList = M_Utils.GetM_OrderInfoList(" m_ConfigInfoID=" + M_Config.m_ConfigInfoID + " and m_TradeInfoID in(" + m_TradeInfoID_Str + ")").Tables[0];

                                tList = M_Utils.GetM_TradeInfoList(" m_ConfigInfoID=" + M_Config.m_ConfigInfoID + " and m_TradeInfoID in(" + m_TradeInfoID_Str + ")").Tables[0];
                            }
                            eList = M_Utils.GetM_ExpressTemplatesInfoList(" m_ConfigInfoID=" + M_Config.m_ConfigInfoID + " order by mAppendTime desc").Tables[0];
                        }
                    }
                    else
                    {
                        AddErrLine("参数错误!");
                    }
                }
                else
                {
                    AddErrLine("权限不足!");
                    AddScript("window.setTimeout('window.parent.HidBox();',1000);");
                }
            }
            else
            {
                AddErrLine("请先登录!");
                SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
                SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer()));
            }
        }