Beispiel #1
0
    //protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    //{
    //    int product = 0;
    //    int.TryParse(RadComboBox1.SelectedValue, out product);
    //    if (product != 0)
    //    {
    //        PDT_ProductBLL productbll = new PDT_ProductBLL(product);
    //        if (productbll.Model == null) return;
    //        PDT_Product p = productbll.Model;

    //        Dictionary<string, Dictionary_Data> dic = DictionaryBLL.GetDicCollections("PDT_Packaging");
    //        string _T = dic[p.TrafficPackaging.ToString()].Name;
    //        string _P = dic[p.Packaging.ToString()].Name;


    //        #region 显示产品包装信息
    //        lb_TrafficPackagingName.Text = "元/" + _T + "(" + p.ConvertFactor.ToString() + _P + ")";
    //        #endregion

    //        #region 获取销售该门店的价格
    //        decimal saleprice = PDT_StandardPriceBLL.GetSalePrice((int)ViewState["Client"], (int)Session["OwnerClient"], product);
    //        if (saleprice > 0)
    //        {
    //            if (ddl_Unit.SelectedValue == "T")
    //                tbx_Price.Text = (saleprice * p.ConvertFactor).ToString("0.###");
    //            else
    //                tbx_Price.Text = saleprice.ToString("0.###");
    //            //tbx_Price.Enabled = false;
    //        }
    //        else
    //        {
    //            tbx_Price.Text = "0";
    //            //tbx_Price.Enabled = true;
    //        }
    //        #endregion

    //    }
    //}

    protected void bt_Assign_Click(object sender, EventArgs e)
    {
        int      deliveryman = 0, deliveryvehicle = 0, supplierwarehouse = 0;
        DateTime prearrivaldate = new DateTime(1900, 1, 1);

        if (Session["AssignFlag"] != null && (bool)Session["AssignFlag"])
        {
            deliveryman       = (int)Session["DeliveryMan"];
            deliveryvehicle   = (int)Session["DeliveryVehicle"];
            supplierwarehouse = (int)Session["SupplierWareHouse"];
            prearrivaldate    = (DateTime)Session["PreArrivalDate"];

            if ((int)ViewState["ID"] != 0)
            {
                PBM_OrderBLL _bll = new PBM_OrderBLL((int)ViewState["ID"]);
                if (_bll.Model.State == 2)
                {
                    int ret = _bll.CreateDelivery(supplierwarehouse, deliveryman, deliveryvehicle, prearrivaldate, (int)Session["UserID"]);
                    if (ret > 0)
                    {
                        Response.Redirect("../Delivery/SaleOut/SaleOutDetail.aspx?ID=" + ret.ToString());
                    }
                    else
                    {
                        MessageBox.Show(this, "派单失败!ret=" + ret.ToString());
                    }
                }
            }
        }
    }
Beispiel #2
0
    /// <summary>
    /// 保存收款信息
    /// </summary>
    private void SavePayInfo()
    {
        if ((int)ViewState["ID"] != 0)
        {
            PBM_OrderBLL _bll = new PBM_OrderBLL((int)ViewState["ID"]);
            _bll.ClearPayInfo();

            decimal amount = 0;
            if (decimal.TryParse(tbx_PayAmount1.Text, out amount) && amount != 0)
            {
                PBM_OrderPayInfoBLL paybll = new PBM_OrderPayInfoBLL();
                paybll.Model.OrderID     = _bll.Model.ID;
                paybll.Model.PayMode     = int.Parse(ddl_PayMode1.SelectedValue);
                paybll.Model.Amount      = amount;
                paybll.Model.ApproveFlag = 2;
                paybll.Model.InsertStaff = (int)Session["UserID"];
                paybll.Add();
            }
            if (decimal.TryParse(tbx_PayAmount2.Text, out amount) && amount != 0)
            {
                PBM_OrderPayInfoBLL paybll = new PBM_OrderPayInfoBLL();
                paybll.Model.OrderID     = _bll.Model.ID;
                paybll.Model.PayMode     = int.Parse(ddl_PayMode2.SelectedValue);
                paybll.Model.Amount      = amount;
                paybll.Model.ApproveFlag = 2;
                paybll.Model.InsertStaff = (int)Session["UserID"];
                paybll.Add();
            }
        }
    }
