Exemplo n.º 1
0
    private void BindGrid()
    {
        ListTable <FNA_FeeApplyDetail> _details = ViewState["Details"] as ListTable <FNA_FeeApplyDetail>;

        gv_List.BindGrid <FNA_FeeApplyDetail>(_details.GetListItem());

        //求金额合计
        decimal _totalcost = _details.GetListItem().Sum(p => p.ApplyCost + p.AdjustCost);

        lb_TotalCost.Text = _totalcost.ToString("0.###");

        decimal _totalcost_thismonth = _details.GetListItem().Sum(p => p.BeginMonth <= (int)ViewState["AccountMonth"] ? (p.ApplyCost + p.AdjustCost) : 0);

        lb_TotalCost_ThisMonth.Text = _totalcost_thismonth.ToString("0.###");

        //if (lb_BudgetAmount.Text != string.Empty && decimal.Parse(lb_BudgetAmount.Text) != 0)
        //    lb_Percent.Text = (_totalcost / decimal.Parse(lb_BudgetAmount.Text)).ToString("0.##%");
        //else
        //    lb_Percent.Text = "N%";

        lb_BorrowTotal.Text = _details.GetListItem().Sum(p => p.BeginMonth > (int)ViewState["AccountMonth"] ? (p.ApplyCost + p.AdjustCost) : 0).ToString("0.###");
        if (_details.GetListItem().Count(p => p.Flag == 1) == 0)
        {
            bt_Cancel.Visible = false;
        }
    }
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        ListTable <EWF_Flow_DataObject> lt = (ListTable <EWF_Flow_DataObject>)ViewState["ListTable"];

        EWF_Flow_DataObjectBLL bll = new EWF_Flow_DataObjectBLL();

        foreach (EWF_Flow_DataObject item in lt.GetListItem(ItemState.Added))
        {
            bll.Model = item;
            bll.Add();
        }

        foreach (EWF_Flow_DataObject item in lt.GetListItem(ItemState.Modified))
        {
            bll.Model = item;
            bll.Update();
        }

        foreach (EWF_Flow_DataObject item in lt.GetListItem(ItemState.Deleted))
        {
            bll.Delete(item.ID);
        }

        Response.Redirect("FlowDataObjectList.aspx?AppID=" + ViewState["AppID"].ToString());
    }
Exemplo n.º 3
0
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        ListTable <PDT_ProductCost> _details = (ListTable <PDT_ProductCost>)ViewState["Details"];

        PDT_ProductCostBLL _bll = new PDT_ProductCostBLL();

        foreach (PDT_ProductCost m in _details.GetListItem(ItemState.Added))
        {
            _bll.Model             = m;
            _bll.Model.InsertStaff = (int)Session["UserID"];
            _bll.Model.ApproveFlag = 2;

            _bll.Add();
        }

        foreach (PDT_ProductCost m in _details.GetListItem(ItemState.Modified))
        {
            _bll.Model             = m;
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            _bll.Update();
        }

        foreach (PDT_ProductCost m in _details.GetListItem(ItemState.Deleted))
        {
            _bll.Model = m;
            _bll.Delete();
        }

        Response.Redirect("PDT_ProductCost.aspx?OrganizeCity=" + tr_OrganizeCity.SelectValue);
    }
Exemplo n.º 4
0
    protected void bt_ConfirmSignIn_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] != 0)
        {
            ListTable <ORD_OrderDeliveryDetail> _details = ViewState["Details"] as ListTable <ORD_OrderDeliveryDetail>;
            if (_details.GetListItem().Where(p => p.DeliveryQuantity != p.SignInQuantity + p.BadQuantity + p.LostQuantity).Count() > 0)
            {
                MessageBox.Show(this, "对不起,该笔发货单仍有部分品项为在途状态,不能确认签收!");
                return;
            }

            ORD_OrderDeliveryBLL bll = new ORD_OrderDeliveryBLL((int)ViewState["ID"]);
            pn_OrderDelivery.GetData(bll.Model);

            if (bll.Model["BalanceLostCost"] == "0" &&
                _details.GetListItem().Where(p => p.LostQuantity + p.BadQuantity > 0).Count() > 0)
            {
                MessageBox.Show(this, "对不起,该笔发货单有部分货品丢失或破损,请确认是否物流司机已赔款!");
                return;
            }
            bll.Update();

            bll.SignIn((int)Session["UserID"]);

            MessageBox.ShowAndRedirect(this, "完成签收成功!", "OrderDeliveryList.aspx");
        }
    }
    private void BindGrid()
    {
        if (ViewState["Details"] != null)
        {
            ListTable <PBM_DeliveryDetail> Details = (ListTable <PBM_DeliveryDetail>)ViewState["Details"];

            int category = 1;
            int.TryParse(tr_Category.SelectValue, out category);
            if (category > 1)
            {
                DataTable  dt        = TreeTableBLL.GetAllChildByNodes("MCS_PUB.dbo.PDT_Category", "ID", "SuperID", category.ToString());
                List <int> categorys = new List <int>();
                foreach (DataRow dr in dt.Rows)
                {
                    categorys.Add((int)dr["ID"]);
                }
                categorys.Add(category);

                gv_List.BindGrid(Details.GetListItem().Where(p => categorys.Contains(new PDT_ProductBLL(p.Product).GetProductExtInfo((int)Session["OwnerClient"]).Category)).ToList());
            }
            else
            {
                gv_List.BindGrid(Details.GetListItem());
            }

            if (Details.GetListItem().Count == 0)
            {
                bt_Confirm.Visible = false;
            }
        }
    }
Exemplo n.º 6
0
    private void BindGrid()
    {
        ListTable <FNA_FeeWriteOffDetail> _details = ViewState["Details"] as ListTable <FNA_FeeWriteOffDetail>;

        gv_List.BindGrid <FNA_FeeWriteOffDetail>(_details.GetListItem().OrderBy(p => p.ID).ToList());

        //求合计
        lb_TotalCost.Text = _details.GetListItem().Sum(p => p.WriteOffCost + p.AdjustCost).ToString("0.###");
    }
