private void BindData()
    {
        int id = (int)ViewState["ID"];

        ORD_OrderApply apply = new ORD_OrderApplyBLL(id).Model;

        if (apply == null)
        {
            Response.Redirect("FeeApplyList.aspx");
        }



        pn_OrderApply.BindData(apply);
        ViewState["Type"] = apply.Type;

        int month = new AC_AccountMonthBLL(apply.AccountMonth).Model.Month;

        ORD_OrderLimitFactorBLL limitbll = new ORD_OrderLimitFactorBLL();

        ViewState["Limit"] = limitbll.GetLimitInfo(apply.AccountMonth, apply.Client);

        #region 绑定当前申请单的管理片区
        Label lb_OrganizeCity = (Label)pn_OrderApply.FindControl("ORD_OrderApply_OrganizeCity");
        lb_OrganizeCity.Text = TreeTableBLL.GetFullPathName("MCS_Sys.dbo.Addr_OrganizeCity", apply.OrganizeCity);
        #endregion

        BindGrid();
    }
Exemplo n.º 2
0
    /// <summary>
    /// 验证指定发货明细里指定行号填写的发货数量是否超过可发货数量,并保存发货数量
    /// </summary>
    /// <param name="Rowindex">行号</param>
    /// <returns>true:可以发货 false:不可发货</returns>
    private bool VerifyDeliveryQuantity(int Rowindex)
    {
        int applydetailid = (int)gv_OrderList.DataKeys[Rowindex]["ApplyDetailID"];

        ORD_OrderApplyDetail m       = new ORD_OrderApplyBLL().GetDetailModel(applydetailid);
        PDT_Product          product = new PDT_ProductBLL(m.Product).Model;

        int ApplyQuantity = m.BookQuantity + m.AdjustQuantity - m.DeliveryQuantity;

        TextBox tbx_DeliveryQuantity_T = (TextBox)gv_OrderList.Rows[Rowindex].FindControl("tbx_DeliveryQuantity_T");
        TextBox tbx_DeliveryQuantity   = (TextBox)gv_OrderList.Rows[Rowindex].FindControl("tbx_DeliveryQuantity");
        int     DeliveryQuantity       = (int.Parse(tbx_DeliveryQuantity_T.Text) * product.ConvertFactor + int.Parse(tbx_DeliveryQuantity.Text));

        if (DeliveryQuantity <= ApplyQuantity)
        {
            ListTable <ORD_OrderDeliveryDetail> _details = ViewState["Details"] as ListTable <ORD_OrderDeliveryDetail>;
            ORD_OrderDeliveryDetail             d        = _details[applydetailid.ToString()];
            d.DeliveryQuantity = DeliveryQuantity;
            d.SignInQuantity   = d.DeliveryQuantity;    //签收数量默认为实发数量
            _details.Update(d);
            return(true);
        }
        else
        {
            MessageBox.Show(this, "对不起,产品:" + product.FullName + "最多只允许发放" + GetQuantityString(m.Product, ApplyQuantity));
            return(false);
        }
    }
Exemplo n.º 3
0
    protected void bt_Submit_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] != 0)
        {
            bt_Save_Click(null, null);

            ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL((int)ViewState["ID"]);

            if (bll.Items.Count == 0)
            {
                MessageBox.Show(this, "对不起,定单请购明细不能为空!");
                return;
            }
            #region 发起工作流
            NameValueCollection dataobjects = new NameValueCollection();
            dataobjects.Add("ID", ViewState["ID"].ToString());
            dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
            dataobjects.Add("AccountMonth", bll.Model.AccountMonth.ToString());
            dataobjects.Add("TotalFee", lb_TotalCost.Text);
            dataobjects.Add("IsSpecial", bll.Model["IsSpecial"]);
            dataobjects.Add("ProductType", bll.Model["ProductType"]);
            dataobjects.Add("ProductBrand", bll.Model["ProductBrand"]);
            int TaskID;
            TaskID = EWF_TaskBLL.NewTask("Product_Apply", (int)Session["UserID"], "订单产品申请流程,订单号:" + bll.Model.SheetCode, "~/SubModule/Logistics/Order/OrderProductApplyDetail.aspx?ID=" + ViewState["ID"].ToString() + "&Type=1", dataobjects);
            new EWF_TaskBLL(TaskID).Start();
            #endregion

            bll.Model["TaskID"] = TaskID.ToString();
            bll.Model.State     = 2;
            bll.Update();
            Response.Redirect("~/SubModule/EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString());
        }
    }
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        ORD_OrderApplyDetail m = new ORD_OrderApplyBLL().GetDetailModel((int)ViewState["ID"]);
        PDT_Product product = new PDT_ProductBLL(m.Product).Model;

        if (int.Parse(tbx_ApproveQuantity_T.Text) * product.ConvertFactor > m.BookQuantity)
        {
            MessageBox.Show(this, "批复请购数量不能超过申请请购数量!");
            return;
        }

        if (int.Parse(tbx_ApproveQuantity_T.Text) * product.ConvertFactor == m.BookQuantity + m.AdjustQuantity)
        {
            MessageBox.Show(this, "批复请购数量与前一次调整值相同,没有发生变化,不需要调整!");
            return;
        }

        decimal OldAdjustQuantity = m.AdjustQuantity;

        m.AdjustQuantity = int.Parse(tbx_ApproveQuantity_T.Text) * product.ConvertFactor - m.BookQuantity;
        m.AdjustReason += "批复人:【" + Session["UserRealName"].ToString() + "】 批复数量:" + tbx_ApproveQuantity_T.Text + " 调整原因:" + tbx_AdjustReason.Text + "<br/>";

        ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL(m.ApplyID);
        bll.UpdateDetail(m);

        Session["SuccessFlag"] = true;
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "message", "<script language='javascript'>window.close();</script>", false);
    }
Exemplo n.º 5
0
 private void BindGrid()
 {
     if (Session["LogisticsOrderApplyDetail"] != null)
     {
         //有购物车内容,从购物车绑定
         ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
         gv_List.DataSource = cart.Items.Where(p => p.BookQuantity > 0).OrderByDescending(p => p.Price).ToList();
         gv_List.DataBind();
         lb_TotalCost.Text = cart.Items.Sum(m => (m.BookQuantity + m.AdjustQuantity) * m.Price).ToString("0.00");
     }
     else
     {
         //从申请单明细绑定
         ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL((int)ViewState["ID"]);
         gv_List.DataSource = apply.Items.Where(p => p.BookQuantity > 0).OrderByDescending(p => p.Price).ToList();
         gv_List.DataBind();
         lb_TotalCost.Text = apply.Items.Sum(m => (m.BookQuantity + m.AdjustQuantity) * m.Price).ToString("0.00");
     }
     if (lb_BalanceAmount.Text != "" && decimal.Parse(lb_BalanceAmount.Text) != 0)
     {
         lb_AfterSubmitBalance.Text    = (decimal.Parse(lb_BalanceAmount.Text) - decimal.Parse(lb_TotalCost.Text)).ToString("0.00");
         lb_Percent.Text               = (decimal.Parse(lb_TotalCost.Text) / decimal.Parse(lb_BalanceAmount.Text)).ToString("0.##%");
         td_Percent.Visible            = true;
         td_AfterSubmitBalance.Visible = true;
     }
     if (lb_TotalCost.Text != "" && decimal.Parse(lb_TotalCost.Text) != 0 && ViewState["SalesVolume"] != null && (decimal)ViewState["SalesVolume"] > 0)
     {
         lb_ActFeeRate.Text    = Math.Round((decimal.Parse(lb_TotalCost.Text) / (decimal)ViewState["SalesVolume"] * 100), 2).ToString();
         td_actfeerate.Visible = true;
     }
 }
    private void BindGrid()
    {
        int organizecity = 0, client = 0;

        int.TryParse(tr_OrganizeCity.SelectValue, out organizecity);
        if (organizecity > 1 && new Addr_OrganizeCityBLL(organizecity).Model.Level > 3)
        {
            MessageBox.Show(this, "管理片区必须选到办事处及以上!");
            return;
        }
        DateTime beginDate, endDate;

        if (tbx_BeginDate.Text == "" || !DateTime.TryParse(tbx_BeginDate.Text, out beginDate))
        {
            MessageBox.Show(this, "请重新填写开始日期!");
            tbx_BeginDate.Focus();
            return;
        }
        if (tbx_EndDate.Text == "" || !DateTime.TryParse(tbx_EndDate.Text, out endDate))
        {
            MessageBox.Show(this, "请重新填写截至日期!");
            tbx_EndDate.Focus();
            return;
        }
        int.TryParse(select_Client.SelectValue, out client);

        gv_ListDetail.DataSource = ORD_OrderApplyBLL.GetRPTOrderList(organizecity, client, beginDate, endDate, tbx_OrderCode.Text.Trim());
        gv_ListDetail.BindGrid();
    }
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        ORD_OrderApplyDetail m       = new ORD_OrderApplyBLL().GetDetailModel((int)ViewState["ID"]);
        PDT_Product          product = new PDT_ProductBLL(m.Product).Model;

        if (int.Parse(tbx_ApproveQuantity_T.Text) * product.ConvertFactor > m.BookQuantity)
        {
            MessageBox.Show(this, "批复请购数量不能超过申请请购数量!");
            return;
        }

        if (int.Parse(tbx_ApproveQuantity_T.Text) * product.ConvertFactor == m.BookQuantity + m.AdjustQuantity)
        {
            MessageBox.Show(this, "批复请购数量与前一次调整值相同,没有发生变化,不需要调整!");
            return;
        }

        decimal OldAdjustQuantity = m.AdjustQuantity;

        m.AdjustQuantity = int.Parse(tbx_ApproveQuantity_T.Text) * product.ConvertFactor - m.BookQuantity;
        m.AdjustReason  += "批复人:【" + Session["UserRealName"].ToString() + "】 批复数量:" + tbx_ApproveQuantity_T.Text + " 调整原因:" + tbx_AdjustReason.Text + "<br/>";


        ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL(m.ApplyID);

        bll.UpdateDetail(m);

        Session["SuccessFlag"] = true;
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "message", "<script language='javascript'>window.close();</script>", false);
    }
    protected void bt_Finish_Click(object sender, EventArgs e)
    {
        ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL((int)ViewState["ID"]);

        if (apply.Model.State == 3) apply.Finish((int)Session["UserID"]);

        Response.Redirect("OrderApplyList.aspx");
    }