Beispiel #3
0
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        int client = 0, salesman = 0;

        int.TryParse(select_Client.SelectValue, out client);
        int.TryParse(ddl_Salesman.SelectedValue, out salesman);

        if (client == 0)
        {
            MessageBox.Show(this, "请正确选择零售店!");
            return;
        }

        PBM_OrderBLL bll = new PBM_OrderBLL();

        bll.Model.Supplier    = (int)Session["OwnerClient"];
        bll.Model.Client      = client;
        bll.Model.SalesMan    = salesman;
        bll.Model.Classify    = (int)ViewState["Classify"] == 0 ? 1 : (int)ViewState["Classify"];
        bll.Model.ArriveTime  = DateTime.Parse(tbx_ArriveTime.Text);
        bll.Model.InsertStaff = (int)Session["UserID"];
        bll.Model.State       = 1;
        bll.Model.ApproveFlag = 2;

        int id = bll.Add();

        Response.Redirect("OrderDetail.aspx?ID=" + id.ToString());

        //Response.Redirect("SaleOutDeail.aspx?Supplier=" + ddl_Supplier.SelectedValue +
        //    "&WareHouse=" + ddl_ClientWareHouse.SelectedValue + "&Salesman=" + ddl_Salesman.SelectedValue);
    }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        int client = 0, salesman = 0;
        int.TryParse(select_Client.SelectValue, out client);
        int.TryParse(ddl_Salesman.SelectedValue, out salesman);

        if (client == 0)
        {
            MessageBox.Show(this, "请正确选择零售店!");
            return;
        }

        PBM_OrderBLL bll = new PBM_OrderBLL();
        bll.Model.Supplier = (int)Session["OwnerClient"];
        bll.Model.Client = client;
        bll.Model.SalesMan = salesman;
        bll.Model.Classify = (int)ViewState["Classify"] == 0 ? 1 : (int)ViewState["Classify"];
        bll.Model.ArriveTime = DateTime.Parse(tbx_ArriveTime.Text);
        bll.Model.InsertStaff = (int)Session["UserID"];
        bll.Model.State = 1;
        bll.Model.ApproveFlag = 2;

        int id = bll.Add();
        Response.Redirect("OrderDetail.aspx?ID=" + id.ToString());

        //Response.Redirect("SaleOutDeail.aspx?Supplier=" + ddl_Supplier.SelectedValue +
        //    "&WareHouse=" + ddl_ClientWareHouse.SelectedValue + "&Salesman=" + ddl_Salesman.SelectedValue);
    }
    protected void bt_Assign_Click(object sender, EventArgs e)
    {
        int      deliveryman = 0, deliveryvehicle = 0, supplierwarehouse = 0;
        DateTime prearrivaldate = new DateTime(1900, 1, 1);

        int.TryParse(ddl_DeliveryMan.SelectedValue, out deliveryman);
        int.TryParse(ddl_DeliveryVehicle.SelectedValue, out deliveryvehicle);
        int.TryParse(ddl_SupplierWareHouse.SelectedValue, out supplierwarehouse);
        DateTime.TryParse(tbx_PreArrivalDate.Text, out prearrivaldate);

        if (deliveryman == 0)
        {
            MessageBox.Show(this, "请选择订单配货时的发货员工!");
            return;
        }

        if (supplierwarehouse == 0)
        {
            MessageBox.Show(this, "请选择订单配货时的发货仓库!");
            return;
        }

        if (prearrivaldate < DateTime.Today)
        {
            MessageBox.Show(this, "要求送货日期不能小于今天!");
            return;
        }

        int count = 0;

        foreach (GridViewRow row in gv_List.Rows)
        {
            int      id  = (int)gv_List.DataKeys[row.RowIndex]["PBM_Order_ID"];
            CheckBox cbx = (CheckBox)row.FindControl("cbx");
            if (cbx != null && cbx.Checked)
            {
                PBM_OrderBLL _bll = new PBM_OrderBLL(id);
                if (_bll.Model.State == 2)
                {
                    int ret = _bll.CreateDelivery(supplierwarehouse, deliveryman, deliveryvehicle, prearrivaldate, (int)Session["UserID"]);
                    if (ret > 0)
                    {
                        count++;
                    }
                }
            }
        }

        MessageBox.Show(this, "成功派单" + count.ToString() + "条预售订单!");

        BindGrid();
    }
    protected void bt_Assign_Click(object sender, EventArgs e)
    {
        int deliveryman = 0, deliveryvehicle = 0, supplierwarehouse = 0;
        DateTime prearrivaldate = new DateTime(1900, 1, 1);

        int.TryParse(ddl_DeliveryMan.SelectedValue, out deliveryman);
        int.TryParse(ddl_DeliveryVehicle.SelectedValue, out deliveryvehicle);
        int.TryParse(ddl_SupplierWareHouse.SelectedValue, out supplierwarehouse);
        DateTime.TryParse(tbx_PreArrivalDate.Text, out prearrivaldate);

        if (deliveryman == 0)
        {
            MessageBox.Show(this, "请选择订单配货时的发货员工!");
            return;
        }

        if (supplierwarehouse == 0)
        {
            MessageBox.Show(this, "请选择订单配货时的发货仓库!");
            return;
        }

        if (prearrivaldate < DateTime.Today)
        {
            MessageBox.Show(this, "要求送货日期不能小于今天!");
            return;
        }

        int count = 0;
        foreach (GridViewRow row in gv_List.Rows)
        {
            int id = (int)gv_List.DataKeys[row.RowIndex]["PBM_Order_ID"];
            CheckBox cbx = (CheckBox)row.FindControl("cbx");
            if (cbx != null && cbx.Checked)
            {
                PBM_OrderBLL _bll = new PBM_OrderBLL(id);
                if (_bll.Model.State == 2)
                {
                    int ret = _bll.CreateDelivery(supplierwarehouse, deliveryman, deliveryvehicle, prearrivaldate, (int)Session["UserID"]);
                    if (ret > 0)
                        count++;
                }
            }
        }

        MessageBox.Show(this, "成功派单" + count.ToString() + "条预售订单!");

        BindGrid();
    }
Beispiel #7
0
    protected void bt_Cancel_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] != 0)
        {
            PBM_OrderBLL _bll = new PBM_OrderBLL((int)ViewState["ID"]);
            int          ret  = _bll.Cancel((int)Session["UserID"], "");

            if (ret == 0)
            {
                Response.Redirect("OrderList.aspx?Classify=" + _bll.Model.Classify.ToString());
            }
            else
            {
                MessageBox.Show(this, "操作失败,返回值:" + ret.ToString());
            }
        }
    }