Exemplo n.º 7
0
    private void BindGrid()
    {
        ListTable <ORD_OrderDeliveryDetail> _details = ViewState["Details"] as ListTable <ORD_OrderDeliveryDetail>;

        gv_OrderList.BindGrid <ORD_OrderDeliveryDetail>(_details.GetListItem().Where(p => p.DeliveryQuantity > 0).ToList());

        //求合计
        lb_TotalFactoryValue.Text = _details.GetListItem().Sum(p => p.DeliveryQuantity * p.FactoryPrice).ToString("合计厂价金额:0.##元");
        lb_TotalSalesValue.Text   = _details.GetListItem().Sum(p => p.DeliveryQuantity * p.Price).ToString("合计销售金额:0.##元");
    }
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        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"]);
        }

        pn_OrderDelivery.GetData(bll.Model);

        if ((int)ViewState["ID"] == 0)
        {
            bll.Model.AccountMonth = AC_AccountMonthBLL.GetCurrentMonth();
            bll.Model.InsertStaff  = (int)Session["UserID"];
            bll.Model.Client       = (int)ViewState["Client"];
            bll.Model.OrganizeCity = (int)ViewState["OrganizeCity"];
            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 修改明细
            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_Edit.aspx?ID=" + ViewState["ID"].ToString());
        }
    }
Exemplo n.º 9
0
    private void BindGrid()
    {
        if (ViewState["Details"] != null)
        {
            ListTable <PBM_DeliveryDetail> Details = (ListTable <PBM_DeliveryDetail>)ViewState["Details"];
            gv_List.BindGrid(Details.GetListItem());

            if (Details.GetListItem().Count == 0)
            {
                bt_Confirm.Visible = false;
            }
        }
    }
Exemplo n.º 10
0
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        PDT_ProductPriceBLL _bll;

        if ((int)ViewState["PriceID"] != 0)
        {
            _bll = new PDT_ProductPriceBLL((int)ViewState["PriceID"]);
        }
        else
        {
            _bll = new PDT_ProductPriceBLL();
        }

        _bll.Model.ApproveFlag = 2;
        _bll.Model.BeginDate   = DateTime.Parse(this.tbx_begin.Text.Trim());
        _bll.Model.EndDate     = ((DateTime.Parse(this.tbx_end.Text.Trim())).AddDays(1)).AddSeconds(-1);
        _bll.Model.Client      = int.Parse(ViewState["ClientID"].ToString());
        _bll.Model.InsertStaff = (int)Session["UserID"];
        ListTable <PDT_ProductPrice_Detail> _details = ViewState["Details"] as ListTable <PDT_ProductPrice_Detail>;

        if ((int)ViewState["PriceID"] != 0)
        {
            _bll.Model.UpdateStaff = int.Parse(Session["UserID"].ToString());
            _bll.Update();

            #region 修改明细
            _bll.Items = _details.GetListItem(ItemState.Added);
            _bll.AddDetail();

            foreach (PDT_ProductPrice_Detail _deleted in _details.GetListItem(ItemState.Deleted))
            {
                _bll.DeleteDetail(_deleted.ID);
            }

            _bll.Items = _details.GetListItem(ItemState.Modified);
            _bll.UpdateDetail();
            #endregion
        }
        else
        {
            _bll.Model.Client      = (int)ViewState["ClientID"];
            _bll.Model.InsertStaff = int.Parse(Session["UserID"].ToString());

            _bll.Items           = _details.GetListItem();
            ViewState["PriceID"] = _bll.Add();
        }
        if (sender != null)
        {
            Response.Redirect("PDT_ProductPrice.aspx?ClientID=" + ViewState["ClientID"].ToString());
        }
    }
Exemplo n.º 11
0
    private void BindGrid()
    {
        ListTable <FNA_FeeApplyDetail> _details = ViewState["Details"] as ListTable <FNA_FeeApplyDetail>;

        gv_List.BindGrid <FNA_FeeApplyDetail>(_details.GetListItem());

        //求销售额合计
        decimal _totalcost = 0;

        foreach (FNA_FeeApplyDetail _detail in _details.GetListItem())
        {
            _totalcost += _detail.ApplyCost + _detail.AdjustCost;
        }
        lb_TotalCost.Text = _totalcost.ToString("0.###");
    }
    private void BindGrid()
    {
        ListTable <ORD_OrderApplyDetail> _details = ViewState["Details"] as ListTable <ORD_OrderApplyDetail>;

        gv_ProductList.BindGrid <ORD_OrderApplyDetail>(_details.GetListItem());

        foreach (GridViewRow row in gv_ProductList.Rows)
        {
            DataTable dt          = ViewState["Limit"] as DataTable;
            int       OrderVolume = 0;
            string    Product     = gv_ProductList.DataKeys[row.RowIndex]["Product"].ToString();
            DataRow[] productrow  = dt.Select("Product=" + Product);
            if (productrow.Count() > 0)
            {
                OrderVolume = Convert.ToInt32(productrow[0]["OrderVolume"]);
                if ((int)ViewState["ID"] != 0 && new ORD_OrderApplyBLL((int)ViewState["ID"]).Model.State == 3)
                {
                    OrderVolume = 0;
                }
                ORD_OrderApplyDetail m = _details[Product];
                Label lb_state         = (Label)row.FindControl("lb_State");
                lb_state.ForeColor = System.Drawing.Color.Red;
                lb_state.Font.Bold = true;
                lb_state.Font.Size = 10;
                if ((OrderVolume + m.BookQuantity) > Convert.ToInt32(productrow[0]["MaxPurchaseVolume"]))
                {
                    row.BackColor    = System.Drawing.Color.FromName("#b7d8f9");
                    lb_state.Visible = true;
                    lb_state.Text    = "↑";
                }
                if ((OrderVolume + m.BookQuantity) < Convert.ToInt32(productrow[0]["MinPurchaseVolume"]))
                {
                    row.BackColor    = System.Drawing.Color.FromName("#7d9cbb");
                    lb_state.Visible = true;
                    lb_state.Text    = "↓";
                }
            }
        }

        //求销售额合计
        decimal _totalcost = 0;

        foreach (ORD_OrderApplyDetail _detail in _details.GetListItem())
        {
            _totalcost += _detail.Price * (_detail.BookQuantity + _detail.AdjustQuantity);
        }
        lb_TotalCost.Text = _totalcost.ToString("0.###");
    }
Exemplo n.º 13
0
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] != 0)
        {
            ListTable <ORD_OrderDeliveryDetail> _details = ViewState["Details"] as ListTable <ORD_OrderDeliveryDetail>;

            ORD_OrderDeliveryBLL bll = new ORD_OrderDeliveryBLL((int)ViewState["ID"]);
            pn_OrderDelivery.GetData(bll.Model);
            bll.Model["SignInStaff"] = Session["UserID"].ToString();
            if (bll.Model["SignInTime"] == "" || bll.Model["SignInTime"] == "1900-01-01")
            {
                bll.Model["SignInTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
            }
            bll.Model.State = 3;   //设为部分签收
            bll.Update();

            #region 修改明细
            bll.Items = _details.GetListItem(ItemState.Modified);
            bll.UpdateDetail();
            #endregion
        }
        if (sender != null)
        {
            MessageBox.ShowAndRedirect(this, "保存成功", "OrderDeliveryDetail.aspx?ID=" + ViewState["ID"].ToString());
        }
    }