Exemplo n.º 9
0
    protected void bt_Finish_Click(object sender, EventArgs e)
    {
        ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL((int)ViewState["ID"]);

        if (apply.Model.State == 3)
        {
            apply.Finish((int)Session["UserID"]);
        }

        Response.Redirect("OrderApplyList.aspx");
    }
    protected void bt_Delete_Click(object sender, EventArgs e)
    {
        ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL((int)ViewState["ID"]);

        if (apply.Model.State == 1)
        {
            apply.DeleteDetail();
            apply.Delete();
        }
        Response.Redirect("OrderApplyList.aspx");
    }
Exemplo n.º 11
0
 protected int GetSubmitQuantity(int product)
 {
     if ((int)ViewState["Publish"] > 0)
     {
         return(ORD_OrderApplyBLL.GetSubmitQuantity((int)ViewState["Publish"], product));
     }
     else
     {
         return(0);
     }
 }
Exemplo n.º 12
0
    protected void bt_Delete_Click(object sender, EventArgs e)
    {
        ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL((int)ViewState["ID"]);

        if (apply.Model.State == 1)
        {
            apply.DeleteDetail();
            apply.Delete();
        }
        Response.Redirect("OrderApplyList.aspx");
    }
    protected void bt_ReApply_Click(object sender, EventArgs e)
    {
        ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL((int)ViewState["ID"]);
        if (apply.Model == null) Response.Redirect("OrderApplyList.aspx");

        apply.Model.SheetCode = ORD_OrderApplyBLL.GenerateSheetCode(apply.Model.OrganizeCity, apply.Model.AccountMonth);
        apply.Model.State = 1;
        apply.Model["TaskID"] = "";
        int c = apply.Items.Count;      //要激活一下Items对象才能在Add方法中被新增到数据库中

        int newid = apply.Add();
        Response.Redirect("OrderApplyDetail3.aspx?ID=" + newid.ToString());
    }
    protected void tr_OrganizeCity_Selected(object sender, SelectedEventArgs e)
    {
        Label lb_OrganizeCity = (Label)pn_OrderApply.FindControl("ORD_OrderApply_OrganizeCity");

        lb_OrganizeCity.Text = TreeTableBLL.GetFullPathName("MCS_Sys.dbo.Addr_OrganizeCity", e.CurSelectIndex);

        Label lb_SheetCode = (Label)pn_OrderApply.FindControl("ORD_OrderApply_SheetCode");

        lb_SheetCode.Text = ORD_OrderApplyBLL.GenerateSheetCode(e.CurSelectIndex, AC_AccountMonthBLL.GetCurrentMonth());

        MCSSelectControl select_Client = (MCSSelectControl)pn_OrderApply.FindControl("ORD_OrderApply_Client");

        select_Client.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType=2&OrganizeCity=" + e.CurSelectIndex;
    }
    private void BindData()
    {
        ORD_OrderApplyDetail m = new ORD_OrderApplyBLL().GetDetailModel((int)ViewState["ID"]);
        PDT_Product product = new PDT_ProductBLL(m.Product).Model;
        lb_Product.Text = product.FullName;

        img_Product.ImageUrl = ATMT_AttachmentBLL.GetFirstPreviewPicture(11, m.Product);
        if (img_Product.ImageUrl == "") img_Product.Visible = false;

        lb_Package1.Text = DictionaryBLL.GetDicCollections("PDT_Packaging")[product.TrafficPackaging.ToString()].Name;
        lb_Package2.Text = lb_Package1.Text;

        lb_BookQuantity_T.Text = (m.BookQuantity / product.ConvertFactor).ToString();
        tbx_ApproveQuantity_T.Text = ((m.BookQuantity + m.AdjustQuantity) / product.ConvertFactor).ToString();
    }
Exemplo n.º 16
0
    protected void bt_ReApply_Click(object sender, EventArgs e)
    {
        ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL((int)ViewState["ID"]);

        if (apply.Model == null)
        {
            Response.Redirect("OrderApplyList.aspx");
        }

        apply.Model.SheetCode = ORD_OrderApplyBLL.GenerateSheetCode(apply.Model.OrganizeCity, apply.Model.AccountMonth);
        apply.Model.State     = 1;
        apply.Model["TaskID"] = "";
        int c = apply.Items.Count;      //要激活一下Items对象才能在Add方法中被新增到数据库中

        int newid = apply.Add();

        Response.Redirect("OrderApplyDetail3.aspx?ID=" + newid.ToString());
    }
    private void BindData()
    {
        ORD_OrderApplyDetail m       = new ORD_OrderApplyBLL().GetDetailModel((int)ViewState["ID"]);
        PDT_Product          product = new PDT_ProductBLL(m.Product).Model;

        lb_Product.Text = product.FullName;

        img_Product.ImageUrl = ATMT_AttachmentBLL.GetFirstPreviewPicture(11, m.Product);
        if (img_Product.ImageUrl == "")
        {
            img_Product.Visible = false;
        }

        lb_Package1.Text = DictionaryBLL.GetDicCollections("PDT_Packaging")[product.TrafficPackaging.ToString()].Name;
        lb_Package2.Text = lb_Package1.Text;

        lb_BookQuantity_T.Text     = (m.BookQuantity / product.ConvertFactor).ToString();
        tbx_ApproveQuantity_T.Text = ((m.BookQuantity + m.AdjustQuantity) / product.ConvertFactor).ToString();
    }
    protected void bt_Confirm_Click(object sender, ImageClickEventArgs e)
    {
        if (ddl_Publish.SelectedValue != "0")
        {
            int OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue);
            int Publish = int.Parse(ddl_Publish.SelectedValue);
            int Client = 0;
            int.TryParse(select_Client.SelectValue, out Client);

            if (rbl_Type.SelectedValue == "1")
            {
                if (Client == 0)
                {
                    MessageBox.Show(this, "请选择申请的客户!");
                    return;
                }
                else
                {
                    OrganizeCity = new CM_ClientBLL(Client).Model.OrganizeCity;
                }
                if (rbl_IsSpecial.SelectedValue == "2" && ddl_OrderType.SelectedValue=="1")
                {
                    ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL();
                    double DelayDays = Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["OrderDelayDays"]);
                    IList<ORD_OrderApply> orderlist = bll._GetModelList(" Client=" + Client.ToString() + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',4)='1'  AND AccountMonth=" + ddl_AccountMonth.SelectedValue + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',5)=" + ddl_Brand.SelectedValue);
                    if (orderlist.Count >= 2)
                    {
                        MessageBox.Show(this, "对不起,非特殊订单只能申请两次。");
                        return;
                    }
                }
            }
            Session["LogisticsOrderApplyDetail"] = new ORD_OrderCartBLL(Publish, OrganizeCity,int.Parse(ddl_OrderType.SelectedValue),int.Parse(ddl_Brand.SelectedValue),int.Parse(rbl_IsSpecial.SelectedValue),Client);
            Response.Redirect("OrderApplyDetail1.aspx");

        }
        else
        {
            ddl_Publish.Focus();
            MessageBox.Show(this, "请正确选择要申请的产品目录!");
        }
    }
Exemplo n.º 19
0
    protected void bt_AddToDeliveryList_Click(object sender, EventArgs e)
    {
        if (tr_OrganizeCity.SelectValue == "0")
        {
            MessageBox.Show(this, "必须选择管理片区才能点添加");
            return;
        }

        tr_OrganizeCity.Enabled = false;     //开始添加报销后,不允许选择其他的管理片区,保证所有的费用明细都来源于一个管理片区

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

        foreach (GridViewRow row in gv_OrderAplyList.Rows)
        {
            CheckBox cb_Selected = (CheckBox)row.FindControl("cb_Selected");
            if (cb_Selected.Checked)
            {
                int applyid       = (int)gv_OrderAplyList.DataKeys[row.RowIndex][0];
                int applydetialid = (int)gv_OrderAplyList.DataKeys[row.RowIndex][1];


                ORD_OrderApplyBLL    applyBLL    = new ORD_OrderApplyBLL(applyid);
                ORD_OrderApplyDetail applydetail = applyBLL.GetDetailModel(applydetialid);

                ORD_OrderDeliveryDetail m = new ORD_OrderDeliveryDetail();

                m.ApplyDetailID    = applydetialid;
                m.Client           = applyBLL.Model.Client;
                m.Product          = applydetail.Product;
                m.Price            = applydetail.Price;
                m.FactoryPrice     = m.FactoryPrice == 0 ? applydetail.Price : m.FactoryPrice;
                m.DeliveryQuantity = applydetail.BookQuantity + applydetail.AdjustQuantity - applydetail.DeliveryQuantity;
                m.SignInQuantity   = m.DeliveryQuantity;

                _details.Add(m);
            }
        }
        bNoDelivery = true;
        BindGrid();
        gv_OrderAplyList.PageIndex = 0;
        BindOrderApplyCanDelivery();
    }