Beispiel #8
0
    protected void bt_Confirm_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] != 0)
        {
            if (!Save())
            {
                return;
            }

            PBM_OrderBLL _bll = new PBM_OrderBLL((int)ViewState["ID"]);

            int ret = _bll.Submit((int)Session["UserID"]);
            if (ret < 0)
            {
                MessageBox.Show(this, "对不起,订单提交失败!Ret=" + ret.ToString());
                return;
            }
            else
            {
                Response.Redirect("OrderList.aspx?Classify=" + _bll.Model.Classify.ToString());
            }
        }
    }
    /// <summary>
    /// 保存收款信息
    /// </summary>
    private void SavePayInfo()
    {
        if ((int)ViewState["ID"] != 0)
        {
            PBM_OrderBLL _bll = new PBM_OrderBLL((int)ViewState["ID"]);
            _bll.ClearPayInfo();

            decimal amount = 0;
            if (decimal.TryParse(tbx_PayAmount1.Text, out amount) && amount != 0)
            {
                PBM_OrderPayInfoBLL paybll = new PBM_OrderPayInfoBLL();
                paybll.Model.OrderID = _bll.Model.ID;
                paybll.Model.PayMode = int.Parse(ddl_PayMode1.SelectedValue);
                paybll.Model.Amount = amount;
                paybll.Model.ApproveFlag = 2;
                paybll.Model.InsertStaff = (int)Session["UserID"];
                paybll.Add();
            }
            if (decimal.TryParse(tbx_PayAmount2.Text, out amount) && amount != 0)
            {
                PBM_OrderPayInfoBLL paybll = new PBM_OrderPayInfoBLL();
                paybll.Model.OrderID = _bll.Model.ID;
                paybll.Model.PayMode = int.Parse(ddl_PayMode2.SelectedValue);
                paybll.Model.Amount = amount;
                paybll.Model.ApproveFlag = 2;
                paybll.Model.InsertStaff = (int)Session["UserID"];
                paybll.Add();
            }
        }
    }
    private bool Save()
    {
        if (ViewState["Details"] == null) return false;
        ListTable<PBM_OrderDetail> Details = (ListTable<PBM_OrderDetail>)ViewState["Details"];

        PBM_OrderBLL _bll;
        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll = new PBM_OrderBLL((int)ViewState["ID"]);
        }
        else
        {
            //新增
            _bll = new PBM_OrderBLL();
        }

        pl_detail.GetData(_bll.Model);

        #region 判断必填项
        if (_bll.Model.Supplier == 0)
        {
            MessageBox.Show(this, "请正确选择供货商!");
            return false;
        }

        if (_bll.Model.Client == 0)
        {
            MessageBox.Show(this, "请正确选择订货客户!");
            return false;
        }
        #endregion

        //折扣价
        _bll.Model.DiscountAmount = Details.GetListItem().Sum(p => (1 - p.DiscountRate) * Math.Round(p.Price * p.ConvertFactor, 2) * p.BookQuantity / p.ConvertFactor);

        //实际成交价
        _bll.Model.ActAmount = Details.GetListItem().Sum(p => Math.Round(p.Price * p.ConvertFactor, 2) * p.BookQuantity / p.ConvertFactor)
            - _bll.Model.DiscountAmount - _bll.Model.WipeAmount;
        _bll.Model.ActAmount = Math.Round(_bll.Model.ActAmount, 2);

        if (_bll.Model.Classify == 2) _bll.Model.ActAmount = 0 - _bll.Model.ActAmount; //退库时,金额以负数计

        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll.Model.UpdateStaff = (int)Session["UserID"];

            #region 保存明细
            if (ViewState["Details"] == null) return false;

            foreach (PBM_OrderDetail d in Details.GetListItem(ItemState.Added))
            {
                _bll.AddDetail(d);
            }
            foreach (PBM_OrderDetail d in Details.GetListItem(ItemState.Modified))
            {
                _bll.UpdateDetail(d);
            }
            foreach (PBM_OrderDetail d in Details.GetListItem(ItemState.Deleted))
            {
                _bll.DeleteDetail(d.ID);
            }
            #endregion

            if (_bll.Update() == 0)
            {
                SavePayInfo();
                return true;
            }
        }
        else
        {
            //新增
            _bll.Model.InsertStaff = (int)Session["UserID"];
            _bll.Items = Details.GetListItem();
            ViewState["ID"] = _bll.Add();

            if ((int)ViewState["ID"] > 0)
            {
                SavePayInfo();
                return true;
            }
        }
        return false;
    }
    private void BindData()
    {
        PBM_OrderBLL bll = new PBM_OrderBLL((int)ViewState["ID"]);
        if (bll.Model != null)
        {
            pl_detail.BindData(bll.Model);

            ViewState["Client"] = bll.Model.Client;
            ViewState["Supplier"] = bll.Model.Supplier;
            ViewState["Details"] = new ListTable<PBM_OrderDetail>(bll.Items, "ID");
            ViewState["State"] = bll.Model.State;
            ViewState["Classify"] = bll.Model.Classify;

            #region 绑定收款信息
            IList<PBM_OrderPayInfo> paylist = bll.GetPayInfoList();

            if (paylist.Count > 0)
            {
                ddl_PayMode1.SelectedValue = paylist[0].PayMode.ToString();
                tbx_PayAmount1.Text = paylist[0].Amount.ToString("0.##");
            }
            if (paylist.Count > 1)
            {
                ddl_PayMode2.SelectedValue = paylist[1].PayMode.ToString();
                tbx_PayAmount2.Text = paylist[1].Amount.ToString("0.##");
            }
            #endregion

            BindGrid();

            #region 界面控件可视状态
            if (bll.Model.State != 1 || bll.Model.ApproveFlag != 2)
            {
                bt_OK.Visible = false;
                tb_AddDetail.Visible = false;
                bt_Delete.Visible = false;
                tr_AddDetail.Visible = false;
                pl_detail.SetControlsEnable(false);

                gv_List.Columns[gv_List.Columns.Count - 1].Visible = false;
                gv_List.Columns[gv_List.Columns.Count - 2].Visible = false;

                ddl_PayMode1.Enabled = false;
                ddl_PayMode2.Enabled = false;
                tbx_PayAmount1.Enabled = false;
                tbx_PayAmount2.Enabled = false;
            }

            if (bll.Model.State != 1)
            {
                bt_Submit.Visible = false;
            }

            if (bll.Model.State != 2)
            {
                bt_Cancel.Visible = false;
                bt_Assign.Visible = false;
            }
            #endregion
        }
    }
    protected void bt_AddDetail_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] == 0) return;
        PBM_OrderBLL _bll = new PBM_OrderBLL((int)ViewState["ID"]);

        if (ViewState["Details"] == null) return;
        ListTable<PBM_OrderDetail> Details = (ListTable<PBM_OrderDetail>)ViewState["Details"];

        int product = 0;
        int.TryParse(select_Product.SelectValue, out product);
        //int.TryParse(RadComboBox1.SelectedValue, out product);
        if (product != 0)
        {
            PDT_ProductBLL productbll = new PDT_ProductBLL(product, true);
            if (productbll.Model == null) return;
            if (productbll.Model.ConvertFactor == 0)
            {
                productbll.Model.ConvertFactor = 1;
                productbll.Update();
            }

            int quantity = 0;
            decimal price = 0;

            int.TryParse(tbx_Quantity.Text, out quantity);
            decimal.TryParse(tbx_Price.Text, out price);

            if (ddl_Unit.SelectedValue == "T")
            {
                //整件单位
                quantity = quantity * productbll.Model.ConvertFactor;
                price = price / productbll.Model.ConvertFactor;
            }

            if (quantity == 0)
            {
                MessageBox.Show(this, "请填写数量!");
                return;
            }

            PBM_OrderDetail d = null;

            if (ViewState["SelectedDetail"] != null)
            {
                d = (PBM_OrderDetail)ViewState["SelectedDetail"];
            }
            else
            {
                d = new PBM_OrderDetail();
                d.OrderID = (int)ViewState["ID"];

                if (Details.GetListItem().Count == 0)
                    d.ID = 1;
                else
                    d.ID = Details.GetListItem().Max(p => p.ID) + 1;
            }

            d.Product = product;
            d.Price = price;                    //实际销售价
            d.DiscountRate = 1;                 //默认全价
            d.ConvertFactor = productbll.Model.ConvertFactor;
            d.BookQuantity = quantity;
            d.ConfirmQuantity = quantity;
            d.DeliveredQuantity = 0;
            d.SalesMode = int.Parse(ddl_SalesMode.SelectedValue);
            if (d.SalesMode == 2)
            { d.Price = 0; }

            if (ViewState["SelectedDetail"] != null)
            {
                Details.Update(d);
                ViewState["SelectedDetail"] = null;
                bt_AddDetail.Text = "新 增";
                gv_List.SelectedIndex = -1;
            }
            else
            {
                Details.Add(d);
            }

            tbx_Quantity.Text = "0";

            BindGrid();
        }
    }
    protected void bt_Submit_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] != 0)
        {
            if (Save())
            {
                PBM_OrderBLL _bll = new PBM_OrderBLL((int)ViewState["ID"]);
                int ret = _bll.Submit((int)Session["UserID"]);

                if (ret == 0)
                    Response.Redirect("OrderList.aspx?Classify=" + _bll.Model.Classify.ToString());
                else
                    MessageBox.Show(this, "操作失败,返回值:" + ret.ToString());
            }
        }
    }
    protected void bt_Confirm_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] != 0)
        {
            if (!Save()) return;

            PBM_OrderBLL _bll = new PBM_OrderBLL((int)ViewState["ID"]);

            int ret = _bll.Submit((int)Session["UserID"]);
            if (ret < 0)
            {
                MessageBox.Show(this, "对不起,订单提交失败!Ret=" + ret.ToString());
                return;
            }
            else
            {
                Response.Redirect("OrderList.aspx?Classify=" + _bll.Model.Classify.ToString());
            }
        }
    }