Exemplo n.º 14
0
    private void BindGrid()
    {
        ListTable <FNA_FeeWriteOffDetail> _details = Session["FeeWriteOffDetails"] as ListTable <FNA_FeeWriteOffDetail>;

        gv_List.BindGrid <FNA_FeeWriteOffDetail>(_details.GetListItem());

        //求费用核消金额合计
        decimal _totalapplycost = 0, _totalcost = 0;

        foreach (FNA_FeeWriteOffDetail _detail in _details.GetListItem())
        {
            _totalapplycost += _detail.ApplyCost;
            _totalcost      += _detail.WriteOffCost + _detail.AdjustCost;
        }
        lb_TotalCost.Text = _totalcost.ToString("0.###");
    }
Exemplo n.º 15
0
    protected void tbx_DeliveryQuantity_TextChanged(object sender, EventArgs e)
    {
        TextBox tbx_sender = (TextBox)sender;
        int     Quantity   = 0;

        if (int.TryParse(tbx_sender.Text, out Quantity))
        {
            int rowindex = ((GridViewRow)tbx_sender.Parent.Parent).RowIndex;
            if (!VerifyDeliveryQuantity(rowindex))
            {
                tbx_sender.Text = "0";
                return;
            }

            //求合计
            ListTable <ORD_OrderDeliveryDetail> _details = ViewState["Details"] as ListTable <ORD_OrderDeliveryDetail>;
            decimal sumPrice = 0;
            foreach (ORD_OrderDeliveryDetail _detail in _details.GetListItem())
            {
                sumPrice += _detail.Price * _detail.DeliveryQuantity;
            }
            lb_TotalCost.Text = sumPrice.ToString("0.##");
        }
        else
        {
            tbx_sender.Text = "0";
        }
    }
Exemplo n.º 16
0
 private void BindGrid()
 {
     if (ViewState["Details"] != null)
     {
         ListTable <PBM_OrderDetail> Details = (ListTable <PBM_OrderDetail>)ViewState["Details"];
         gv_List.BindGrid(Details.GetListItem());
     }
 }
Exemplo n.º 17
0
    private void BindOrderApplyCanDelivery()
    {
        string condition = "";

        #region 组织查询条件
        if (string.IsNullOrEmpty(tr_OrganizeCity.SelectValue) || tr_OrganizeCity.SelectValue == "0")
        {
            MessageBox.Show(this, "必须选择管理片区");
            return;
        }
        else
        {
            Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue), true);
            string orgcitys = orgcity.GetAllChildNodeIDs();
            if (orgcitys != "")
            {
                orgcitys += ",";
            }
            orgcitys += tr_OrganizeCity.SelectValue;

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

        if (select_Client.SelectValue != "" && select_Client.SelectValue != "0")
        {
            condition += " AND ORD_OrderApply.Client=" + select_Client.SelectValue;
        }

        if (tbx_SheetCode.Text != "")
        {
            condition += " AND ORD_OrderApply.SheetCode like '%" + tbx_SheetCode.Text + "%'";
        }

        #region 排除已选中到发放列表中的产品
        string applydetailids = "";
        ListTable <ORD_OrderDeliveryDetail> _details = ViewState["Details"] as ListTable <ORD_OrderDeliveryDetail>;
        foreach (ORD_OrderDeliveryDetail item in _details.GetListItem())
        {
            applydetailids += item.ApplyDetailID.ToString() + ",";
        }
        if (applydetailids != "")
        {
            applydetailids = applydetailids.Substring(0, applydetailids.Length - 1);
            condition     += " AND ORD_OrderApplyDetail.ID not in (" + applydetailids + ")";
        }
        #endregion

        #endregion

        gv_OrderAplyList.ConditionString = condition;
        gv_OrderAplyList.BindGrid();

        bNoDelivery = true;
    }
Exemplo n.º 18
0
    protected void bt_AddDetail_Click(object sender, EventArgs e)
    {
        if (Session["SuccessFlag"] != null && Session["FeeApplyDetail"] != null && (bool)Session["SuccessFlag"])
        {
            ListTable <FNA_FeeApplyDetail> _details    = ViewState["Details"] as ListTable <FNA_FeeApplyDetail>;
            ListTable <FNA_FeeApplyDetail> _newdetails = (ListTable <FNA_FeeApplyDetail>)Session["FeeApplyDetail"];

            #region 费用申请时,是否可以在一个申请单中申请多家店面费用
            try
            {
                if (!ConfigHelper.GetConfigBool("FeeApplyMutiClientsFee"))
                {
                    if (_details.GetListItem().Count > 0 && _newdetails.GetListItem().Count > 0)
                    {
                        if (_details.GetListItem()[0].Client != _newdetails.GetListItem()[0].Client)
                        {
                            Session["FeeApplyDetail"] = null;
                            Session["SuccessFlag"]    = null;

                            MessageBox.Show(this, "对不起,一份申请单只能申请同一个客户的费用科目申请!");
                            return;
                        }
                    }
                }
            }
            catch { }
            #endregion

            foreach (FNA_FeeApplyDetail item in _newdetails.GetListItem())
            {
                ViewState["MaxID"] = (int)ViewState["MaxID"] + 1;
                item.ID            = (int)ViewState["MaxID"];
                _details.Add(item);
            }

            Session["FeeApplyDetail"] = null;
            Session["SuccessFlag"]    = null;

            BindGrid();
        }
    }
    protected void tbx_DeliveryQuantity_TextChanged(object sender, EventArgs e)
    {
        TextBox tbx_sender = (TextBox)sender;
        int     Quantity   = 0;

        if (int.TryParse(tbx_sender.Text, out Quantity))
        {
            int rowindex  = ((GridViewRow)tbx_sender.Parent.Parent).RowIndex;
            int productid = (int)gv_OrderList.DataKeys[rowindex]["Product"];

            PDT_Product product = new PDT_ProductBLL(productid).Model;

            TextBox tbx_DeliveryQuantity_T = (TextBox)gv_OrderList.Rows[rowindex].FindControl("tbx_DeliveryQuantity_T");
            TextBox tbx_DeliveryQuantity   = (TextBox)gv_OrderList.Rows[rowindex].FindControl("tbx_DeliveryQuantity");

            ListTable <ORD_OrderDeliveryDetail> _details = ViewState["Details"] as ListTable <ORD_OrderDeliveryDetail>;
            ORD_OrderDeliveryDetail             detail   = _details[productid.ToString()];
            detail.DeliveryQuantity = int.Parse(tbx_DeliveryQuantity_T.Text) * product.ConvertFactor + int.Parse(tbx_DeliveryQuantity.Text);

            _details.Update(detail);

            Label lb_FactoryValue = (Label)((GridViewRow)tbx_sender.Parent.Parent).FindControl("lb_FactoryValue");
            if (lb_FactoryValue != null)
            {
                lb_FactoryValue.Text = (detail.FactoryPrice * detail.DeliveryQuantity).ToString("0.##");
            }

            Label lb_SalesValue = (Label)((GridViewRow)tbx_sender.Parent.Parent).FindControl("lb_SalesValue");
            if (lb_SalesValue != null)
            {
                lb_SalesValue.Text = (detail.Price * detail.DeliveryQuantity).ToString("0.##");
            }

            lb_TotalFactoryValue.Text = _details.GetListItem().Sum(p => p.DeliveryQuantity * p.FactoryPrice).ToString("0.##");
            lb_TotalSalesValue.Text   = _details.GetListItem().Sum(p => p.DeliveryQuantity * p.Price).ToString("0.##");
        }
        else
        {
            tbx_sender.Text = "0";
        }
    }