Exemplo n.º 20
0
    protected void bt_Confirm_Click(object sender, ImageClickEventArgs e)
    {
        if (ddl_Publish.SelectedValue != "0")
        {
            int Client = 0;
            int.TryParse(select_Client.SelectValue, out Client);
            if (Client == 0)
            {
                MessageBox.Show(this, "请选择申请的客户!");
                return;
            }
            int Receiver = 0;
            int.TryParse(select_Receiver.SelectValue, out Receiver);
            if (Receiver == 0)
            {
                MessageBox.Show(this, "请选择收货客户!");
                return;
            }
            //if (ddl_Address.SelectedValue == "0")
            //{
            //    MessageBox.Show(this, "该客户没有对应ERP地址ID!");
            //    return;
            //}
            if (ORD_OrderApplyBLL.CheckClientCanApply(int.Parse(ddl_AccountMonth.SelectedValue), int.Parse(select_Client.SelectValue), int.Parse(ddl_Publish.SelectedValue)) <= 0)
            {
                MessageBox.Show(this, "该申请品项目录当月申请已达到可申请上限!");
                ddl_Publish.Focus();
                return;
            }
            int Publish      = int.Parse(ddl_Publish.SelectedValue);
            int OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue);
            int AccountMonth = int.Parse(ddl_AccountMonth.SelectedValue);

            Session["LogisticsOrderApplyDetail"] = new ORD_OrderCartBLL(Publish, OrganizeCity, Client, AccountMonth, 0, Receiver, "");
            Response.Redirect("OrderApplyDetail1.aspx");
        }
        else
        {
            ddl_Publish.Focus();
            MessageBox.Show(this, "请正确选择要申请的发布目录!");
        }
    }
 private void BindData()
 {
     if (ViewState["SheetCode"].ToString() != "")
     {
         DataTable dt = ORD_OrderApplyBLL.GetRPTOrderDetail(ViewState["SheetCode"].ToString());
         if (dt.Rows.Count > 0)
         {
             DataRow row = dt.Rows[0];
             lb_Fdate.Text     = DateTime.Parse(row["fdate"].ToString()).ToShortDateString();
             lb_DICode.Text    = row["fnumber"].ToString();
             lb_Addr.Text      = row["ffetchadd"].ToString();
             lb_SheetCode.Text = ViewState["SheetCode"].ToString();
             lb_DIName.Text    = row["经销商名称"].ToString();
             lb_CarryDI.Text   = row["货运商"].ToString();
             lb_Remark.Text    = row["fheadselfB0167"].ToString();
         }
         gv_ListDetail.DataSource = dt;
         gv_ListDetail.BindGrid();
     }
 }
    private void BindGrid()
    {
        int organizecity = 0, month = 0, classify = 0, client = 0;

        int.TryParse(tr_OrganizeCity.SelectValue, out organizecity);
        if (organizecity > 1 && new Addr_OrganizeCityBLL(organizecity).Model.Level > 3)
        {
            MessageBox.Show(this, "管理片区必须选到办事处及以上!");
            return;
        }
        if (!int.TryParse(ddl_Month.SelectedValue, out month))
        {
            MessageBox.Show(this, "请正确选择月份!");
            return;
        }
        int.TryParse(ddl_Classify.SelectedValue, out classify);
        int.TryParse(select_Client.SelectValue, out client);
        gv_ListDetail.DataSource = ORD_OrderApplyBLL.GetRPTOrderApplyPayTrack(month, client, classify, organizecity);
        gv_ListDetail.BindGrid();
    }
    protected bool bNoSignIn = false; //未签收,界面签收数量字段可编辑

    #endregion Fields

    #region Methods

    protected void bt_AddToDeliveryList_Click(object sender, EventArgs e)
    {
        if (tr_OrganizeCity.SelectValue == "0")
        {
            MessageBox.Show(this, "必须选择管理片区才能点添加");
            return;
        }

        tr_OrganizeCity.Enabled = false;     //开始添加报销后,不允许选择其他的管理片区,保证所有的费用明细都来源于一个管理片区

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

        foreach (GridViewRow row in gv_OrderAplyList.Rows)
        {
            CheckBox cb_Selected = (CheckBox)row.FindControl("cb_Selected");
            if (cb_Selected.Checked)
            {
                int applyid = (int)gv_OrderAplyList.DataKeys[row.RowIndex][0];
                int applydetialid = (int)gv_OrderAplyList.DataKeys[row.RowIndex][1];

                ORD_OrderApplyBLL applyBLL = new ORD_OrderApplyBLL(applyid);
                ORD_OrderApplyDetail applydetail = applyBLL.GetDetailModel(applydetialid);

                ORD_OrderDeliveryDetail m = new ORD_OrderDeliveryDetail();

                m.ApplyDetailID = applydetialid;
                m.Client = applyBLL.Model.Client;
                m.Product = applydetail.Product;
                m.Price = applydetail.Price;
                m.FactoryPrice = m.FactoryPrice == 0 ? applydetail.Price : m.FactoryPrice;
                m.DeliveryQuantity = applydetail.BookQuantity + applydetail.AdjustQuantity - applydetail.DeliveryQuantity;
                m.SignInQuantity = m.DeliveryQuantity;

                _details.Add(m);
            }
        }
        bNoDelivery = true;
        BindGrid();
        gv_OrderAplyList.PageIndex = 0;
        BindOrderApplyCanDelivery();
    }
    protected void bt_Confirm_Click(object sender, ImageClickEventArgs e)
    {
        if (ddl_Publish.SelectedValue != "0")
        {
            int OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue);
            int Publish      = int.Parse(ddl_Publish.SelectedValue);
            int Client       = 0;
            int.TryParse(select_Client.SelectValue, out Client);

            if (rbl_Type.SelectedValue == "1")
            {
                if (Client == 0)
                {
                    MessageBox.Show(this, "请选择申请的客户!");
                    return;
                }
                else
                {
                    OrganizeCity = new CM_ClientBLL(Client).Model.OrganizeCity;
                }
                if (rbl_IsSpecial.SelectedValue == "2" && ddl_OrderType.SelectedValue == "1")
                {
                    ORD_OrderApplyBLL      bll       = new ORD_OrderApplyBLL();
                    double                 DelayDays = Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["OrderDelayDays"]);
                    IList <ORD_OrderApply> orderlist = bll._GetModelList(" Client=" + Client.ToString() + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',4)='1'  AND AccountMonth=" + ddl_AccountMonth.SelectedValue + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',5)=" + ddl_Brand.SelectedValue);
                    if (orderlist.Count >= 2)
                    {
                        MessageBox.Show(this, "对不起,非特殊订单只能申请两次。");
                        return;
                    }
                }
            }
            Session["LogisticsOrderApplyDetail"] = new ORD_OrderCartBLL(Publish, OrganizeCity, int.Parse(ddl_OrderType.SelectedValue), int.Parse(ddl_Brand.SelectedValue), int.Parse(rbl_IsSpecial.SelectedValue), Client);
            Response.Redirect("OrderApplyDetail1.aspx");
        }
        else
        {
            ddl_Publish.Focus();
            MessageBox.Show(this, "请正确选择要申请的产品目录!");
        }
    }
    /// <summary>
    /// 设置页面gv_ProductList控件中,调整金额是否只读
    /// </summary>

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            #region 判断传入参数是否为SheetCode
            if (Request.QueryString["SheetCode"] != null)
            {
                string code = Request.QueryString["SheetCode"];

                IList <ORD_OrderApply> list = ORD_OrderApplyBLL.GetModelList("SheetCode='" + code + "'");
                if (list.Count > 0)
                {
                    Response.Redirect("OrderProductApplyDetail.aspx?ID=" + list[0].ID.ToString());
                }
                else
                {
                    Response.Redirect("OrderApplyList.aspx");
                }
            }
            #endregion
            ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]);


            ViewState["Product"] = 0;

            #region 创建空的列表
            ListTable <ORD_OrderApplyDetail> _details = new ListTable <ORD_OrderApplyDetail>(new ORD_OrderApplyBLL((int)ViewState["ID"]).Items, "Product");
            ViewState["Details"] = _details;
            #endregion

            if ((int)ViewState["ID"] != 0)
            {
                BindData();
            }
            Header.Attributes["WebPageSubCode"] = "Type=" + ViewState["Type"].ToString();
        }
    }
Exemplo n.º 26
0
    protected void bt_SaveAdjust_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] != 0)
        {
            ListTable <ORD_OrderApplyDetail> _details = ViewState["Details"] as ListTable <ORD_OrderApplyDetail>;

            foreach (GridViewRow row in gv_ProductList.Rows)
            {
                int productid = (int)gv_ProductList.DataKeys[row.RowIndex]["Product"];

                ORD_OrderApplyDetail m       = _details[productid.ToString()];
                PDT_Product          product = new PDT_ProductBLL(m.Product).Model;

                TextBox tbx_AdjustQuantity_T = (TextBox)row.FindControl("tbx_AdjustQuantity_T");
                TextBox tbx_AdjustQuantity   = (TextBox)row.FindControl("tbx_AdjustQuantity");

                int quantity = int.Parse(tbx_AdjustQuantity_T.Text) * product.ConvertFactor + int.Parse(tbx_AdjustQuantity.Text);
                if (m.BookQuantity + quantity < 0)
                {
                    MessageBox.Show(this, "对不起,扣减的调整数量不能大于定货数量!");
                    return;
                }
                m.AdjustQuantity = quantity;
                m.AdjustReason   = ((TextBox)row.FindControl("tbx_AdjustReason")).Text;

                _details.Update(m);
            }

            ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL((int)ViewState["ID"]);
            bll.Items = _details.GetListItem(ItemState.Modified);

            bll.UpdateDetail();

            BindGrid();
        }
    }
    protected void bt_SaveAdjust_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] != 0)
        {
            ListTable<ORD_OrderApplyDetail> _details = ViewState["Details"] as ListTable<ORD_OrderApplyDetail>;

            foreach (GridViewRow row in gv_ProductList.Rows)
            {
                int productid = (int)gv_ProductList.DataKeys[row.RowIndex]["Product"];

                ORD_OrderApplyDetail m = _details[productid.ToString()];
                PDT_Product product = new PDT_ProductBLL(m.Product).Model;

                TextBox tbx_AdjustQuantity_T = (TextBox)row.FindControl("tbx_AdjustQuantity_T");
                TextBox tbx_AdjustQuantity = (TextBox)row.FindControl("tbx_AdjustQuantity");

                int quantity = int.Parse(tbx_AdjustQuantity_T.Text) * product.ConvertFactor + int.Parse(tbx_AdjustQuantity.Text);
                if (m.BookQuantity + quantity < 0)
                {
                    MessageBox.Show(this, "对不起,扣减的调整数量不能大于定货数量!");
                    return;
                }
                m.AdjustQuantity = quantity;
                m.AdjustReason = ((TextBox)row.FindControl("tbx_AdjustReason")).Text;

                _details.Update(m);
            }

            ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL((int)ViewState["ID"]);
            bll.Items = _details.GetListItem(ItemState.Modified);

            bll.UpdateDetail();

            BindGrid();
        }
    }