Beispiel #15
0
    protected void bt_AddDetail_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] == 0)
        {
            return;
        }
        PBM_OrderBLL _bll = new PBM_OrderBLL((int)ViewState["ID"]);

        if (ViewState["Details"] == null)
        {
            return;
        }
        ListTable <PBM_OrderDetail> Details = (ListTable <PBM_OrderDetail>)ViewState["Details"];

        int product = 0;

        int.TryParse(select_Product.SelectValue, out product);
        //int.TryParse(RadComboBox1.SelectedValue, out product);
        if (product != 0)
        {
            PDT_ProductBLL productbll = new PDT_ProductBLL(product, true);
            if (productbll.Model == null)
            {
                return;
            }
            if (productbll.Model.ConvertFactor == 0)
            {
                productbll.Model.ConvertFactor = 1;
                productbll.Update();
            }

            int     quantity = 0;
            decimal price    = 0;

            int.TryParse(tbx_Quantity.Text, out quantity);
            decimal.TryParse(tbx_Price.Text, out price);

            if (ddl_Unit.SelectedValue == "T")
            {
                //整件单位
                quantity = quantity * productbll.Model.ConvertFactor;
                price    = price / productbll.Model.ConvertFactor;
            }

            if (quantity == 0)
            {
                MessageBox.Show(this, "请填写数量!");
                return;
            }

            PBM_OrderDetail d = null;

            if (ViewState["SelectedDetail"] != null)
            {
                d = (PBM_OrderDetail)ViewState["SelectedDetail"];
            }
            else
            {
                d         = new PBM_OrderDetail();
                d.OrderID = (int)ViewState["ID"];

                if (Details.GetListItem().Count == 0)
                {
                    d.ID = 1;
                }
                else
                {
                    d.ID = Details.GetListItem().Max(p => p.ID) + 1;
                }
            }

            d.Product           = product;
            d.Price             = price;        //实际销售价
            d.DiscountRate      = 1;            //默认全价
            d.ConvertFactor     = productbll.Model.ConvertFactor;
            d.BookQuantity      = quantity;
            d.ConfirmQuantity   = quantity;
            d.DeliveredQuantity = 0;
            d.SalesMode         = int.Parse(ddl_SalesMode.SelectedValue);
            if (d.SalesMode == 2)
            {
                d.Price = 0;
            }

            if (ViewState["SelectedDetail"] != null)
            {
                Details.Update(d);
                ViewState["SelectedDetail"] = null;
                bt_AddDetail.Text           = "新 增";
                gv_List.SelectedIndex       = -1;
            }
            else
            {
                Details.Add(d);
            }

            tbx_Quantity.Text = "0";

            BindGrid();
        }
    }
        /// <summary>
        /// 提交订货单,并输出提交后的订单信息
        /// </summary>
        /// <param name="User"></param>
        /// <param name="OrderID">订货单ID</param>
        /// <param name="OrderInfo">输出:订货单结构</param>
        /// <param name="ErrorInfo">输出:出错信息</param>
        /// <returns>0:成功 小于0:失败</returns>
        public static int Order_Submit(UserInfo User, int OrderID, decimal WipeAmount, List<Order.OrderPayInfo> PayInfoList, out Order OrderInfo, out string ErrorInfo)
        {
            ErrorInfo = "";
            OrderInfo = null;
            LogWriter.WriteLog("PBMIFService.Order_Submit:UserName="******",OrderID=" + OrderID.ToString());

            if (OrderID <= 0) { ErrorInfo = "订货单ID无效"; return -1; }

            PBM_OrderBLL bll = new PBM_OrderBLL(OrderID);
            if (bll.Model == null) { ErrorInfo = "订货单ID无效"; return -1; }
            if (bll.Model.State > 1 || bll.Model.ApproveFlag == 1) { ErrorInfo = "订货单状态无效"; return -1; }

            if (User.OwnerType == 3 && bll.Model.Supplier != User.ClientID) { ErrorInfo = "不可提交该订货单"; return -2; }

            bll.Model.WipeAmount = WipeAmount;
            bll.Model.ActAmount = Math.Round((bll.Model.Classify == 2 ? -1 : 1) *
                bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.ConfirmQuantity / p.ConvertFactor)
                - bll.Model.WipeAmount, 2);
            bll.Update();

            #region 写入收款明细
            //先清除之前的付款信息
            if (bll.GetPayInfoList().Count > 0) bll.ClearPayInfo();

            foreach (Order.OrderPayInfo item in PayInfoList)
            {
                PBM_DeliveryPayInfoBLL paybll = new PBM_DeliveryPayInfoBLL();
                paybll.Model.DeliveryID = OrderID;
                paybll.Model.PayMode = item.PayMode;
                paybll.Model.Amount = item.Amount;
                paybll.Model.Remark = item.Remark;
                paybll.Model.ApproveFlag = 2;
                paybll.Model.InsertStaff = User.StaffID;
                paybll.Add();
            }
            #endregion

            int ret = bll.Submit(User.StaffID);
            if (ret < 0) { ErrorInfo = "订货单提交失败!"; return -1; }

            OrderInfo = new Order(bll.Model.ID);
            return 0;
        }
        /// <summary>
        /// 新增预售订单
        /// </summary>
        /// <param name="User"></param>
        /// <param name="OrderInfo">发货单信息</param>
        /// <param name="ErrorInfo">出错消息</param>
        /// <returns></returns>
        public static int Order_Add(UserInfo User, Order OrderInfo, out string ErrorInfo)
        {
            ErrorInfo = "";
            LogWriter.WriteLog("PBMIFService.Order_Add:UserName="******",OrderInfo=" + JsonConvert.SerializeObject(OrderInfo));

            //经销商级人员,供货商只能是自己所属的经销商
            if (User.OwnerType == 3) OrderInfo.Supplier = User.ClientID;

            //默认业务人员为当前员工
            if (OrderInfo.SalesMan == 0) OrderInfo.SalesMan = User.StaffID;

            #region 必填字段校验
            if (OrderInfo.Supplier == 0) { ErrorInfo = "无效的供货客户!"; return -2; }
            if (OrderInfo.Client == 0) { ErrorInfo = "无效的购买客户!"; return -2; }
            if (OrderInfo.Items == null || OrderInfo.Items.Count == 0) { ErrorInfo = "无销售产品明细!"; return -10; }
            #endregion

            PBM_OrderBLL bll = new PBM_OrderBLL();

            #region 保存销售单头信息
            bll.Model.SheetCode = "";
            bll.Model.Supplier = OrderInfo.Supplier;
            bll.Model.Client = OrderInfo.Client;
            bll.Model.SalesMan = OrderInfo.SalesMan;
            bll.Model.Classify = (OrderInfo.Classify == 0 ? 1 : OrderInfo.Classify);              //默认销售单
            bll.Model.State = 1;        //默认制单状态
            bll.Model.StandardPrice = OrderInfo.StandardPrice;

            bll.Model.WipeAmount = OrderInfo.WipeAmount;
            bll.Model.ArriveTime = OrderInfo.ArriveTime < DateTime.Today ? DateTime.Today.AddDays(1) : OrderInfo.ArriveTime;
            bll.Model.WorkList = OrderInfo.WorkList;
            bll.Model.Remark = OrderInfo.Remark;
            bll.Model.ApproveFlag = 2;
            bll.Model.InsertStaff = User.StaffID;

            //订单来源
            bll.Model["OrderSource"] = OrderInfo.OrderSource > 0 ? OrderInfo.OrderSource.ToString() : "2";

            #endregion

            #region 循环处理每个订单明细
            foreach (Order.OrderDetail item in OrderInfo.Items)
            {
                if (item.Product == 0) continue;
                if (item.BookQuantity <= 0 && item.ConfirmQuantity <= 0) continue;

                int bookquantity = item.BookQuantity <= 0 ? item.ConfirmQuantity : item.BookQuantity;

                PDT_ProductBLL productbll = new PDT_ProductBLL(item.Product);
                if (productbll.Model == null) { ErrorInfo = "无效产品项,产品ID:" + item.Product; return -11; }
                PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo(bll.Model.Supplier);
                if (productbll.Model == null) { ErrorInfo = "产品不在销售商的经营目录中," + productbll.Model.FullName; return -11; }

                #region 新增商品明细
                PBM_OrderDetail d = new PBM_OrderDetail();

                d.Product = item.Product;
                d.SalesMode = item.SalesMode == 0 ? 1 : item.SalesMode;     //默认为“销售”

                if (item.Price > 0)
                    d.Price = item.Price;
                else
                    d.Price = PDT_StandardPriceBLL.GetSalePrice(bll.Model.Client, bll.Model.Supplier, d.Product);       //默认销售价

                if (d.SalesMode == 1)
                    d.DiscountRate = (item.DiscountRate <= 0 || item.DiscountRate > 1) ? 1 : item.DiscountRate;
                else
                    d.DiscountRate = 0;     //非销售时,0折销售

                d.ConvertFactor = productbll.Model.ConvertFactor == 0 ? 1 : productbll.Model.ConvertFactor;
                d.BookQuantity = bookquantity;
                d.ConfirmQuantity = d.BookQuantity;
                d.Remark = item.Remark;

                bll.Items.Add(d);
                #endregion
            }
            #endregion

            //计算折扣金额
            bll.Model.DiscountAmount = bll.Items.Sum(p => (1 - p.DiscountRate) *
                Math.Round(p.Price * p.ConvertFactor, 2) * p.ConfirmQuantity / p.ConvertFactor);

            //计算实际销售金额
            bll.Model.ActAmount = Math.Round((bll.Model.Classify == 2 ? -1 : 1) *
                bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.ConfirmQuantity / p.ConvertFactor)
                - bll.Model.WipeAmount, 2);

            int orderid = bll.Add();
            if (orderid <= 0) { ErrorInfo = "销售订单保存失败!"; return orderid; }

            #region 判断订单是否直接提交
            if (OrderInfo.State == 2)
            {
                LogWriter.WriteLog("PBMIFService.Order_Add:UserName="******",OrderID=" + orderid.ToString() + ",Auto submit order!");
                Order OutOrderInfo;
                if (OrderInfo.PayInfos == null) OrderInfo.PayInfos = new List<Order.OrderPayInfo>();
                int ret = Order_Submit(User, orderid, OrderInfo.WipeAmount, OrderInfo.PayInfos, out OutOrderInfo, out ErrorInfo);
                if (ret < 0)
                {
                    LogWriter.WriteLog("PBMIFService.Order_Add:UserName="******",OrderID=" + orderid.ToString() +
                        ",Auto submit failed!ErrorInfo=" + ErrorInfo);
                    return ret;
                }
            }
            #endregion

            return orderid;
        }