Exemplo n.º 20
0
    private void BindGrid()
    {
        ListTable <ORD_OrderDeliveryDetail> _details = ViewState["Details"] as ListTable <ORD_OrderDeliveryDetail>;

        gv_OrderList.BindGrid <ORD_OrderDeliveryDetail>(_details.GetListItem());

        //求合计
        decimal sumPrice = 0;

        foreach (ORD_OrderDeliveryDetail _detail in _details.GetListItem())
        {
            sumPrice += _detail.Price * _detail.DeliveryQuantity;
        }
        lb_TotalCost.Text = sumPrice.ToString("0.##");

        //如果已有报销明细了,则不允许再修改管理片区
        if (_details.GetListItem().Count > 0)
        {
            tr_OrganizeCity.Enabled = false;
        }
    }
    private void BindGrid()
    {
        ListTable <EWF_Flow_DataObject> lt = (ListTable <EWF_Flow_DataObject>)ViewState["ListTable"];

        //排序后显示
        IList <EWF_Flow_DataObject> orderlist = new List <EWF_Flow_DataObject>();

        foreach (EWF_Flow_DataObject item in lt.GetListItem().OrderBy <EWF_Flow_DataObject, int>(p => p.SortID))
        {
            orderlist.Add(item);
        }
        gv_List.BindGrid <EWF_Flow_DataObject>(orderlist);
    }
Exemplo n.º 22
0
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        ListTable <PDT_ClassifyGiftCostRate> _details = (ListTable <PDT_ClassifyGiftCostRate>)ViewState["Details"];

        PDT_ClassifyGiftCostRateBLL _bll = new PDT_ClassifyGiftCostRateBLL();


        foreach (PDT_ClassifyGiftCostRate m in _details.GetListItem(ItemState.Added))
        {
            _bll.Model             = m;
            _bll.Model.InsertStaff = (int)Session["UserID"];
            _bll.Model.ApproveFlag = 1;
            _bll.Add();
        }

        foreach (PDT_ClassifyGiftCostRate m in _details.GetListItem(ItemState.Modified))
        {
            _bll.Model             = m;
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            _bll.Update();
        }

        foreach (PDT_ClassifyGiftCostRate m in _details.GetListItem(ItemState.Deleted))
        {
            _bll.Model = m;
            _bll.Delete(m.ID);
        }
        if ((int)ViewState["Client"] != 0)
        {
            Response.Redirect("PDT_ClassifyGiftCostRate.aspx?Client=" + select_Client.SelectValue);
        }
        else
        {
            Response.Redirect("PDT_ClassifyGiftCostRate.aspx?OrganizeCity=" + tr_OrganizeCity.SelectValue);
        }
    }
Exemplo n.º 23
0
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        if (!SaveGrid())
        {
            return;
        }

        ListTable <FNA_FeeWriteOffDetail> _details = Session["FeeWriteOffDetails"] as ListTable <FNA_FeeWriteOffDetail>;

        if (_details.GetListItem().Count == 0)
        {
            MessageBox.Show(this, "对不起,报销科目明细中没有记录!");
            return;
        }

        Session["SuccessFlag"] = true;
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "message", "<script language='javascript'>window.close();</script>", false);
    }
Exemplo n.º 24
0
    protected void bt_ConfirmDelivery_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] != 0)
        {
            #region 再次验证发货数量是否超允许发货数量,以防止用户在多个页面分别填写发货单,并保存后再分批发放
            for (int i = 0; i < gv_OrderList.Rows.Count; i++)
            {
                if (!VerifyDeliveryQuantity(i))
                {
                    return;
                }
            }
            #endregion

            ORD_OrderDeliveryBLL bll = new ORD_OrderDeliveryBLL((int)ViewState["ID"]);
            pn_OrderDelivery.GetData(bll.Model);

            if (bll.Model.Store == 0)
            {
                MessageBox.Show(this, "对不起,必须选择发货仓库!");
                return;
            }

            bll.Model["DeliveryTime"]  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            bll.Model["DeliveryStaff"] = Session["UserID"].ToString();

            bll.Update();

            #region 保存实发数量
            ListTable <ORD_OrderDeliveryDetail> _details = ViewState["Details"] as ListTable <ORD_OrderDeliveryDetail>;
            bll.Items = _details.GetListItem(ItemState.Modified);
            bll.UpdateDetail();
            #endregion


            bll.Delivery((int)Session["UserID"]);

            MessageBox.ShowAndRedirect(this, "发货单发放成功,已为在途状态,待签收!", "OrderDeliveryList.aspx");
        }
    }