Exemplo n.º 28
0
        /// <summary>
        /// 根据请购买申请单重新初始化购物车
        /// </summary>
        /// <param name="ApplyID"></param>
        /// <returns></returns>
        public static ORD_OrderCartBLL InitByOrderApply(int ApplyID)
        {
            ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL(ApplyID);
            if (apply.Model == null) return null;

            ORD_ApplyPublishBLL publish = new ORD_ApplyPublishBLL(apply.Model.PublishID);
            if (publish.Model == null) return null;
            int addressid = 0;
            int.TryParse(apply.Model["AddressID"], out addressid);
            ORD_OrderCartBLL cart = new ORD_OrderCartBLL(apply.Model.PublishID, apply.Model.OrganizeCity, apply.Model.Client, apply.Model.AccountMonth, addressid);

            foreach (ORD_OrderApplyDetail item in apply.Items)
            {
                ORD_ApplyPublishDetail _m = publish.Items.FirstOrDefault(m => m.Product == item.Product);
                if (_m == null) continue;

                ORD_OrderCart cartitem = new ORD_OrderCart();
                cartitem.ID = _m.ID;
                cartitem.Product = _m.Product;
                cartitem.MinQuantity = _m.MinQuantity;
                cartitem.MaxQuantity = _m.MaxQuantity;
                cartitem.Price = item.Price;
                cartitem.AvailableQuantity = _m.AvailableQuantity;
                cartitem.SubmitQuantity = ORD_OrderApplyBLL.GetSubmitQuantity(cart.Publish, cartitem.Product);

                cartitem.BookQuantity = item.BookQuantity;

                cart.Items.Add(cartitem);
            }

            return cart;
        }
    private void BindData()
    {
        ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL((int)ViewState["ID"]);
        if (apply.Model == null) Response.Redirect("FeeApplyList.aspx");

        pn_OrderApply.BindData(apply.Model);

        ViewState["Publish"] = apply.Model.PublishID;
        ORD_ApplyPublish publish = new ORD_ApplyPublishBLL(apply.Model.PublishID).Model;
        #region 根据审批状态控制页面
        if (apply.Model.Type == 2 && apply.Model.State == 1)
        {
            #region 绑定赠品申请预算信息

            if (publish == null) Response.Redirect("OrderApplyDetail0.aspx");
            int productbrand = 0, giftclassify = 0;
            int.TryParse(publish["ProductBrand"], out productbrand);
            int.TryParse(publish["GiftClassify"], out giftclassify);
            int giftfeetype = publish.FeeType;
            int month = apply.Model.AccountMonth;
            int city = apply.Model.OrganizeCity;
            int client = apply.Model.Client;

            BindBudgetInfo(city, month, client, giftfeetype, productbrand, giftclassify);

            tb_GiftBudgetInfo.Visible = true;
            #endregion
        }

        if (apply.Model.State != 1)
        {
            //非 未提交 状态
            pn_OrderApply.SetControlsEnable(false);

            bt_EditCart.Visible = false;
            bt_Delete.Visible = false;
            bt_Save.Visible = false;
            bt_Submit.Visible = false;

            //可见调整数量及原因
            gv_List.Columns[gv_List.Columns.Count - 4].Visible = true;      //调整原因
            gv_List.Columns[gv_List.Columns.Count - 5].Visible = true;      //批复数量
        }

        AC_AccountMonth endmonht = new AC_AccountMonthBLL(apply.Model.AccountMonth).Model;
        DateTime reapplyend;
        reapplyend = DateTime.Parse(endmonht.Name + ConfigHelper.GetConfigString("GiftReApplyDate"));
        bt_ReApply.Visible = !(DateTime.Now > reapplyend);
        switch (apply.Model.State)
        {
            case 1:     //编辑状态
                bt_Finish.Visible = false;
                bt_ReApply.Visible = false;
                break;
            case 2:     //已提交状态,审批过程中,可以作申请数量调整
                if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
                    gv_List.Columns[gv_List.Columns.Count - 2].Visible = true;      //允许调整

                bt_Finish.Visible = false;
                bt_ReApply.Visible = false;
                break;
            case 3:     //审核已通过
            case 4:     //审核已通过后,终止发放(该功能暂未启用)
                bt_Finish.Visible = false;
                bt_ReApply.Visible = false;
                //gv_List.Columns[gv_List.Columns.Count - 1].Visible = true;      //已发放数量
                break;
            case 8:     //审核不通过
                bt_Finish.Visible = false;
                int forwarddays = ConfigHelper.GetConfigInt("GiftApplyForwardDays");
                if (apply.Model.AccountMonth < AC_AccountMonthBLL.GetMonthByDate(DateTime.Now.AddDays(forwarddays)))
                    bt_ReApply.Visible = false;
                break;
            default:
                break;
        }
        #endregion

        BindGrid();
    }
Exemplo n.º 30
0
    private bool Save()
    {
        ORD_OrderCartBLL cart = null;

        if (Session["LogisticsOrderApplyDetail"] != null)
        {
            cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
        }

        if ((int)ViewState["ID"] == 0)
        {
            if (cart == null || cart.Items.Count == 0)
            {
                MessageBox.Show(this, "对不起,定单申请明细不能为空!");
                return(false);
            }

            ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL();
            pn_OrderApply.GetData(bll.Model);

            #region 判断有没有填写经销商
            if (bll.Model.Client == 0)
            {
                MessageBox.Show(this, "对不起,请填写申请定购的经销商!");
                return(false);
            }
            #endregion

            #region 初始化定单字段
            bll.Model.OrganizeCity = cart.OrganizeCity;
            bll.Model.PublishID    = cart.Publish;
            bll.Model.AccountMonth = cart.AccountMonth;
            bll.Model.SheetCode    = ORD_OrderApplyBLL.GenerateSheetCode(bll.Model.OrganizeCity, bll.Model.AccountMonth); //自动产生备案号
            bll.Model.ApproveFlag  = 2;
            bll.Model.State        = 1;
            bll.Model.InsertStaff  = (int)Session["UserID"];
            bll.Model["AddressID"] = cart.AddressID.ToString();
            bll.Model["Receiver"]  = cart.Receiver.ToString();
            if (cart.Publish > 0)
            {
                ORD_ApplyPublish publish = new ORD_ApplyPublishBLL(cart.Publish).Model;
                if (publish != null)
                {
                    bll.Model["ProductBrand"] = publish["ProductBrand"];
                    bll.Model["GiftClassify"] = publish["GiftClassify"];
                }
            }
            #endregion

            ViewState["ID"] = bll.Add();

            #region 新增定单明细明细
            foreach (ORD_OrderCart cartitem in cart.Items)
            {
                if (cartitem.BookQuantity == 0)
                {
                    continue;
                }
                ORD_OrderApplyDetail m = new ORD_OrderApplyDetail();
                m.ApplyID          = (int)ViewState["ID"];
                m.Product          = cartitem.Product;
                m.Price            = cartitem.Price;
                m.BookQuantity     = cartitem.BookQuantity;
                m.AdjustQuantity   = 0;
                m.DeliveryQuantity = 0;

                bll.AddDetail(m);
            }
            #endregion
        }
        else
        {
            ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL((int)ViewState["ID"]);
            pn_OrderApply.GetData(bll.Model);
            bll.Model.UpdateStaff = (int)Session["UserID"];
            bll.Update();

            #region 修改明细
            if (cart != null)
            {
                //先将现有定单中每个品项与购物中的比较
                //如果购物车中没有该产品,则删除,如有且数量不同,则更新,并从购物车中移除该品项
                foreach (ORD_OrderApplyDetail m in bll.Items)
                {
                    ORD_OrderCart cartitem = cart.Items.FirstOrDefault(p => p.Product == m.Product);
                    if (cartitem == null)
                    {
                        bll.DeleteDetail(m.ID);
                    }
                    else
                    {
                        if (cartitem.BookQuantity != m.BookQuantity)
                        {
                            m.BookQuantity = cartitem.BookQuantity;
                            bll.UpdateDetail(m);
                        }
                        cart.RemoveProduct(m.Product);
                    }
                }

                //新购物车中新增的品项加入定单明细中
                foreach (ORD_OrderCart cartitem in cart.Items)
                {
                    ORD_OrderApplyDetail m = new ORD_OrderApplyDetail();
                    m.ApplyID          = (int)ViewState["ID"];
                    m.Product          = cartitem.Product;
                    m.Price            = cartitem.Price;
                    m.BookQuantity     = cartitem.BookQuantity;
                    m.AdjustQuantity   = 0;
                    m.DeliveryQuantity = 0;

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

        return(true);
    }
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        ORD_OrderCartBLL cart = null;
        if (Session["LogisticsOrderApplyDetail"] != null) cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];

        ListTable<ORD_OrderApplyDetail> _details = ViewState["Details"] as ListTable<ORD_OrderApplyDetail>;
        ORD_OrderApplyBLL bll;
        if ((int)ViewState["ID"] == 0)
            bll = new ORD_OrderApplyBLL();
        else
            bll = new ORD_OrderApplyBLL((int)ViewState["ID"]);

        pn_OrderApply.GetData(bll.Model);

        #region 保存明细
        foreach (GridViewRow row in gv_ProductList.Rows)
        {
            int productid = (int)gv_ProductList.DataKeys[row.RowIndex]["Product"];

            ORD_OrderApplyDetail m = _details[productid.ToString()];
            PDT_Product product = new PDT_ProductBLL(m.Product).Model;

            TextBox tbx_price = (TextBox)row.FindControl("tbx_Price");
            TextBox tbx_BookQuantity_T = (TextBox)row.FindControl("tbx_BookQuantity_T");
            TextBox tbx_BookQuantity = (TextBox)row.FindControl("tbx_BookQuantity");

            int quantity = int.Parse(tbx_BookQuantity_T.Text) * product.ConvertFactor + int.Parse(tbx_BookQuantity.Text);

            m.BookQuantity = quantity;
            m.Price = decimal.Parse(tbx_price.Text);

            _details.Update(m);
        }
        #endregion

        if ((int)ViewState["ID"] == 0)
        {
            double DelayDays = Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["OrderDelayDays"]);
            bll.Model.OrganizeCity = cart.OrganizeCity;
            bll.Model.Client = cart.Client;
            bll.Model.PublishID = cart.Publish;
            bll.Model.AccountMonth = AC_AccountMonthBLL.GetMonthByDate(DateTime.Now.AddDays(-DelayDays));
            bll.Model.SheetCode = ORD_OrderApplyBLL.GenerateSheetCode(bll.Model.OrganizeCity, bll.Model.AccountMonth);   //自动产生备案号
            bll.Model.ApproveFlag = 2;
            bll.Model.State = 1;
            bll.Model.InsertStaff = (int)Session["UserID"];
            bll.Model["IsSpecial"] = cart.IsSpecial.ToString();
            bll.Model.Type = cart.Type;
            bll.Model["ProductBrand"] = cart.Brand.ToString();
            bll.Model["ProductType"] = cart.OrderType.ToString();
            bll.Items = _details.GetListItem();

            ViewState["ID"] = bll.Add();
        }
        else
        {
            bll.Model.UpdateStaff = (int)Session["UserID"];
            bll.Update();

            #region 修改明细

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

            #endregion
        }

        if (sender != null)
            Response.Redirect("OrderProductApplyDetail.aspx?ID=" + ViewState["ID"].ToString());
    }
    private void BindData()
    {
        int id = (int)ViewState["ID"];

        ORD_OrderApply apply = new ORD_OrderApplyBLL(id).Model;

        if (apply == null) Response.Redirect("OrderApplyList.aspx");

        if (apply["ProductType"] != "1") priceEnable = true;

        pn_OrderApply.BindData(apply);
        ViewState["Type"] = apply.Type;

        int month = new AC_AccountMonthBLL(apply.AccountMonth).Model.Month;

        ORD_OrderLimitFactorBLL limitbll = new ORD_OrderLimitFactorBLL();
        ViewState["Limit"] = limitbll.GetLimitInfo(apply.AccountMonth, apply.Client);

        #region 绑定当前申请单的管理片区
        Label lb_OrganizeCity = (Label)pn_OrderApply.FindControl("ORD_OrderApply_OrganizeCity");
        lb_OrganizeCity.Text = TreeTableBLL.GetFullPathName("MCS_Sys.dbo.Addr_OrganizeCity", apply.OrganizeCity);
        #endregion

        #region 根据审批状态控制页面

        if (apply.State != 1 && apply.State != 8)
        {
            //提交 状态

            pn_OrderApply.SetControlsEnable(false);
            gv_ProductList.Columns[0].Visible = false;                             //选择 列
            gv_ProductList.Columns[gv_ProductList.Columns.Count - 1].Visible = false;     //删除 列
            bt_Save.Visible = false;
            bt_Submit.Visible = false;
            bt_Delete.Visible = false;
            //可见调整数量及原因
            gv_ProductList.Columns[gv_ProductList.Columns.Count - 4].Visible = true;      //调整原因
            gv_ProductList.Columns[gv_ProductList.Columns.Count - 5].Visible = true;      //调整金额
            bt_SaveAdjust.Visible = false;
        }

        if (apply.State == 2)
        {

            bt_SaveAdjust.Visible = false;

            ///已提交状态,审批过程中,可以作申请数量调整
            if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
            {
                bt_SaveAdjust.Visible = true;
            }

        }

        if (apply.State >= 3)
        {
            bt_SaveAdjust.Visible = false;

            //审批通过
            gv_ProductList.Columns[gv_ProductList.Columns.Count - 3].Visible = true;      //已发放数量
        }
        #endregion

        BindGrid();
    }
    private void BindData()
    {
        int id = (int)ViewState["ID"];

        ORD_OrderApply apply = new ORD_OrderApplyBLL(id).Model;

        if (apply == null) Response.Redirect("FeeApplyList.aspx");

        pn_OrderApply.BindData(apply);
        ViewState["Type"] = apply.Type;

        int month = new AC_AccountMonthBLL(apply.AccountMonth).Model.Month;

        ORD_OrderLimitFactorBLL limitbll = new ORD_OrderLimitFactorBLL();
        ViewState["Limit"] = limitbll.GetLimitInfo(apply.AccountMonth, apply.Client);

        #region 绑定当前申请单的管理片区
        Label lb_OrganizeCity = (Label)pn_OrderApply.FindControl("ORD_OrderApply_OrganizeCity");
        lb_OrganizeCity.Text = TreeTableBLL.GetFullPathName("MCS_Sys.dbo.Addr_OrganizeCity", apply.OrganizeCity);
        #endregion

        BindGrid();
    }