Beispiel #18
0
        private void FillModel(int OrderID)
        {
            PBM_OrderBLL bll = new PBM_OrderBLL(OrderID);
            if (bll.Model == null) { ID = -1; return; }

            PBM_Order m = bll.Model;
            ID = m.ID;
            SheetCode = m.SheetCode;
            Supplier = m.Supplier;
            Client = m.Client;
            SalesMan = m.SalesMan;
            Classify = m.Classify;
            StandardPrice = m.StandardPrice;
            State = m.State;
            DiscountAmount = m.DiscountAmount;
            WipeAmount = m.WipeAmount;
            ActAmount = m.ActAmount;
            ArriveTime = m.ArriveTime;
            SubmitTime = m.SubmitTime;
            ConfirmTime = m.ConfirmTime;
            InsertTime = m.InsertTime;
            Remark = m.Remark;
            WorkList = m.WorkList;
            ApproveFlag = m.ApproveFlag;

            int.TryParse(m["OrderSource"], out OrderSource);

            //订货单明细
            Items = new List<OrderDetail>();
            foreach (PBM_OrderDetail item in bll.Items)
            {
                Items.Add(new OrderDetail(item));
            }

            //预收款信息列表
            PayInfos = new List<OrderPayInfo>();
            foreach (PBM_OrderPayInfo item in bll.GetPayInfoList())
            {
                PayInfos.Add(new OrderPayInfo(item));
            }

            #region 获取各字段ID对应的名称
            if (Supplier > 0)
            {
                CM_Client c = new CM_ClientBLL(Supplier).Model;
                if (c != null) SupplierName = c.FullName;
            }
            if (Client > 0)
            {
                CM_Client c = new CM_ClientBLL(Client).Model;
                if (c != null) ClientName = c.FullName;
            }
            if (SalesMan > 0)
            {
                Org_Staff s = new Org_StaffBLL(SalesMan).Model;
                if (s != null) SalesManName = s.RealName;
            }
            if (StandardPrice > 0)
            {
                PDT_StandardPrice s = new PDT_StandardPriceBLL(StandardPrice).Model;
                if (s != null) StandardPriceName = s.Name;
            }
            #endregion

            #region 获取字典表名称
            try
            {
                if (m.Classify > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_OrderClassify")[m.Classify.ToString()];
                    if (dic != null) ClassifyName = dic.Name;
                }

                if (m.State > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_OrderState")[m.State.ToString()];
                    if (dic != null) StateName = dic.Name;
                }

                if (OrderSource > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_OrderSource")[OrderSource.ToString()];
                    if (dic != null) OrderSourceName = dic.Name;
                }
            }
            catch (System.Exception err)
            {
                LogWriter.WriteLog("MCSFramework.WSI.Order", err);
            }
            #endregion
        }