Exemplo n.º 25
0
    protected void gv_List_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int id = (int)gv_List.DataKeys[e.Row.RowIndex]["ID"];
            ListTable <FNA_FeeWriteOffDetail> _details = ViewState["Details"] as ListTable <FNA_FeeWriteOffDetail>;
            FNA_FeeWriteOffDetail             item     = _details.GetListItem().FirstOrDefault(p => p.ID == id);

            if (item != null && item.AccountTitle > 1)
            {
                if (!string.IsNullOrEmpty(item["TeleFeeRelateTelephone"]) ||
                    !string.IsNullOrEmpty(item["MobileFeeRelateStaff"]))
                {
                    if (e.Row.FindControl("ddl_AccountTitle") != null)
                    {
                        ((DropDownList)e.Row.FindControl("ddl_AccountTitle")).Enabled = false;
                    }

                    if (e.Row.FindControl("ddl_BeginMonth") != null)
                    {
                        ((DropDownList)e.Row.FindControl("ddl_BeginMonth")).Enabled = false;
                    }

                    if (e.Row.FindControl("tbx_WriteOffCost") != null)
                    {
                        ((TextBox)e.Row.FindControl("tbx_WriteOffCost")).Enabled = false;
                    }

                    if (e.Row.FindControl("tbx_Remark") != null)
                    {
                        ((TextBox)e.Row.FindControl("tbx_Remark")).Enabled = false;
                    }
                }
            }
        }
    }
Exemplo n.º 26
0
    /// <summary>
    /// 删除已保存但未提交的申请单
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void bt_Delete_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] != 0)
        {
            ListTable <FNA_FeeApplyDetail> _details = ViewState["Details"] as ListTable <FNA_FeeApplyDetail>;
            FNA_FeeApplyBLL bll = new FNA_FeeApplyBLL((int)ViewState["ID"]);
            if (bll.Model.State != 1)
            {
                MessageBox.Show(this, "对不起,该申请单不为草稿状态,不能删除!");
                return;
            }
            int activityid = 0;
            if (int.TryParse(bll.Model["ActivityID"], out activityid) && activityid > 0)
            {
                //CAT_ActivityBLL cat = new CAT_ActivityBLL(activityid);
                //cat.Model.FeeApply = 0;
            }
            bll.Items = _details.GetListItem(ItemState.Modified);
            bll.DeleteDetail();
            bll.Delete();

            Response.Redirect("~/SubModule/FNA/FeeApply/FeeApplyList.aspx");
        }
    }
Exemplo n.º 27
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();
        }
    }