Exemplo n.º 34
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            #region 判断传入参数是否为SheetCode
            if (Request.QueryString["SheetCode"] != null)
            {
                string code = Request.QueryString["SheetCode"];

                IList <ORD_OrderApply> list = ORD_OrderApplyBLL.GetModelList("SheetCode='" + code + "'");
                if (list.Count > 0)
                {
                    Response.Redirect("OrderProductApplyDetail.aspx?ID=" + list[0].ID.ToString());
                }
                else
                {
                    Response.Redirect("OrderApplyList.aspx");
                }
            }
            #endregion
            ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]);

            BindDropDown();
            ViewState["Product"] = 0;

            #region 创建空的列表
            ListTable <ORD_OrderApplyDetail> _details = new ListTable <ORD_OrderApplyDetail>(new ORD_OrderApplyBLL((int)ViewState["ID"]).Items, "Product");
            ViewState["Details"] = _details;
            #endregion

            if (Session["LogisticsOrderApplyDetail"] != null && (int)ViewState["ID"] == 0)
            {
                #region 新费用申请时,初始化申请信
                ORD_OrderCartBLL cart  = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
                ORD_OrderApply   model = new ORD_OrderApply();
                if (cart.Client != 0)
                {
                    model.OrganizeCity = new CM_ClientBLL(cart.Client).Model.OrganizeCity;
                    model.Client       = cart.Client;
                }
                model.InsertStaff     = (int)Session["UserID"];
                model.InsertTime      = DateTime.Now;
                model["IsSpecial"]    = cart.IsSpecial.ToString();
                model.Type            = cart.Type;
                ViewState["Type"]     = cart.Type;
                model["ProductBrand"] = cart.Brand.ToString();
                model["ProductType"]  = cart.OrderType.ToString();
                if (cart.OrderType != 1)
                {
                    priceEnable = true;
                }
                model.AccountMonth = AC_AccountMonthBLL.GetCurrentMonth();

                ORD_OrderLimitFactorBLL limitbll = new ORD_OrderLimitFactorBLL();
                ViewState["Limit"] = limitbll.GetLimitInfo(Convert.ToInt32(model.AccountMonth), cart.Client);
                bt_Submit.Visible  = false;


                foreach (ORD_OrderCart item in cart.Items)
                {
                    ORD_OrderApplyDetail _detailmodel = new ORD_OrderApplyDetail();
                    _detailmodel.Price        = item.Price;
                    _detailmodel.Product      = item.Product;
                    _detailmodel.BookQuantity = item.BookQuantity;
                    _details.Add(_detailmodel);
                }
                ViewState["Details"] = _details;
                pn_OrderApply.BindData(model);
                BindGrid();
                #endregion
            }
            else
            {
                BindData();
            }

            Header.Attributes["WebPageSubCode"] = "Type=" + ViewState["Type"].ToString();
        }
    }
Exemplo n.º 35
0
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        #region  效性校验
        if (tr_OrganizeCity.SelectValue == "0")
        {
            MessageBox.Show(this, "必须选择管理片区才能保存!");
            return;
        }
        #endregion

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

        if (_details.GetListItem().Count == 0)
        {
            MessageBox.Show(this, "在保存之前,发货明细不能为空!");
            return;
        }
        ORD_OrderDeliveryBLL bll;

        if ((int)ViewState["ID"] == 0)
        {
            bll = new ORD_OrderDeliveryBLL();
        }
        else
        {
            bll = new ORD_OrderDeliveryBLL((int)ViewState["ID"]);
        }

        if ((int)ViewState["ID"] == 0)
        {
            bll.Model.AccountMonth = AC_AccountMonthBLL.GetCurrentMonth();
            bll.Model.InsertStaff  = (int)Session["UserID"];
            bll.Model.OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue);
            bll.Model.State        = 1;
            bll.Model.ApproveFlag  = 2;
            bll.Model.SheetCode    = ORD_OrderDeliveryBLL.GenerateSheetCode(bll.Model.OrganizeCity, bll.Model.AccountMonth);
            bll.Items = _details.GetListItem();

            ViewState["ID"] = bll.Add();
        }
        else
        {
            bll.Model.UpdateStaff = (int)Session["UserID"];

            bll.Update();

            #region 修改明细

            #region 增加发放明细时,再次判断该项费用是否超过发放数量
            bll.Items = new List <ORD_OrderDeliveryDetail>();
            foreach (ORD_OrderDeliveryDetail item in _details.GetListItem(ItemState.Added))
            {
                ORD_OrderApplyDetail apply = new ORD_OrderApplyBLL().GetDetailModel(item.ApplyDetailID);
                if (apply.BookQuantity + apply.AdjustQuantity - apply.DeliveryQuantity >= item.DeliveryQuantity)
                {
                    bll.Items.Add(item);
                }
            }
            bll.AddDetail();
            #endregion

            foreach (ORD_OrderDeliveryDetail _deleted in _details.GetListItem(ItemState.Deleted))
            {
                bll.DeleteDetail(_deleted.ID);
            }

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

            #endregion
        }
        if (sender != null)
        {
            MessageBox.ShowAndRedirect(this, "保存成功", "OrderDeliveryDetail.aspx?ID=" + ViewState["ID"].ToString());
        }
    }