Beispiel #19
0
    private void BindData()
    {
        PBM_OrderBLL bll = new PBM_OrderBLL((int)ViewState["ID"]);

        if (bll.Model != null)
        {
            pl_detail.BindData(bll.Model);

            ViewState["Client"]   = bll.Model.Client;
            ViewState["Supplier"] = bll.Model.Supplier;
            ViewState["Details"]  = new ListTable <PBM_OrderDetail>(bll.Items, "ID");
            ViewState["State"]    = bll.Model.State;
            ViewState["Classify"] = bll.Model.Classify;

            #region 绑定收款信息
            IList <PBM_OrderPayInfo> paylist = bll.GetPayInfoList();

            if (paylist.Count > 0)
            {
                ddl_PayMode1.SelectedValue = paylist[0].PayMode.ToString();
                tbx_PayAmount1.Text        = paylist[0].Amount.ToString("0.##");
            }
            if (paylist.Count > 1)
            {
                ddl_PayMode2.SelectedValue = paylist[1].PayMode.ToString();
                tbx_PayAmount2.Text        = paylist[1].Amount.ToString("0.##");
            }
            #endregion

            BindGrid();

            #region 界面控件可视状态
            if (bll.Model.State != 1 || bll.Model.ApproveFlag != 2)
            {
                bt_OK.Visible        = false;
                tb_AddDetail.Visible = false;
                bt_Delete.Visible    = false;
                tr_AddDetail.Visible = false;
                pl_detail.SetControlsEnable(false);

                gv_List.Columns[gv_List.Columns.Count - 1].Visible = false;
                gv_List.Columns[gv_List.Columns.Count - 2].Visible = false;

                ddl_PayMode1.Enabled   = false;
                ddl_PayMode2.Enabled   = false;
                tbx_PayAmount1.Enabled = false;
                tbx_PayAmount2.Enabled = false;
            }

            if (bll.Model.State != 1)
            {
                bt_Submit.Visible = false;
            }

            if (bll.Model.State != 2)
            {
                bt_Cancel.Visible = false;
                bt_Assign.Visible = false;
            }
            #endregion
        }
    }
