Exemplo n.º 1
0
    protected void bt_ConfirmSignIn_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] != 0)
        {
            ORD_OrderDeliveryBLL bll = new ORD_OrderDeliveryBLL((int)ViewState["ID"]);
            pn_OrderDelivery.GetData(bll.Model);
            if (bll.Model["SignInTime"] == "1900-01-01")
            {
                MessageBox.Show(this, "请选择实际到货日期!");
                return;
            }
            if (DateTime.Parse(bll.Model["SignInTime"]) > DateTime.Now)
            {
                MessageBox.Show(this, "实际到货日期不能大于今天!");
                return;
            }

            if (new CM_ClientBLL(bll.Model.Client).Model.ClientType == 2 && SVM_InventoryBLL.GetModelList("Client=" + bll.Model.Client.ToString() + " AND AccountMonth=" + bll.Model.AccountMonth.ToString() + " AND ApproveFlag=2").Count > 0)
            {
                MessageBox.ShowAndRedirect(this, "该经销商本月还有未审核库存,请先审核库存再作此操作。", "InventoryList.aspx?ClientID=" + bll.Model.Client.ToString());
                return;
            }

            ListTable <ORD_OrderDeliveryDetail> _details = ViewState["Details"] as ListTable <ORD_OrderDeliveryDetail>;

            #region 判断签收数量是否大于发放数量
            for (int i = 0; i < gv_OrderList.Rows.Count; i++)
            {
                int id = (int)gv_OrderList.DataKeys[i]["ID"];

                ORD_OrderDeliveryDetail m       = new ORD_OrderDeliveryBLL().GetDetailModel(id);
                PDT_Product             product = new PDT_ProductBLL(m.Product).Model;


                TextBox tbx_SignInQuantity_T = (TextBox)gv_OrderList.Rows[i].FindControl("tbx_SignInQuantity_T");
                TextBox tbx_SignInQuantity   = (TextBox)gv_OrderList.Rows[i].FindControl("tbx_SignInQuantity");

                TextBox tbx_BadQuantity_T = (TextBox)gv_OrderList.Rows[i].FindControl("tbx_BadQuantity_T");
                TextBox tbx_BadQuantity   = (TextBox)gv_OrderList.Rows[i].FindControl("tbx_BadQuantity");

                TextBox tbx_LostQuantity_T = (TextBox)gv_OrderList.Rows[i].FindControl("tbx_LostQuantity_T");
                TextBox tbx_LostQuantity   = (TextBox)gv_OrderList.Rows[i].FindControl("tbx_LostQuantity");

                int SignInQuantity = (int.Parse(tbx_SignInQuantity_T.Text) * product.ConvertFactor + int.Parse(tbx_SignInQuantity.Text));
                int BadQuantity    = (int.Parse(tbx_BadQuantity_T.Text) * product.ConvertFactor + int.Parse(tbx_BadQuantity.Text));
                int LostQuantity   = (int.Parse(tbx_LostQuantity_T.Text) * product.ConvertFactor + int.Parse(tbx_LostQuantity.Text));

                if (SignInQuantity < 0 || BadQuantity < 0 || LostQuantity < 0)
                {
                    MessageBox.Show(this, "对不起,产品:" + product.FullName + "签收、丢失、破损的数量不能小于0");
                    return;
                }
                if (SignInQuantity + BadQuantity + LostQuantity != m.DeliveryQuantity)
                {
                    MessageBox.Show(this, "对不起,产品:" + product.FullName + "签收、丢失、破损的数量必需等于实发数量" + GetQuantityString(m.Product, m.DeliveryQuantity));
                    return;
                }

                m.SignInQuantity = SignInQuantity;
                m.BadQuantity    = BadQuantity;
                m.LostQuantity   = LostQuantity;

                _details.Update(m);
            }
            #endregion


            bll.Model["SignInStaff"] = Session["UserID"].ToString();
            bll.Model.State          = 3; //已签收

            bll.Update();

            bll.Items = _details.GetListItem(ItemState.Modified);
            bll.UpdateDetail();

            MessageBox.ShowAndRedirect(this, "发货单签收成功!", "OrderDeliveryList.aspx");
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 绑定客户信息
    /// </summary>
    /// <param name="type">销量类型 1:经销商进货 3:经销商出货(即门店进货) 3:门店出货</param>
    /// <param name="sellinclient">进货客户</param>
    /// <param name="supplier">出货客户</param>
    private void BindClientInfo(int sellinclient, int supplier)
    {
        if (sellinclient > 0)
        {
            CM_Client _r = new CM_ClientBLL(sellinclient).Model;
            switch (_r.ClientType)
            {
            case 1:     //公司仓库
                hy_SellInClient.NavigateUrl = "~/SubModule/CM/Store/StoreDetail.aspx?ClientID=" + sellinclient.ToString();
                break;

            case 2:     //经销商
                hy_SellInClient.NavigateUrl = "~/SubModule/CM/DI/DistributorDetail.aspx?ClientID=" + sellinclient.ToString();
                break;

            case 3:     //终端门店
                hy_SellInClient.NavigateUrl = "~/SubModule/CM/RT/RetailerDetail.aspx?ClientID=" + sellinclient.ToString();
                break;
            }
            hy_SellInClient.Text = "(" + _r.Code + ")" + _r.FullName;

            if (supplier == 0)
            {
                supplier = _r.Supplier;

                #region 根据门店或分销商取供货商
                //成品,只取第一供货商
                //赠品,先取第二供货商,如果取不到,则取第一供货商
                if ((bool)ViewState["IsCXP"])
                {
                    int supplier2 = 0;
                    int.TryParse(_r["Supplier2"], out supplier2);
                    if (supplier2 != 0)
                    {
                        supplier = supplier2;
                    }
                }
                CM_Client _s = new CM_ClientBLL(supplier).Model;
                ddl_SellOutClient.Items.Add(new ListItem("(" + _s.Code + ")" + _s.FullName, _s.ID.ToString()));
                #endregion

                hy_SellOutClient.Visible = false;

                //经销商登录时,供货商直接选择该经销商
                Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"]);
                if (!string.IsNullOrEmpty(staff.Model["RelateClient"]))
                {
                    if (ddl_SellOutClient.Items.FindByValue(staff.Model["RelateClient"]) == null)
                    {
                        MessageBox.ShowAndRedirect(this, "对不起,您无法向该客户配送" + ((bool)ViewState["IsCXP"] ? "赠品" : "成品") + "!",
                                                   "SalesVolumeList.aspx?Type=" + ViewState["Type"].ToString() + "&SellInClientID=" + _r.ID.ToString());
                    }

                    ddl_SellOutClient.SelectedValue = staff.Model["RelateClient"];
                    ddl_SellOutClient.Enabled       = false;
                }
            }

            if ((int)ViewState["VolumeID"] == 0 && new CM_ClientBLL(int.Parse(ddl_SellOutClient.SelectedValue)).Model.ClientType == 2 && SVM_InventoryBLL.GetModelList("Client=" + ddl_SellOutClient.SelectedValue + " AND AccountMonth=" + ddl_AccountMonth.SelectedValue + " AND ApproveFlag=2").Count > 0)
            {
                MessageBox.ShowAndRedirect(this, "该经销商本月还有未审核库存,请先审核库存再作此操作。", "InventoryList.aspx?ClientID=" + ddl_SellOutClient.SelectedValue);
                return;
            }
        }
        else
        {
            hy_SellInClient.Visible = false;
            lb_SellInTitle.Visible  = false;
        }

        if (hy_SellOutClient.Visible)
        {
            if (supplier > 0)
            {
                CM_Client _s = new CM_ClientBLL(supplier).Model;
                switch (_s.ClientType)
                {
                case 1:     //公司仓库
                    hy_SellOutClient.NavigateUrl = "~/SubModule/CM/Store/StoreDetail.aspx?ClientID=" + supplier.ToString();
                    break;

                case 2:     //经销商
                    hy_SellOutClient.NavigateUrl = "~/SubModule/CM/DI/DistributorDetail.aspx?ClientID=" + supplier.ToString();
                    break;

                case 3:     //终端门店
                    hy_SellOutClient.NavigateUrl = "~/SubModule/CM/RT/RetailerDetail.aspx?ClientID=" + supplier.ToString();

                    #region 绑定门店导购员
                    try
                    {
                        lbl_Promotor.Visible = true;
                        ddl_Promotor.Visible = true;

                        AC_AccountMonth month     = new AC_AccountMonthBLL(int.Parse(ddl_AccountMonth.SelectedValue)).Model;
                        StringBuilder   condition = new StringBuilder(" PM_Promotor.BeginWorkDate<='" + month.EndDate.AddDays(1).ToString("yyyy-MM-dd") + "' AND ISNULL(PM_Promotor.EndWorkDate,GETDATE())>='" + month.BeginDate.ToString("yyyy-MM-dd") + "' AND PM_Promotor.ApproveFlag=1 ");
                        condition.Append("AND ID in (SELECT Promotor FROM PM_PromotorInRetailer WHERE Client = " + supplier.ToString() + ")");
                        //if ((int)ViewState["VolumeID"] == 0)
                        //{
                        //    condition.Append(" AND ID NOT IN (SELECT Promotor  FROM [MCS_SVM].[dbo].[SVM_SalesVolume] WHERE Type=3 AND Supplier= " + supplier.ToString() + "  AND AccountMonth=" + ddl_AccountMonth.SelectedValue + " AND Promotor IS NOT NULL)");
                        //}
                        ddl_Promotor.DataSource = PM_PromotorBLL.GetModelList(condition.ToString());
                        ddl_Promotor.DataBind();
                        ddl_Promotor.Items.Insert(0, new ListItem("请选择..", "0"));
                    }
                    catch { }
                    #endregion

                    break;
                }
                hy_SellOutClient.Text     = "(" + _s.Code + ")" + _s.FullName;
                ddl_SellOutClient.Visible = false;
            }
            else
            {
                hy_SellOutClient.Visible  = false;
                ddl_SellOutClient.Visible = false;
                lb_SellOutTitle.Visible   = false;
            }
        }
    }