Exemplo n.º 36
0
    private void BindData()
    {
        ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL((int)ViewState["ID"]);

        if (apply.Model == null)
        {
            Response.Redirect("FeeApplyList.aspx");
        }

        pn_OrderApply.BindData(apply.Model);

        ViewState["Publish"] = apply.Model.PublishID;
        ORD_ApplyPublish publish = new ORD_ApplyPublishBLL(apply.Model.PublishID).Model;

        #region 根据审批状态控制页面
        if (apply.Model.Type == 2 && apply.Model.State == 1)
        {
            #region 绑定赠品申请预算信息


            if (publish == null)
            {
                Response.Redirect("OrderApplyDetail0.aspx");
            }
            int productbrand = 0, giftclassify = 0;
            int.TryParse(publish["ProductBrand"], out productbrand);
            int.TryParse(publish["GiftClassify"], out giftclassify);
            int giftfeetype = publish.FeeType;
            int month       = apply.Model.AccountMonth;
            int city        = apply.Model.OrganizeCity;
            int client      = apply.Model.Client;

            BindBudgetInfo(city, month, client, giftfeetype, productbrand, giftclassify);

            tb_GiftBudgetInfo.Visible = true;
            #endregion
        }

        if (apply.Model.State != 1)
        {
            //非 未提交 状态
            pn_OrderApply.SetControlsEnable(false);

            bt_EditCart.Visible = false;
            bt_Delete.Visible   = false;
            bt_Save.Visible     = false;
            bt_Submit.Visible   = false;

            //可见调整数量及原因
            gv_List.Columns[gv_List.Columns.Count - 4].Visible = true;      //调整原因
            gv_List.Columns[gv_List.Columns.Count - 5].Visible = true;      //批复数量
        }

        AC_AccountMonth endmonht = new AC_AccountMonthBLL(apply.Model.AccountMonth).Model;
        DateTime        reapplyend;
        reapplyend         = DateTime.Parse(endmonht.Name + ConfigHelper.GetConfigString("GiftReApplyDate"));
        bt_ReApply.Visible = !(DateTime.Now > reapplyend);
        switch (apply.Model.State)
        {
        case 1:         //编辑状态
            bt_Finish.Visible  = false;
            bt_ReApply.Visible = false;
            break;

        case 2:         //已提交状态,审批过程中,可以作申请数量调整
            if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
            {
                gv_List.Columns[gv_List.Columns.Count - 2].Visible = true;          //允许调整
            }
            bt_Finish.Visible  = false;
            bt_ReApply.Visible = false;
            break;

        case 3:         //审核已通过
        case 4:         //审核已通过后,终止发放(该功能暂未启用)
            bt_Finish.Visible  = false;
            bt_ReApply.Visible = false;
            //gv_List.Columns[gv_List.Columns.Count - 1].Visible = true;      //已发放数量
            break;

        case 8:         //审核不通过
            bt_Finish.Visible = false;
            int forwarddays = ConfigHelper.GetConfigInt("GiftApplyForwardDays");
            if (apply.Model.AccountMonth < AC_AccountMonthBLL.GetMonthByDate(DateTime.Now.AddDays(forwarddays)))
            {
                bt_ReApply.Visible = false;
            }
            break;

        default:
            break;
        }
        #endregion

        BindGrid();
    }
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        #region 有效性校验
        if (tr_OrganizeCity.SelectValue == "0")
        {
            MessageBox.Show(this, "必须选择管理片区才能保存!");
            return;
        }
        #endregion

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

        if (_details.GetListItem().Count == 0)
        {
            MessageBox.Show(this, "在保存之前,发货明细不能为空!");
            return;
        }
        ORD_OrderDeliveryBLL bll;

        if ((int)ViewState["ID"] == 0)
            bll = new ORD_OrderDeliveryBLL();
        else
            bll = new ORD_OrderDeliveryBLL((int)ViewState["ID"]);

        if ((int)ViewState["ID"] == 0)
        {
            bll.Model.AccountMonth = AC_AccountMonthBLL.GetCurrentMonth();
            bll.Model.InsertStaff = (int)Session["UserID"];
            bll.Model.OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue);
            bll.Model.State = 1;
            bll.Model.ApproveFlag = 2;
            bll.Model.SheetCode = ORD_OrderDeliveryBLL.GenerateSheetCode(bll.Model.OrganizeCity, bll.Model.AccountMonth);
            bll.Items = _details.GetListItem();

            ViewState["ID"] = bll.Add();

        }
        else
        {
            bll.Model.UpdateStaff = (int)Session["UserID"];

            bll.Update();

            #region 修改明细

            #region 增加发放明细时,再次判断该项费用是否超过发放数量
            bll.Items = new List<ORD_OrderDeliveryDetail>();
            foreach (ORD_OrderDeliveryDetail item in _details.GetListItem(ItemState.Added))
            {
                ORD_OrderApplyDetail apply = new ORD_OrderApplyBLL().GetDetailModel(item.ApplyDetailID);
                if (apply.BookQuantity + apply.AdjustQuantity - apply.DeliveryQuantity >= item.DeliveryQuantity)
                {
                    bll.Items.Add(item);
                }
            }
            bll.AddDetail();
            #endregion

            foreach (ORD_OrderDeliveryDetail _deleted in _details.GetListItem(ItemState.Deleted))
            {
                bll.DeleteDetail(_deleted.ID);
            }

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

            #endregion
        }
        if (sender != null)
            MessageBox.ShowAndRedirect(this, "保存成功", "OrderDeliveryDetail.aspx?ID=" + ViewState["ID"].ToString());
    }
Exemplo n.º 38
0
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        ORD_OrderCartBLL cart = null;

        if (Session["LogisticsOrderApplyDetail"] != null)
        {
            cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
        }

        ListTable <ORD_OrderApplyDetail> _details = ViewState["Details"] as ListTable <ORD_OrderApplyDetail>;
        ORD_OrderApplyBLL bll;

        if ((int)ViewState["ID"] == 0)
        {
            bll = new ORD_OrderApplyBLL();
        }
        else
        {
            bll = new ORD_OrderApplyBLL((int)ViewState["ID"]);
        }

        pn_OrderApply.GetData(bll.Model);

        #region 保存明细
        foreach (GridViewRow row in gv_ProductList.Rows)
        {
            int productid = (int)gv_ProductList.DataKeys[row.RowIndex]["Product"];

            ORD_OrderApplyDetail m       = _details[productid.ToString()];
            PDT_Product          product = new PDT_ProductBLL(m.Product).Model;

            TextBox tbx_price          = (TextBox)row.FindControl("tbx_Price");
            TextBox tbx_BookQuantity_T = (TextBox)row.FindControl("tbx_BookQuantity_T");
            TextBox tbx_BookQuantity   = (TextBox)row.FindControl("tbx_BookQuantity");

            int quantity = int.Parse(tbx_BookQuantity_T.Text) * product.ConvertFactor + int.Parse(tbx_BookQuantity.Text);

            m.BookQuantity = quantity;
            m.Price        = decimal.Parse(tbx_price.Text);

            _details.Update(m);
        }
        #endregion

        if ((int)ViewState["ID"] == 0)
        {
            double DelayDays = Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["OrderDelayDays"]);
            bll.Model.OrganizeCity    = cart.OrganizeCity;
            bll.Model.Client          = cart.Client;
            bll.Model.PublishID       = cart.Publish;
            bll.Model.AccountMonth    = AC_AccountMonthBLL.GetMonthByDate(DateTime.Now.AddDays(-DelayDays));
            bll.Model.SheetCode       = ORD_OrderApplyBLL.GenerateSheetCode(bll.Model.OrganizeCity, bll.Model.AccountMonth); //自动产生备案号
            bll.Model.ApproveFlag     = 2;
            bll.Model.State           = 1;
            bll.Model.InsertStaff     = (int)Session["UserID"];
            bll.Model["IsSpecial"]    = cart.IsSpecial.ToString();
            bll.Model.Type            = cart.Type;
            bll.Model["ProductBrand"] = cart.Brand.ToString();
            bll.Model["ProductType"]  = cart.OrderType.ToString();
            bll.Items = _details.GetListItem();

            ViewState["ID"] = bll.Add();
        }
        else
        {
            bll.Model.UpdateStaff = (int)Session["UserID"];
            bll.Update();

            #region 修改明细

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

            #endregion
        }

        if (sender != null)
        {
            Response.Redirect("OrderProductApplyDetail.aspx?ID=" + ViewState["ID"].ToString());
        }
    }
    /// <summary>
    /// 验证指定发货明细里指定行号填写的发货数量是否超过可发货数量,并保存发货数量
    /// </summary>
    /// <param name="Rowindex">行号</param>
    /// <returns>true:可以发货 false:不可发货</returns>
    private bool VerifyDeliveryQuantity(int Rowindex)
    {
        int applydetailid = (int)gv_OrderList.DataKeys[Rowindex]["ApplyDetailID"];

        ORD_OrderApplyDetail m = new ORD_OrderApplyBLL().GetDetailModel(applydetailid);
        PDT_Product product = new PDT_ProductBLL(m.Product).Model;

        int ApplyQuantity = m.BookQuantity + m.AdjustQuantity - m.DeliveryQuantity;

        TextBox tbx_DeliveryQuantity_T = (TextBox)gv_OrderList.Rows[Rowindex].FindControl("tbx_DeliveryQuantity_T");
        TextBox tbx_DeliveryQuantity = (TextBox)gv_OrderList.Rows[Rowindex].FindControl("tbx_DeliveryQuantity");
        int DeliveryQuantity = (int.Parse(tbx_DeliveryQuantity_T.Text) * product.ConvertFactor + int.Parse(tbx_DeliveryQuantity.Text));

        if (DeliveryQuantity <= ApplyQuantity)
        {
            ListTable<ORD_OrderDeliveryDetail> _details = ViewState["Details"] as ListTable<ORD_OrderDeliveryDetail>;
            ORD_OrderDeliveryDetail d = _details[applydetailid.ToString()];
            d.DeliveryQuantity = DeliveryQuantity;
            d.SignInQuantity = d.DeliveryQuantity;      //签收数量默认为实发数量
            _details.Update(d);
            return true;
        }
        else
        {
            MessageBox.Show(this, "对不起,产品:" + product.FullName + "最多只允许发放" + GetQuantityString(m.Product, ApplyQuantity));
            return false;
        }
    }