Beispiel #20
0
    private bool Save()
    {
        if (ViewState["Details"] == null)
        {
            return(false);
        }
        ListTable <PBM_OrderDetail> Details = (ListTable <PBM_OrderDetail>)ViewState["Details"];

        PBM_OrderBLL _bll;

        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll = new PBM_OrderBLL((int)ViewState["ID"]);
        }
        else
        {
            //新增
            _bll = new PBM_OrderBLL();
        }

        pl_detail.GetData(_bll.Model);

        #region 判断必填项
        if (_bll.Model.Supplier == 0)
        {
            MessageBox.Show(this, "请正确选择供货商!");
            return(false);
        }

        if (_bll.Model.Client == 0)
        {
            MessageBox.Show(this, "请正确选择订货客户!");
            return(false);
        }
        #endregion

        //折扣价
        _bll.Model.DiscountAmount = Details.GetListItem().Sum(p => (1 - p.DiscountRate) * Math.Round(p.Price * p.ConvertFactor, 2) * p.BookQuantity / p.ConvertFactor);

        //实际成交价
        _bll.Model.ActAmount = Details.GetListItem().Sum(p => Math.Round(p.Price * p.ConvertFactor, 2) * p.BookQuantity / p.ConvertFactor)
                               - _bll.Model.DiscountAmount - _bll.Model.WipeAmount;
        _bll.Model.ActAmount = Math.Round(_bll.Model.ActAmount, 2);

        if (_bll.Model.Classify == 2)
        {
            _bll.Model.ActAmount = 0 - _bll.Model.ActAmount;                           //退库时,金额以负数计
        }
        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll.Model.UpdateStaff = (int)Session["UserID"];

            #region 保存明细
            if (ViewState["Details"] == null)
            {
                return(false);
            }

            foreach (PBM_OrderDetail d in Details.GetListItem(ItemState.Added))
            {
                _bll.AddDetail(d);
            }
            foreach (PBM_OrderDetail d in Details.GetListItem(ItemState.Modified))
            {
                _bll.UpdateDetail(d);
            }
            foreach (PBM_OrderDetail d in Details.GetListItem(ItemState.Deleted))
            {
                _bll.DeleteDetail(d.ID);
            }
            #endregion

            if (_bll.Update() == 0)
            {
                SavePayInfo();
                return(true);
            }
        }
        else
        {
            //新增
            _bll.Model.InsertStaff = (int)Session["UserID"];
            _bll.Items             = Details.GetListItem();
            ViewState["ID"]        = _bll.Add();

            if ((int)ViewState["ID"] > 0)
            {
                SavePayInfo();
                return(true);
            }
        }
        return(false);
    }
        /// <summary>
        /// 取消预售订单
        /// </summary>
        /// <param name="User"></param>
        /// <param name="OrderID"></param>
        /// <param name="CancelReason"></param>
        /// <param name="ErrorInfo"></param>
        /// <returns></returns>
        public static int Order_Cancel(UserInfo User, int OrderID, string CancelReason, out string ErrorInfo)
        {
            ErrorInfo = "";
            LogWriter.WriteLog("PBMIFService.Order_Cancel:UserName="******",OrderID=" + OrderID.ToString() +
                ",CancelReason=" + CancelReason);

            if (OrderID <= 0) { ErrorInfo = "预售订单ID无效"; return -1; }

            PBM_OrderBLL bll = new PBM_OrderBLL(OrderID);
            if (bll.Model == null) { ErrorInfo = "预售订单ID无效"; return -1; }
            if (bll.Model.State > 2) { ErrorInfo = "预售订单状态无效"; return -1; }

            if (User.OwnerType == 3 && bll.Model.Supplier != User.ClientID) { ErrorInfo = "不可取消该销售单"; return -2; }

            int ret = bll.Cancel(User.StaffID, CancelReason);
            if (ret < 0) { ErrorInfo = "预售订单取消失败!"; return -1; }

            return 0;
        }
    //protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    //{
    //    int product = 0;
    //    int.TryParse(RadComboBox1.SelectedValue, out product);
    //    if (product != 0)
    //    {
    //        PDT_ProductBLL productbll = new PDT_ProductBLL(product);
    //        if (productbll.Model == null) return;
    //        PDT_Product p = productbll.Model;
    //        Dictionary<string, Dictionary_Data> dic = DictionaryBLL.GetDicCollections("PDT_Packaging");
    //        string _T = dic[p.TrafficPackaging.ToString()].Name;
    //        string _P = dic[p.Packaging.ToString()].Name;
    //        #region 显示产品包装信息
    //        lb_TrafficPackagingName.Text = "元/" + _T + "(" + p.ConvertFactor.ToString() + _P + ")";
    //        #endregion
    //        #region 获取销售该门店的价格
    //        decimal saleprice = PDT_StandardPriceBLL.GetSalePrice((int)ViewState["Client"], (int)Session["OwnerClient"], product);
    //        if (saleprice > 0)
    //        {
    //            if (ddl_Unit.SelectedValue == "T")
    //                tbx_Price.Text = (saleprice * p.ConvertFactor).ToString("0.###");
    //            else
    //                tbx_Price.Text = saleprice.ToString("0.###");
    //            //tbx_Price.Enabled = false;
    //        }
    //        else
    //        {
    //            tbx_Price.Text = "0";
    //            //tbx_Price.Enabled = true;
    //        }
    //        #endregion
    //    }
    //}
    protected void bt_Assign_Click(object sender, EventArgs e)
    {
        int deliveryman = 0, deliveryvehicle = 0, supplierwarehouse = 0;
        DateTime prearrivaldate = new DateTime(1900, 1, 1);

        if (Session["AssignFlag"] != null && (bool)Session["AssignFlag"])
        {
            deliveryman = (int)Session["DeliveryMan"];
            deliveryvehicle = (int)Session["DeliveryVehicle"];
            supplierwarehouse = (int)Session["SupplierWareHouse"];
            prearrivaldate = (DateTime)Session["PreArrivalDate"];

            if ((int)ViewState["ID"] != 0)
            {
                PBM_OrderBLL _bll = new PBM_OrderBLL((int)ViewState["ID"]);
                if (_bll.Model.State == 2)
                {
                    int ret = _bll.CreateDelivery(supplierwarehouse, deliveryman, deliveryvehicle, prearrivaldate, (int)Session["UserID"]);
                    if (ret > 0)
                        Response.Redirect("../Delivery/SaleOut/SaleOutDetail.aspx?ID=" + ret.ToString());
                    else
                        MessageBox.Show(this, "派单失败!ret=" + ret.ToString());
                }
            }
        }
    }
        /// <summary>
        /// 更新预售订单
        /// </summary>
        /// <param name="User"></param>
        /// <param name="OrderInfo"></param>
        /// <param name="ErrorInfo"></param>
        /// <returns></returns>
        public static int Order_Update(UserInfo User, Order OrderInfo, out string ErrorInfo)
        {
            ErrorInfo = "";
            LogWriter.WriteLog("PBMIFService.Order_Update:UserName="******",OrderInfo=" + JsonConvert.SerializeObject(OrderInfo));

            if (OrderInfo.ID == 0) { ErrorInfo = "销售订单不存在,请先新增销售订单!"; return -1; }

            PBM_OrderBLL bll = new PBM_OrderBLL(OrderInfo.ID);
            if (bll.Model == null) { ErrorInfo = "订货单不存在,请先新增订货单!"; return -1; }
            if (bll.Model.State > 1 || bll.Model.ApproveFlag == 1) { ErrorInfo = "订货单状态不允许执行此操作!"; return -1; }

            if (bll.Model.Supplier == 0) bll.Model.Supplier = OrderInfo.Supplier;
            if (bll.Model.Client == 0) bll.Model.Client = OrderInfo.Client;

            //默认业务人员为当前员工
            if (OrderInfo.SalesMan == 0) OrderInfo.SalesMan = User.StaffID;

            #region 必填字段校验
            if (bll.Model.Supplier == 0) { ErrorInfo = "无效的供货客户!"; return -2; }
            if (User.OwnerType == 3 && bll.Model.Supplier != User.ClientID) { ErrorInfo = "无效的供货客户!"; return -2; }
            if (bll.Model.Client == 0) { ErrorInfo = "无效的购买客户!"; return -2; }

            if (OrderInfo.Items == null || OrderInfo.Items.Count == 0) { ErrorInfo = "无订货产品明细!"; return -10; }
            #endregion

            #region 保存订货单头信息
            bll.Model.SalesMan = OrderInfo.SalesMan;
            bll.Model.WipeAmount = OrderInfo.WipeAmount;
            bll.Model.ArriveTime = OrderInfo.ArriveTime < DateTime.Today ? DateTime.Today.AddDays(1) : OrderInfo.ArriveTime;
            bll.Model.WorkList = OrderInfo.WorkList;
            bll.Model.Remark = OrderInfo.Remark;
            #endregion

            #region 循环处理每个订单明细
            foreach (Order.OrderDetail item in OrderInfo.Items)
            {
                if (item.Product == 0) continue;
                if (item.BookQuantity <= 0 && item.ConfirmQuantity <= 0)
                {
                    if (item.DetailID == 0)
                        continue;
                    else
                        bll.DeleteDetail(item.DetailID);
                }

                int quantity = item.BookQuantity == 0 ? item.ConfirmQuantity : item.BookQuantity;

                string remark = item.Remark;

                PDT_ProductBLL productbll = new PDT_ProductBLL(item.Product);
                if (productbll.Model == null) { ErrorInfo = "无效产品项,产品ID:" + item.Product; return -11; }
                PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo(bll.Model.Supplier);
                if (productbll.Model == null) { ErrorInfo = "产品不在销售商的经营目录中," + productbll.Model.FullName; return -11; }

                if (item.DetailID > 0)
                {
                    PBM_OrderDetail d = bll.GetDetailModel(item.DetailID);

                    d.ConvertFactor = productbll.Model.ConvertFactor == 0 ? 1 : productbll.Model.ConvertFactor;
                    d.BookQuantity = quantity;
                    d.ConfirmQuantity = quantity;
                    d.Remark = item.Remark;
                    bll.UpdateDetail(d);
                }
                else
                {
                    #region 新增商品明细品项
                    PBM_OrderDetail d = new PBM_OrderDetail();

                    d.Product = item.Product;
                    d.SalesMode = item.SalesMode == 0 ? 1 : item.SalesMode;     //默认为“销售”

                    d.Price = PDT_StandardPriceBLL.GetSalePrice(bll.Model.Client, bll.Model.Supplier, d.Product);
                    if (d.SalesMode == 1)
                        d.DiscountRate = (item.DiscountRate <= 0 || item.DiscountRate > 1) ? 1 : item.DiscountRate;
                    else
                        d.DiscountRate = 0;

                    d.BookQuantity = quantity;
                    d.ConfirmQuantity = d.BookQuantity;
                    d.Remark = item.Remark;

                    bll.AddDetail(d);
                    #endregion
                }
            }
            #endregion

            //计算折扣金额
            bll.Model.DiscountAmount = bll.Items.Sum(p => (1 - p.DiscountRate) *
                Math.Round(p.Price * p.ConvertFactor, 2) * p.ConfirmQuantity / p.ConvertFactor);

            //计算实际销售金额
            bll.Model.ActAmount = Math.Round((bll.Model.Classify == 2 ? -1 : 1) *
                bll.Items.Sum(p => p.DiscountRate * Math.Round(p.Price * p.ConvertFactor, 2) * p.ConfirmQuantity / p.ConvertFactor)
                - bll.Model.WipeAmount, 2);

            int ret = bll.Update();
            if (ret < 0) { ErrorInfo = "订货单保存失败!"; return ret; }

            return 0;
        }