Exemplo n.º 28
0
    private void BindGrid()
    {
        if (MCSTabControl1.SelectedIndex == 0)
        {
            ListTable <ORD_ApplyPublishDetail> _details = ViewState["Details"] as ListTable <ORD_ApplyPublishDetail>;

            gv_List.BindGrid <ORD_ApplyPublishDetail>(_details.GetListItem().OrderByDescending(p => p.Price).ThenBy(p => p["GiveLevel"]).ToArray());
        }
        else
        {
            //获取非价表产品列表
            string condition = "ID NOT IN (SELECT Product FROM MCS_Logistics.dbo.ORD_ApplyPublishDetail WHERE PublishID=" + ViewState["ID"].ToString() + ")";

            if (ddl_Brand.SelectedValue != "0")
            {
                if (ddl_Classify.SelectedValue == "0")
                {
                    condition += " AND Brand =" + ddl_Brand.SelectedValue;
                }
                else
                {
                    condition += " AND Classify =" + ddl_Classify.SelectedValue;
                }
            }
            condition += " AND State = 1 AND ApproveFlag = 1 AND Brand IN (SELECT ID FROM MCS_PUB.dbo.PDT_Brand WHERE IsOpponent=9)";

            if (tbx_ProductText.Text != "")
            {
                condition += " AND (FullName like '%" + tbx_ProductText.Text + "%' OR ShortName like '%" + tbx_ProductText.Text + "%' OR Code like '%" + tbx_ProductText.Text + "%')";
            }
            IList <PDT_Product> products = PDT_ProductBLL.GetModelList(condition);
            gv_NotInList.BindGrid <PDT_Product>(products);
        }

        cb_SelectAll.Checked = false;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 动态加入事件
        ddl_PartyCSignMan = (DropDownList)pl_detail.FindControl("CM_Contract_PartyCSignMan");
        ddl_PartyC = (DropDownList)pl_detail.FindControl("CM_Contract_PartyC");
        if (ddl_PartyC != null)
        {
            ddl_PartyC.AutoPostBack = true;
            ddl_PartyC.SelectedIndexChanged += new EventHandler(ddl_PartyC_SelectedIndexChanged);
        }

        ddl_RebateLevel = (DropDownList)pl_detail.FindControl("CM_Contract_RebateLevel");
        if (ddl_RebateLevel != null)
        {
            ddl_RebateLevel.AutoPostBack = true;
            ddl_RebateLevel.SelectedIndexChanged += new EventHandler(ddl_RebateLevel_SelectedIndexChanged);
        }
        tbx_EndDate = pl_detail.FindControl("CM_Contract_EndDate") != null ? (TextBox)pl_detail.FindControl("CM_Contract_EndDate") : null;
        tbx_BeginDate = pl_detail.FindControl("CM_Contract_BeginDate") != null ? (TextBox)pl_detail.FindControl("CM_Contract_BeginDate") : null;

        #endregion

        if (!Page.IsPostBack)
        {
            #region 获取页面参数
            ViewState["ContractID"] = Request.QueryString["ContractID"] == null ? 0 : int.Parse(Request.QueryString["ContractID"]);
            ViewState["Classify"] = Request.QueryString["Classify"] == null ? 0 : int.Parse(Request.QueryString["Classify"]);
            ViewState["ClientID"] = 0;
            if (Request.QueryString["ClientID"] != null)
            {
                ViewState["ClientID"] = Int32.Parse(Request.QueryString["ClientID"]);
                Session["ClientID"] = ViewState["ClientID"];
            }
            else if (Session["ClientID"] != null)
            {
                ViewState["ClientID"] = Int32.Parse(Session["ClientID"].ToString());
            }

            if ((int)ViewState["ContractID"] == 0 && (int)ViewState["ClientID"] == 0) Response.Redirect("~/SubModule/DeskTop.aspx");
            #endregion

            BindDropDown();

            #region 创建空的列表
            ListTable<CM_ContractDetail> _details = new ListTable<CM_ContractDetail>(new CM_ContractBLL((int)ViewState["ContractID"]).Items, "ID");
            ViewState["MAXID"] = _details.GetListItem().Count > 0 ? _details.GetListItem().Max(p => p.ID) : 0;
            ViewState["Details"] = _details;
            #endregion

            if ((int)ViewState["ContractID"] != 0)
            {
                BindData();
                DropDownList ddl_PromotorCostPayMode = (DropDownList)pl_detail.FindControl("CM_Contract_PromotorCostPayMode");
                if (ddl_PromotorCostPayMode != null)
                {
                    //月付的管理费,不需上协议
                    if (ddl_PromotorCostPayMode.Items.FindByValue("1") != null)
                        ddl_PromotorCostPayMode.Items.FindByValue("1").Enabled = false;

                    if (ddl_PromotorCostPayMode.Items.FindByValue("20") != null)
                        ddl_PromotorCostPayMode.Items.FindByValue("20").Enabled = false;
                }
            }
            else if ((int)ViewState["ClientID"] != 0)
            {
                Label l = (Label)pl_detail.FindControl("CM_Contract_Client");
                CM_Client m = new CM_ClientBLL((int)ViewState["ClientID"]).Model;
                if (l != null) l.Text = m.FullName.ToString();

                DropDownList ddl_Classify = (DropDownList)pl_detail.FindControl("CM_Contract_Classify");
                if (ddl_Classify != null) ddl_Classify.SelectedValue = ViewState["Classify"].ToString();
                BindContractClassify((int)ViewState["Classify"]);

                if (tbx_BeginDate != null && tbx_EndDate != null)
                {
                    tbx_BeginDate.Text = DateTime.Today.AddDays(1).ToString("yyyy-MM-dd");
                    tbx_EndDate.Text = DateTime.Today.AddYears(1).ToString("yyyy-MM-dd");

                    if (((int)ViewState["Classify"] == 2 || (int)ViewState["Classify"] == 3) && CM_ContractBLL.GetModelList("State=3 AND Classify=" + ViewState["Classify"].ToString() + " AND Client=" + ViewState["ClientID"].ToString()).Count > 0)
                    {
                        MessageBox.Show(this, "该协议同时只能有一条生效,请先中止生效的协议后再新增");
                    }
                    //判断是否门店关联离职导购

                }

                if (ddl_PartyCSignMan != null) ddl_PartyCSignMan.Items.Clear();

                bt_Submit.Visible = false;
                bt_Delete.Visible = false;
                bt_Approve.Visible = false;
                bt_Disable.Visible = false;
                bt_FeeApply.Visible = false;
                UploadFile1.Visible = false;
                bt_print.Visible = false;
                if ((int)ViewState["Classify"] != 1)
                {
                    tr_AddDetail.Visible = false;
                    tr_ContractDetail.Visible = false;
                }
            }

            Header.Attributes["WebPageSubCode"] = "Classify=" + ViewState["Classify"].ToString();
        }

        #region 注册弹出窗口脚本
        string script = "function PopSetEndDate(id){\r\n";
        script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("Pop_SetContractEndDate.aspx") +
            "?ContractID=' + id +'&tempid='+tempid, window, 'dialogWidth:500px;DialogHeight=260px;status:yes;resizable=yes');}";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Pop_SetContractEndDate", script, true);
        #endregion
    }
    private bool Save()
    {
        if (ViewState["Details"] == null)
        {
            return(false);
        }
        ListTable <PBM_DeliveryDetail> Details = (ListTable <PBM_DeliveryDetail>)ViewState["Details"];

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

        pl_detail.GetData(_bll.Model);

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

        if (_bll.Model.SupplierWareHouse == 0)
        {
            MessageBox.Show(this, "请正确选择盘点仓库!");
            return(false);
        }
        #endregion

        #region 循环设置盘点调整数量
        foreach (GridViewRow row in gv_List.Rows)
        {
            int _id = (int)gv_List.DataKeys[row.RowIndex]["ID"];
            PBM_DeliveryDetail d = Details[_id.ToString()];

            if (d == null)
            {
                continue;
            }
            int     quantity       = 0;
            TextBox tbx_Quantity_T = (TextBox)row.FindControl("tbx_Quantity_T");
            TextBox tbx_Quantity_P = (TextBox)row.FindControl("tbx_Quantity_P");

            if (tbx_Quantity_T != null)
            {
                int.TryParse(tbx_Quantity_T.Text, out quantity);
                d.DeliveryQuantity = quantity * d.ConvertFactor;
            }

            if (tbx_Quantity_P != null)
            {
                int.TryParse(tbx_Quantity_P.Text, out quantity);
                d.DeliveryQuantity += quantity;
            }

            DropDownList ddl_Mode = (DropDownList)row.FindControl("ddl_Mode");
            if (ddl_Mode != null && ddl_Mode.SelectedValue == "D")
            {
                int inv_quantity = 0;
                int.TryParse(d["PreInventoryQuantity"], out inv_quantity);
                if (inv_quantity < d.DeliveryQuantity)
                {
                    MessageBox.Show(this, "盘亏数量不能大于当前库存!");
                    return(false);
                }

                d.DeliveryQuantity = -1 * d.DeliveryQuantity;
                d.SignInQuantity   = d.DeliveryQuantity;
            }

            Details.Update(d);
        }
        #endregion

        _bll.Model.DiscountAmount = 0;
        _bll.Model.WipeAmount     = 0;

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

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

            #region 保存明细
            foreach (PBM_DeliveryDetail d in Details.GetListItem(ItemState.Modified))
            {
                _bll.UpdateDetail(d);
            }
            #endregion

            if (_bll.Update() == 0)
            {
                return(true);
            }
        }

        return(false);
    }
    protected void gv_List_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (ViewState["Details"] == null)
        {
            return;
        }
        ListTable <PBM_DeliveryDetail> Details = (ListTable <PBM_DeliveryDetail>)ViewState["Details"];

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int id = (int)gv_List.DataKeys[e.Row.RowIndex]["ID"];
            PBM_DeliveryDetail d = Details[id.ToString()];

            PDT_Product        product = new PDT_ProductBLL(d.Product, true).Model;
            PDT_ProductExtInfo extInfo = new PDT_ProductBLL(d.Product, true).GetProductExtInfo((int)Session["OwnerClient"]);

            if (product == null || extInfo == null)
            {
                return;
            }
            Dictionary <string, Dictionary_Data> dic = DictionaryBLL.GetDicCollections("PDT_Packaging");
            string _T = dic[product.TrafficPackaging.ToString()].Name;
            string _P = dic[product.Packaging.ToString()].Name;

            #region 显示产品分类价格包装信息
            Label lb_ProductCategory = (Label)e.Row.FindControl("lb_ProductCategory");
            if (lb_ProductCategory != null || extInfo.Category > 0)
            {
                lb_ProductCategory.Text = TreeTableBLL.GetFullPathName("MCS_PUB.dbo.PDT_Category", extInfo.Category);
            }

            Label lb_Price = (Label)e.Row.FindControl("lb_Price");
            if (lb_Price != null)
            {
                lb_Price.Text = (d.Price * product.ConvertFactor).ToString("0.##") + "元 / " + _T + "(" + product.ConvertFactor.ToString() + _P + ")";
            }
            #endregion

            #region 显示产品调整数量信息
            Label        lb_Quantity    = (Label)e.Row.FindControl("lb_Quantity");
            DropDownList ddl_Mode       = (DropDownList)e.Row.FindControl("ddl_Mode");
            TextBox      tbx_Quantity_T = (TextBox)e.Row.FindControl("tbx_Quantity_T");
            TextBox      tbx_Quantity_P = (TextBox)e.Row.FindControl("tbx_Quantity_P");
            Label        lb_P_T         = (Label)e.Row.FindControl("lb_P_T");
            Label        lb_P_P         = (Label)e.Row.FindControl("lb_P_P");
            if ((int)ViewState["State"] == 1)
            {
                lb_Quantity.Visible = false;

                if (ddl_Mode != null)
                {
                    ddl_Mode.SelectedValue = (d.DeliveryQuantity >= 0 ? "I" : "D");
                }
                if (tbx_Quantity_T != null)
                {
                    tbx_Quantity_T.Text = Math.Abs(d.DeliveryQuantity / product.ConvertFactor).ToString();
                }
                if (tbx_Quantity_P != null)
                {
                    tbx_Quantity_P.Text = Math.Abs(d.DeliveryQuantity % product.ConvertFactor).ToString();
                }
                if (lb_P_T != null)
                {
                    lb_P_T.Text = _T;
                }
                if (lb_P_P != null)
                {
                    lb_P_P.Text = _P;
                }
            }
            else
            {
                if (d.DeliveryQuantity != 0)
                {
                    lb_Quantity.ForeColor = d.DeliveryQuantity >= 0 ? System.Drawing.Color.Blue : System.Drawing.Color.Red;
                    lb_Quantity.Text      = d.DeliveryQuantity >= 0 ? "盘盈 " : "盘亏 ";

                    if (d.DeliveryQuantity / d.ConvertFactor != 0)
                    {
                        lb_Quantity.Text += (d.DeliveryQuantity / d.ConvertFactor).ToString() + _T;
                    }
                    if (d.DeliveryQuantity % d.ConvertFactor != 0)
                    {
                        lb_Quantity.Text += " " + (d.DeliveryQuantity % d.ConvertFactor).ToString() + _P;
                    }
                }
                ddl_Mode.Visible       = false;
                tbx_Quantity_T.Visible = false;
                tbx_Quantity_P.Visible = false;
                lb_P_T.Visible         = false;
                lb_P_P.Visible         = false;
            }
            #endregion

            #region 显示库存数量
            Label lb_InventoryQuantity = (Label)e.Row.FindControl("lb_InventoryQuantity");
            if (lb_InventoryQuantity != null)
            {
                int inv_quantity = 0;
                int.TryParse(d["PreInventoryQuantity"], out inv_quantity);

                if (inv_quantity / product.ConvertFactor != 0)
                {
                    lb_InventoryQuantity.Text = (inv_quantity / product.ConvertFactor).ToString() + _T;
                }
                if (inv_quantity % product.ConvertFactor != 0)
                {
                    lb_InventoryQuantity.Text += " " + (inv_quantity % product.ConvertFactor).ToString() + _P;
                }
            }
            #endregion
        }
        else if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[0].Text = "盈亏小计";
            e.Row.Cells[5].Text = Details.GetListItem().Sum(p => Math.Round(p.Price * p.ConvertFactor, 2) * p.DeliveryQuantity / p.ConvertFactor).ToString("<font color=red size='larger'>0.##元</font>");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            #region 判断传入参数是否为SheetCode
            if (Request.QueryString["SheetCode"] != null)
            {
                string code = Request.QueryString["SheetCode"];
                IList<FNA_FeeApply> list = FNA_FeeApplyBLL.GetModelList("SheetCode='" + code + "'");
                if (list.Count > 0)
                    Response.Redirect("FeeApplyDetail3.aspx?ID=" + list[0].ID.ToString());
                else
                    Response.Redirect("FeeApplyList.aspx");
            }
            #endregion

            #region 获取参数
            ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]);
            ViewState["OrganizeCity"] = Request.QueryString["OrganizeCity"] == null ? 0 : int.Parse(Request.QueryString["OrganizeCity"]);
            ViewState["FeeType"] = Request.QueryString["FeeType"] == null ? 0 : int.Parse(Request.QueryString["FeeType"]);
            ViewState["AccountTitle2"] = Request.QueryString["AccountTitle2"] == null ? 0 : int.Parse(Request.QueryString["AccountTitle2"]);
            ViewState["AccountMonth"] = Request.QueryString["AccountMonth"] == null ? 0 : int.Parse(Request.QueryString["AccountMonth"]);
            ViewState["ActivityID"] = Request.QueryString["ActivityID"] == null ? 0 : int.Parse(Request.QueryString["ActivityID"]);
            ViewState["Client"] = Request.QueryString["Client"] == null ? 0 : int.Parse(Request.QueryString["Client"]);
            ViewState["Brand"] = Request.QueryString["Brand"] == null ? 0 : int.Parse(Request.QueryString["Brand"]);
            ViewState["RelateCar"] = Request.QueryString["RelateCar"] == null ? 0 : int.Parse(Request.QueryString["RelateCar"]);
            ViewState["GiftFeeClassify"] = Request.QueryString["GiftFeeClassify"] == null ? 0 : int.Parse(Request.QueryString["GiftFeeClassify"]);
            ViewState["FromGeneralFlow"] = Request.QueryString["FromGeneralFlow"] == null ? "N" : Request.QueryString["FromGeneralFlow"];

            Session["FeeApplyDetail"] = null;
            Session["SuccessFlag"] = null;
            #endregion

            BindDropDown();

            #region 创建费用明细的列表
            ListTable<FNA_FeeApplyDetail> _details = new ListTable<FNA_FeeApplyDetail>(new FNA_FeeApplyBLL((int)ViewState["ID"]).Items, "ID");
            ViewState["Details"] = _details;

            int max = 0;
            if (_details.GetListItem().Count > 0) _details.GetListItem().Max(p => p.ID);
            ViewState["MaxID"] = max;
            #endregion

            if ((int)ViewState["ID"] == 0)
            {
                if ((int)ViewState["FeeType"] == 0 || (int)ViewState["OrganizeCity"] == 0)
                {
                    Response.Redirect("FeeApplyDetail0.aspx");
                    return;
                }
                ViewState["DicFeeType"] = DictionaryBLL.GetDicCollections("FNA_FeeType")[ViewState["FeeType"].ToString()];

                if ((int)ViewState["AccountMonth"] == 0)
                    ViewState["AccountMonth"] = AC_AccountMonthBLL.GetCurrentMonth();

                #region 新费用申请时,初始化申请信息
                Label lb_OrganizeCity = (Label)pn_FeeApply.FindControl("FNA_FeeApply_OrganizeCity");
                if (lb_OrganizeCity != null) lb_OrganizeCity.Text = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", (int)ViewState["OrganizeCity"]);

                Label lb_month = (Label)pn_FeeApply.FindControl("FNA_FeeApply_AccountMonth");
                if (lb_month != null) lb_month.Text = new AC_AccountMonthBLL((int)ViewState["AccountMonth"]).Model.Name;

                Label lb_FeeType = (Label)pn_FeeApply.FindControl("FNA_FeeApply_FeeType");
                if (lb_FeeType != null) lb_FeeType.Text = ((Dictionary_Data)ViewState["DicFeeType"]).Name;

                Label lb_staff = (Label)pn_FeeApply.FindControl("FNA_FeeApply_InsertStaff");
                if (lb_staff != null) lb_staff.Text = new Org_StaffBLL((int)Session["UserID"]).Model.RealName;

                Label lb_InsertTime = (Label)pn_FeeApply.FindControl("FNA_FeeApply_InsertTime");
                if (lb_InsertTime != null) lb_InsertTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm");

                TextBox tbx_Title = (TextBox)pn_FeeApply.FindControl("FNA_FeeApply_Title");
                if (tbx_Title != null && lb_FeeType != null)
                    tbx_Title.Text = lb_month.Text + " " + lb_FeeType.Text + "申请单" + Session["UserRealName"].ToString();

                if ((int)ViewState["AccountTitle2"] != 0)
                {
                    Label lb_AccountTitle2 = (Label)pn_FeeApply.FindControl("FNA_FeeApply_AccountTitle2");
                    if (lb_AccountTitle2 != null) lb_AccountTitle2.Text = new AC_AccountTitleBLL((int)ViewState["AccountTitle2"]).Model.Name;
                }

                DropDownList ddl_Brand = (DropDownList)pn_FeeApply.FindControl("FNA_FeeApply_ProductBrand");
                if (ddl_Brand != null) ddl_Brand.SelectedValue = ViewState["Brand"].ToString();

                if ((int)ViewState["RelateCar"] != 0)
                {
                    Label lb_RelateCar = (Label)pn_FeeApply.FindControl("FNA_FeeApply_RelateCar");
                    if (lb_RelateCar != null)
                    {
                        Car_CarList car = new Car_CarListBLL((int)ViewState["RelateCar"]).Model;
                        if (car != null)
                            lb_RelateCar.Text = car.CarNo;
                        else
                            ViewState["RelateCar"] = 0;
                    }
                }
                #endregion

                if (((Dictionary_Data)ViewState["DicFeeType"]).Description == "BudgetControl")
                    BindBudgetInfo();
                else if (((Dictionary_Data)ViewState["DicFeeType"]).Description == "FeeRateControl")
                    BindFeeRateInfo();
                UploadFile1.Visible = false;
                bt_Submit.Visible = false;
                bt_ViewReport.Visible = false;
                bt_Print.Visible = false;
                bt_Copy.Visible = false;
                bt_ViewWriteOff.Visible = false;
                bt_Cancel.Visible = false;
                tbl_Remark.Visible = true;
            }
            else
            {
                BindData();
            }
            bt_AddDetail.OnClientClick =
                string.Format("PopAddFeeDetail({0},{1},{2},{3},{4},{5});",
                    ViewState["FeeType"].ToString(),
                    ViewState["OrganizeCity"].ToString(),
                    ViewState["AccountMonth"].ToString(),
                    ViewState["AccountTitle2"].ToString(),
                    ViewState["Brand"].ToString(),
                    ViewState["RelateCar"].ToString()
                    );
        }

        #region 注册弹出窗口脚本
        string script = "function PopAddFeeDetail(feetype,organizecity,month,accounttitle2,brand,car){\r\n";
        script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("Pop_AddFeeApplyDetailItem.aspx") +
            "?FeeType=' + feetype + '&OrganizeCity=' + organizecity + '&AccountMonth=' + month + '&AccountTitle2=' + accounttitle2 + '&Client=" +
            ViewState["Client"].ToString() + "&Brand=' + brand + '&RelateCar=' + car + '&FromGeneralFlow=" + ViewState["FromGeneralFlow"].ToString()
            + "&tempid='+tempid, window, 'dialogWidth:800px;DialogHeight=600px;status:yes;resizable=yes');}";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopAddFeeDetail", script, true);

        script = "function PopReport(id){\r\n";
        script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("~/SubModule/ReportViewer/PubReportViewerFeeApp.aspx?ViewFramework=false&ReportPath=/MCS_FNA_Report/Report_FNA_ClientInfoByAppID_001&FeeAppID=' + id ") +
            ", window, 'dialogWidth:800px;DialogHeight=600px;status:yes;resizable=yes');}";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopReport", script, true);

        script = "function PopWriteOffListByDetailID(detailid){\r\n";
        script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("../FeeWriteoff/Pop_FeeWriteOffListByFeeApply.aspx?tempid='+tempid+'&FeeApplyDetailID=' + detailid ") +
            ", window, 'dialogWidth:800px;DialogHeight=600px;status:yes;resizable=yes');}";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopWriteOffListByDetailID", script, true);

        script = "function PopWriteOffListByApplyID(applyid){\r\n";
        script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("../FeeWriteoff/Pop_FeeWriteOffListByFeeApply.aspx?tempid='+tempid+'&FeeApplyID=' + applyid ") +
            ", window, 'dialogWidth:800px;DialogHeight=600px;status:yes;resizable=yes');}";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopWriteOffListByApplyID", script, true);

        script = "function PopAdjust(id){\r\n";
        script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("Pop_AdjustApplyDetail.aspx") +
            "?ID=' + id + '&tempid='+tempid, window, 'dialogWidth:500px;DialogHeight=600px;status:yes;resizable=yes');}";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopAdjust", script, true);

        script = "function PopClientFNAInfo(clientid){\r\n";
        script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("../FeeApplyOrWriteoffByClientList.aspx") +
            "?ClientID=' + clientid + '&tempid='+tempid, window, 'dialogWidth:900px;DialogHeight=600px;status:yes;resizable=yes');}";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopClientFNAInfo", script, true);
        #endregion
    }