Exemplo n.º 40
0
    private void BindData()
    {
        int id = (int)ViewState["ID"];

        ORD_OrderApply apply = new ORD_OrderApplyBLL(id).Model;

        if (apply == null)
        {
            Response.Redirect("OrderApplyList.aspx");
        }

        if (apply["ProductType"] != "1")
        {
            priceEnable = true;
        }

        pn_OrderApply.BindData(apply);
        ViewState["Type"] = apply.Type;

        int month = new AC_AccountMonthBLL(apply.AccountMonth).Model.Month;

        ORD_OrderLimitFactorBLL limitbll = new ORD_OrderLimitFactorBLL();

        ViewState["Limit"] = limitbll.GetLimitInfo(apply.AccountMonth, apply.Client);

        #region 绑定当前申请单的管理片区
        Label lb_OrganizeCity = (Label)pn_OrderApply.FindControl("ORD_OrderApply_OrganizeCity");
        lb_OrganizeCity.Text = TreeTableBLL.GetFullPathName("MCS_Sys.dbo.Addr_OrganizeCity", apply.OrganizeCity);
        #endregion

        #region 根据审批状态控制页面

        if (apply.State != 1 && apply.State != 8)
        {
            //提交 状态

            pn_OrderApply.SetControlsEnable(false);
            gv_ProductList.Columns[0].Visible = false;                                //选择 列
            gv_ProductList.Columns[gv_ProductList.Columns.Count - 1].Visible = false; //删除 列
            bt_Save.Visible   = false;
            bt_Submit.Visible = false;
            bt_Delete.Visible = false;
            //可见调整数量及原因
            gv_ProductList.Columns[gv_ProductList.Columns.Count - 4].Visible = true;      //调整原因
            gv_ProductList.Columns[gv_ProductList.Columns.Count - 5].Visible = true;      //调整金额
            bt_SaveAdjust.Visible = false;
        }

        if (apply.State == 2)
        {
            bt_SaveAdjust.Visible = false;

            ///已提交状态,审批过程中,可以作申请数量调整
            if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
            {
                bt_SaveAdjust.Visible = true;
            }
        }

        if (apply.State >= 3)
        {
            bt_SaveAdjust.Visible = false;

            //审批通过
            gv_ProductList.Columns[gv_ProductList.Columns.Count - 3].Visible = true;      //已发放数量
        }
        #endregion

        BindGrid();
    }
    protected void bt_Submit_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] != 0)
        {
            bt_Save_Click(null, null);

            ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL((int)ViewState["ID"]);

            if (bll.Items.Count == 0)
            {
                MessageBox.Show(this, "对不起,定单请购明细不能为空!");
                return;
            }
            #region 发起工作流
            NameValueCollection dataobjects = new NameValueCollection();
            dataobjects.Add("ID", ViewState["ID"].ToString());
            dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
            dataobjects.Add("AccountMonth", bll.Model.AccountMonth.ToString());
            dataobjects.Add("TotalFee", lb_TotalCost.Text);
            dataobjects.Add("IsSpecial", bll.Model["IsSpecial"]);
            dataobjects.Add("ProductType", bll.Model["ProductType"]);
            dataobjects.Add("ProductBrand", bll.Model["ProductBrand"]);
            int TaskID;
            TaskID = EWF_TaskBLL.NewTask("Product_Apply", (int)Session["UserID"], "订单产品申请流程,订单号:" + bll.Model.SheetCode, "~/SubModule/Logistics/Order/OrderProductApplyDetail.aspx?ID=" + ViewState["ID"].ToString() + "&Type=1", dataobjects);
            new EWF_TaskBLL(TaskID).Start();
            #endregion

            bll.Model["TaskID"] = TaskID.ToString();
            bll.Model.State = 2;
            bll.Update();
            Response.Redirect("~/SubModule/EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString());
        }
    }
    protected void bt_Submit_Click(object sender, EventArgs e)
    {
        if (!Save()) return;

        if ((int)ViewState["ID"] != 0)
        {
            ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL((int)ViewState["ID"]);
            Session["SubmitOrderApplyID"] = (int)ViewState["ID"];
            if (bll.Model.State > 1) Response.Redirect("OrderApplyList.aspx");

            if (bll.Items.Count == 0)
            {
                MessageBox.ShowAndRedirect(this, "对不起,定单申请明细不能为空!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString());
                return;
            }

            if (bll.Model.AccountMonth < AC_AccountMonthBLL.GetCurrentMonth())
            {
                MessageBox.Show(this, "对不起,该订单申请月份已不是当前月份,已不可提交,请删除该单后重新申请赠品!");
                return;
            }

            decimal totalcost = bll.Items.Sum(m => m.BookQuantity * m.Price);

            if (bll.Model.Type == 2)
            {
                //促销品申请
                #region 判断预算额度余额是否够申请
                ORD_ApplyPublish publish = new ORD_ApplyPublishBLL(bll.Model.PublishID).Model;
                int productbrand = 0, giftclassify = 0;
                int.TryParse(publish["ProductBrand"], out productbrand);
                int.TryParse(publish["GiftClassify"], out giftclassify);

                decimal _budgetbalance = FNA_BudgetBLL.GetUsableAmount(bll.Model.AccountMonth, bll.Model.OrganizeCity, publish.FeeType);
                decimal _productbalance = ORD_GiftApplyAmountBLL.GetBalanceAmount(bll.Model.AccountMonth, bll.Model.Client, productbrand, giftclassify);

                decimal _balance = _productbalance;
                //2012-3-27 暂时限定赠品额度,不限定预算
                //decimal _balance = (_budgetbalance > _productbalance ? _productbalance : _budgetbalance);
                string[] nolimitbrand = Addr_OrganizeCityParamBLL.GetValueByType(1, 24).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
                if (_balance < totalcost && !nolimitbrand.Contains(publish["ProductBrand"]))
                {
                    if (bll.Model["GiftClassify"] == "2" && _balance > 0 && ORD_OrderApplyBLL.GetModelList("Client=" + bll.Model.Client.ToString() + " AND AccountMonth=" + bll.Model.AccountMonth.ToString() + " AND State IN (2,3) AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',5)=" + bll.Model["ProductBrand"] + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',7)=" + bll.Model["GiftClassify"]).Count == 0)
                    {
                        //判断是否可以申请最低金额赠品1件
                        decimal MinApplyAmount = 0, MaxApplyAmount = 0;

                        ORD_ApplyPublishBLL _publishbll = new ORD_ApplyPublishBLL(bll.Model.PublishID);
                        _publishbll.GetMinApplyAmount(out MinApplyAmount, out MaxApplyAmount);
                        if (_balance > 0 && _balance < MinApplyAmount)
                        {

                            if (bll.Items.Count > 1)
                            {
                                MessageBox.Show(this, "对不起,您当前的可申请余额不足,仅能申请最多1件赠品");
                                return;
                            }
                            else
                            {
                                int applyproduct = bll.Items[0].Product;
                                ORD_ApplyPublishDetail applydetail = _publishbll.Items.FirstOrDefault(p => p.Product == applyproduct);
                                if (applydetail != null && applydetail.MinQuantity < bll.Items[0].BookQuantity)
                                {
                                    MessageBox.Show(this, "对不起,您当前的可申请余额不足,仅能申请最多1件赠品");
                                    return;
                                }
                            }
                        }
                        else
                        {
                            MessageBox.ShowAndRedirect(this, "对不起,您当前的可申请余额[" + _balance.ToString("0.##") + "]不够申请这些品项!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString());
                            return;
                        }

                    }
                    else
                    {
                        MessageBox.ShowAndRedirect(this, "对不起,您当前的可申请余额[" + _balance.ToString("0.##") + "]不够申请这些品项!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString());
                        return;
                    }
                }
                #endregion

                #region 发起工作流
                NameValueCollection dataobjects = new NameValueCollection();

                dataobjects.Add("ID", ViewState["ID"].ToString());
                dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
                dataobjects.Add("AccountMonth", bll.Model.AccountMonth.ToString());
                dataobjects.Add("FeeType", publish.FeeType.ToString());
                dataobjects.Add("ProductBrand", publish["ProductBrand"]);
                dataobjects.Add("GiftClassify", publish["GiftClassify"]);
                dataobjects.Add("TotalFee", totalcost.ToString());

                int TaskID = EWF_TaskBLL.NewTask("CuXiaoPin_Apply", (int)Session["UserID"], "促销品申请申请流程", "~/SubModule/Logistics/Order/OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString() + "&Type=2", dataobjects);

                new EWF_TaskBLL(TaskID).Start();
                #endregion

                bll.Submit((int)Session["UserID"], TaskID);

                Response.Redirect("~/SubModule/EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString());
            }
            else
            {
                //产品申请申请
                bll.Submit((int)Session["UserID"], 0);
                Response.Redirect("OrderApplyList.aspx");
            }
        }
    }
    private bool Save()
    {
        ORD_OrderCartBLL cart = null;
        if (Session["LogisticsOrderApplyDetail"] != null) cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];

        if ((int)ViewState["ID"] == 0)
        {
            if (cart == null || cart.Items.Count == 0)
            {
                MessageBox.Show(this, "对不起,定单申请明细不能为空!");
                return false;
            }

            ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL();
            pn_OrderApply.GetData(bll.Model);

            #region 判断有没有填写经销商
            if (bll.Model.Client == 0)
            {
                MessageBox.Show(this, "对不起,请填写申请定购的经销商!");
                return false;
            }
            #endregion

            #region 初始化定单字段
            bll.Model.OrganizeCity = cart.OrganizeCity;
            bll.Model.PublishID = cart.Publish;
            bll.Model.AccountMonth = cart.AccountMonth;
            bll.Model.SheetCode = ORD_OrderApplyBLL.GenerateSheetCode(bll.Model.OrganizeCity, bll.Model.AccountMonth);   //自动产生备案号
            bll.Model.ApproveFlag = 2;
            bll.Model.State = 1;
            bll.Model.InsertStaff = (int)Session["UserID"];
            bll.Model["AddressID"] = cart.AddressID.ToString();
            bll.Model["Receiver"] = cart.Receiver.ToString();
            if (cart.Publish > 0)
            {
                ORD_ApplyPublish publish = new ORD_ApplyPublishBLL(cart.Publish).Model;
                if (publish != null)
                {
                    bll.Model["ProductBrand"] = publish["ProductBrand"];
                    bll.Model["GiftClassify"] = publish["GiftClassify"];
                }
            }
            #endregion

            ViewState["ID"] = bll.Add();

            #region 新增定单明细明细
            foreach (ORD_OrderCart cartitem in cart.Items)
            {
                if (cartitem.BookQuantity == 0) continue;
                ORD_OrderApplyDetail m = new ORD_OrderApplyDetail();
                m.ApplyID = (int)ViewState["ID"];
                m.Product = cartitem.Product;
                m.Price = cartitem.Price;
                m.BookQuantity = cartitem.BookQuantity;
                m.AdjustQuantity = 0;
                m.DeliveryQuantity = 0;

                bll.AddDetail(m);
            }
            #endregion
        }
        else
        {
            ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL((int)ViewState["ID"]);
            pn_OrderApply.GetData(bll.Model);
            bll.Model.UpdateStaff = (int)Session["UserID"];
            bll.Update();

            #region 修改明细
            if (cart != null)
            {
                //先将现有定单中每个品项与购物中的比较
                //如果购物车中没有该产品,则删除,如有且数量不同,则更新,并从购物车中移除该品项
                foreach (ORD_OrderApplyDetail m in bll.Items)
                {
                    ORD_OrderCart cartitem = cart.Items.FirstOrDefault(p => p.Product == m.Product);
                    if (cartitem == null)
                        bll.DeleteDetail(m.ID);
                    else
                    {
                        if (cartitem.BookQuantity != m.BookQuantity)
                        {
                            m.BookQuantity = cartitem.BookQuantity;
                            bll.UpdateDetail(m);
                        }
                        cart.RemoveProduct(m.Product);
                    }
                }

                //新购物车中新增的品项加入定单明细中
                foreach (ORD_OrderCart cartitem in cart.Items)
                {
                    ORD_OrderApplyDetail m = new ORD_OrderApplyDetail();
                    m.ApplyID = (int)ViewState["ID"];
                    m.Product = cartitem.Product;
                    m.Price = cartitem.Price;
                    m.BookQuantity = cartitem.BookQuantity;
                    m.AdjustQuantity = 0;
                    m.DeliveryQuantity = 0;

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

        return true;
    }
 private void BindGrid()
 {
     if (Session["LogisticsOrderApplyDetail"] != null)
     {
         //有购物车内容,从购物车绑定
         ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
         gv_List.DataSource = cart.Items.Where(p => p.BookQuantity > 0).OrderByDescending(p => p.Price).ToList();
         gv_List.DataBind();
         lb_TotalCost.Text = cart.Items.Sum(m => (m.BookQuantity + m.AdjustQuantity) * m.Price).ToString("0.00");
     }
     else
     {
         //从申请单明细绑定
         ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL((int)ViewState["ID"]);
         gv_List.DataSource = apply.Items.Where(p => p.BookQuantity > 0).OrderByDescending(p => p.Price).ToList();
         gv_List.DataBind();
         lb_TotalCost.Text = apply.Items.Sum(m => (m.BookQuantity + m.AdjustQuantity) * m.Price).ToString("0.00");
     }
     if (lb_BalanceAmount.Text != "" && decimal.Parse(lb_BalanceAmount.Text) != 0)
     {
         lb_AfterSubmitBalance.Text = (decimal.Parse(lb_BalanceAmount.Text) - decimal.Parse(lb_TotalCost.Text)).ToString("0.00");
         lb_Percent.Text = (decimal.Parse(lb_TotalCost.Text) / decimal.Parse(lb_BalanceAmount.Text)).ToString("0.##%");
         td_Percent.Visible = true;
         td_AfterSubmitBalance.Visible = true;
     }
     if (lb_TotalCost.Text != "" && decimal.Parse(lb_TotalCost.Text) != 0 && ViewState["SalesVolume"] != null && (decimal)ViewState["SalesVolume"] > 0)
     {
         lb_ActFeeRate.Text = Math.Round((decimal.Parse(lb_TotalCost.Text) / (decimal)ViewState["SalesVolume"] * 100), 2).ToString();
         td_actfeerate.Visible = true;
     }
 }
Exemplo n.º 45
0
    private void BindGrid()
    {
        gv_List.Columns[2].Visible = true;
        gv_List.Columns[3].Visible = true;
        gv_List.Columns[4].Visible = true;
        int month        = int.Parse(ddl_Month.SelectedValue);
        int organizecity = int.Parse(tr_OrganizeCity.SelectValue);
        int level        = int.Parse(ddl_Level.SelectedValue);
        int productType  = int.Parse(ddl_ProductType.SelectedValue);
        int brand        = int.Parse(ddl_Brand.SelectedValue);
        int classify     = int.Parse(ddl_Classify.SelectedValue);
        int product      = select_Product.SelectValue == ""?0:int.Parse(select_Product.SelectValue);
        int state        = int.Parse(ddl_State.SelectedValue);

        if (level > 10)
        {
            gv_List.Columns[3].Visible = false;
            gv_List.Columns[4].Visible = false;
        }
        if (level == 30)
        {
            gv_List.Columns[2].Visible = false;
        }
        if (MCSTabControl1.SelectedIndex == 0)
        {
            #region 显示汇总单数据源

            DataTable dtSummary = ORD_OrderApplyBLL.GetSummaryTotal(month, organizecity, level, productType, brand, classify, product, state);
            if (dtSummary.Rows.Count == 0)
            {
                gv_List.DataBind();
                return;
            }

            DataRow dtrow = dtSummary.NewRow();
            dtrow["Level"]     = "合计";
            dtrow["ProductID"] = 0;
            dtrow["Weight"]    = dtSummary.Compute("Sum(Weight)", "true");
            dtrow["Price"]     = dtSummary.Compute("Sum(Price)", "true");
            dtrow["Quantity"]  = dtSummary.Compute("Sum(Quantity)", "true");
            dtSummary.Rows.Add(dtrow);
            gv_List.DataSource = dtSummary;
            gv_List.DataBind();


            #endregion
        }
        else
        {
            string condition = " ORD_OrderApply.Type =1 AND ORD_OrderApply.AccountMonth = " + ddl_Month.SelectedValue;
            #region 组织查询条件

            if (tr_OrganizeCity.SelectValue != "1")
            {
                //管理片区及所有下属管理片区
                Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue));
                string orgcitys = orgcity.GetAllChildNodeIDs();
                if (orgcitys != "")
                {
                    orgcitys += ",";
                }
                orgcitys += tr_OrganizeCity.SelectValue;

                condition += " AND ORD_OrderApply.OrganizeCity IN (" + orgcitys + ")";
            }

            if (ddl_ProductType.SelectedValue != "0")
            {
                condition += " AND MCS_SYS.dbo.UF_Spilt(ORD_OrderApply.ExtPropertys,'|',4)=" + ddl_ProductType.SelectedValue;
            }

            if (ddl_Brand.SelectedValue != "0")
            {
                condition += " AND MCS_SYS.dbo.UF_Spilt(ORD_OrderApply.ExtPropertys,'|',5)=" + ddl_Brand.SelectedValue;
            }

            //审批状态
            if (ddl_State.SelectedValue != "0")
            {
                condition += " AND ORD_OrderApply.State = " + ddl_State.SelectedValue;
            }

            #endregion
            gv_ListDetail.ConditionString = condition;
            gv_ListDetail.BindGrid();
        }
    }
Exemplo n.º 46
0
    protected void bt_Submit_Click(object sender, EventArgs e)
    {
        if (!Save())
        {
            return;
        }

        if ((int)ViewState["ID"] != 0)
        {
            ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL((int)ViewState["ID"]);
            Session["SubmitOrderApplyID"] = (int)ViewState["ID"];
            if (bll.Model.State > 1)
            {
                Response.Redirect("OrderApplyList.aspx");
            }

            if (bll.Items.Count == 0)
            {
                MessageBox.ShowAndRedirect(this, "对不起,定单申请明细不能为空!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString());
                return;
            }

            if (bll.Model.AccountMonth < AC_AccountMonthBLL.GetCurrentMonth())
            {
                MessageBox.Show(this, "对不起,该订单申请月份已不是当前月份,已不可提交,请删除该单后重新申请赠品!");
                return;
            }

            decimal totalcost = bll.Items.Sum(m => m.BookQuantity * m.Price);

            if (bll.Model.Type == 2)
            {
                //促销品申请
                #region 判断预算额度余额是否够申请
                ORD_ApplyPublish publish = new ORD_ApplyPublishBLL(bll.Model.PublishID).Model;
                int productbrand = 0, giftclassify = 0;
                int.TryParse(publish["ProductBrand"], out productbrand);
                int.TryParse(publish["GiftClassify"], out giftclassify);

                decimal _budgetbalance  = FNA_BudgetBLL.GetUsableAmount(bll.Model.AccountMonth, bll.Model.OrganizeCity, publish.FeeType);
                decimal _productbalance = ORD_GiftApplyAmountBLL.GetBalanceAmount(bll.Model.AccountMonth, bll.Model.Client, productbrand, giftclassify);

                decimal _balance = _productbalance;
                //2012-3-27 暂时限定赠品额度,不限定预算
                //decimal _balance = (_budgetbalance > _productbalance ? _productbalance : _budgetbalance);
                string[] nolimitbrand = Addr_OrganizeCityParamBLL.GetValueByType(1, 24).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
                if (_balance < totalcost && !nolimitbrand.Contains(publish["ProductBrand"]))
                {
                    if (bll.Model["GiftClassify"] == "2" && _balance > 0 && ORD_OrderApplyBLL.GetModelList("Client=" + bll.Model.Client.ToString() + " AND AccountMonth=" + bll.Model.AccountMonth.ToString() + " AND State IN (2,3) AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',5)=" + bll.Model["ProductBrand"] + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',7)=" + bll.Model["GiftClassify"]).Count == 0)
                    {
                        //判断是否可以申请最低金额赠品1件
                        decimal MinApplyAmount = 0, MaxApplyAmount = 0;

                        ORD_ApplyPublishBLL _publishbll = new ORD_ApplyPublishBLL(bll.Model.PublishID);
                        _publishbll.GetMinApplyAmount(out MinApplyAmount, out MaxApplyAmount);
                        if (_balance > 0 && _balance < MinApplyAmount)
                        {
                            if (bll.Items.Count > 1)
                            {
                                MessageBox.Show(this, "对不起,您当前的可申请余额不足,仅能申请最多1件赠品");
                                return;
                            }
                            else
                            {
                                int applyproduct = bll.Items[0].Product;
                                ORD_ApplyPublishDetail applydetail = _publishbll.Items.FirstOrDefault(p => p.Product == applyproduct);
                                if (applydetail != null && applydetail.MinQuantity < bll.Items[0].BookQuantity)
                                {
                                    MessageBox.Show(this, "对不起,您当前的可申请余额不足,仅能申请最多1件赠品");
                                    return;
                                }
                            }
                        }
                        else
                        {
                            MessageBox.ShowAndRedirect(this, "对不起,您当前的可申请余额[" + _balance.ToString("0.##") + "]不够申请这些品项!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString());
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.ShowAndRedirect(this, "对不起,您当前的可申请余额[" + _balance.ToString("0.##") + "]不够申请这些品项!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString());
                        return;
                    }
                }
                #endregion

                #region 发起工作流
                NameValueCollection dataobjects = new NameValueCollection();

                dataobjects.Add("ID", ViewState["ID"].ToString());
                dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
                dataobjects.Add("AccountMonth", bll.Model.AccountMonth.ToString());
                dataobjects.Add("FeeType", publish.FeeType.ToString());
                dataobjects.Add("ProductBrand", publish["ProductBrand"]);
                dataobjects.Add("GiftClassify", publish["GiftClassify"]);
                dataobjects.Add("TotalFee", totalcost.ToString());

                int TaskID = EWF_TaskBLL.NewTask("CuXiaoPin_Apply", (int)Session["UserID"], "促销品申请申请流程", "~/SubModule/Logistics/Order/OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString() + "&Type=2", dataobjects);

                new EWF_TaskBLL(TaskID).Start();
                #endregion

                bll.Submit((int)Session["UserID"], TaskID);

                Response.Redirect("~/SubModule/EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString());
            }
            else
            {
                //产品申请申请
                bll.Submit((int)Session["UserID"], 0);
                Response.Redirect("OrderApplyList.aspx");
            }
        }
    }