Beispiel #24
0
        private void FillModel(int OrderID)
        {
            PBM_OrderBLL bll = new PBM_OrderBLL(OrderID);

            if (bll.Model == null)
            {
                ID = -1; return;
            }

            PBM_Order m = bll.Model;

            ID             = m.ID;
            SheetCode      = m.SheetCode;
            Supplier       = m.Supplier;
            Client         = m.Client;
            SalesMan       = m.SalesMan;
            Classify       = m.Classify;
            StandardPrice  = m.StandardPrice;
            State          = m.State;
            DiscountAmount = m.DiscountAmount;
            WipeAmount     = m.WipeAmount;
            ActAmount      = m.ActAmount;
            ArriveTime     = m.ArriveTime;
            SubmitTime     = m.SubmitTime;
            ConfirmTime    = m.ConfirmTime;
            InsertTime     = m.InsertTime;
            Remark         = m.Remark;
            WorkList       = m.WorkList;
            ApproveFlag    = m.ApproveFlag;

            int.TryParse(m["OrderSource"], out OrderSource);

            //订货单明细
            Items = new List <OrderDetail>();
            foreach (PBM_OrderDetail item in bll.Items)
            {
                Items.Add(new OrderDetail(item));
            }

            //预收款信息列表
            PayInfos = new List <OrderPayInfo>();
            foreach (PBM_OrderPayInfo item in bll.GetPayInfoList())
            {
                PayInfos.Add(new OrderPayInfo(item));
            }

            #region 获取各字段ID对应的名称
            if (Supplier > 0)
            {
                CM_Client c = new CM_ClientBLL(Supplier).Model;
                if (c != null)
                {
                    SupplierName = c.FullName;
                }
            }
            if (Client > 0)
            {
                CM_Client c = new CM_ClientBLL(Client).Model;
                if (c != null)
                {
                    ClientName = c.FullName;
                }
            }
            if (SalesMan > 0)
            {
                Org_Staff s = new Org_StaffBLL(SalesMan).Model;
                if (s != null)
                {
                    SalesManName = s.RealName;
                }
            }
            if (StandardPrice > 0)
            {
                PDT_StandardPrice s = new PDT_StandardPriceBLL(StandardPrice).Model;
                if (s != null)
                {
                    StandardPriceName = s.Name;
                }
            }
            #endregion

            #region 获取字典表名称
            try
            {
                if (m.Classify > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_OrderClassify")[m.Classify.ToString()];
                    if (dic != null)
                    {
                        ClassifyName = dic.Name;
                    }
                }

                if (m.State > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_OrderState")[m.State.ToString()];
                    if (dic != null)
                    {
                        StateName = dic.Name;
                    }
                }

                if (OrderSource > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_OrderSource")[OrderSource.ToString()];
                    if (dic != null)
                    {
                        OrderSourceName = dic.Name;
                    }
                }
            }
            catch (System.Exception err)
            {
                LogWriter.WriteLog("MCSFramework.WSI.Order", err);
            }
            #endregion
        }