protected void bt_Add_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["PriceID"] > 0)
        {
            if (tr_OrganizeCity.SelectValue != "0" && tr_OrganizeCity.SelectValue != tr_OrganizeCity.RootValue)
            {
                PDT_StandardPriceBLL bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

                Addr_OrganizeCityBLL selectedcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue));
                string[] allparent = selectedcity.GetAllSuperNodeIDs().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (PDT_StandardPrice_ApplyCity city in bll.ApplyCityItems)
                {
                    if (selectedcity.Model.ID == city.OrganizeCity)
                    {
                        MessageBox.Show(this, "对不起,该区域已在适用区域内,请勿重复添加!");
                        return;
                    }

                    if (allparent.Contains(city.OrganizeCity.ToString()))
                    {
                        MessageBox.Show(this, "对不起,要新增的区域的上级【" + TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", city.OrganizeCity) + "】已在适用区域内!");
                        return;
                    }
                }

                PDT_StandardPrice_ApplyCity c = new PDT_StandardPrice_ApplyCity();
                c.OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue);
                bll.AddApplyCity(c);

                BindCheckBoxList();
            }
        }
    }
    protected void btn_Apply_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["PriceID"] == 0)
        {
            MessageBox.Show(this, "对不起,请您先保存后在发起申请");
            return;
        }

        PDT_StandardPriceBLL bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);
        if (bll.GetApplyCityDetail().Count == 0)
        {
            MessageBox.Show(this, "请点击【适用区域】按钮,选择该标准价表适用于的区域!");
            return;
        }

        bt_CompareStdPrice_Click(null, null);

        NameValueCollection dataobjects = new NameValueCollection();
        dataobjects.Add("ID", bll.Model.ID.ToString());
        dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
        dataobjects.Add("FullName", bll.Model.FullName);
        dataobjects.Add("MaxRate", ((decimal)ViewState["MaxRate"] * 100).ToString());

        int TaskID = EWF_TaskBLL.NewTask("PDT_StandardPrice_Apply", (int)Session["UserID"], "标准价表名称:" + bll.Model.FullName, "~/SubModule/Product/PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString(), dataobjects);
        if (TaskID > 0)
        {
            bll.Model.TaskID = TaskID;
            bll.Update();
            new EWF_TaskBLL(TaskID).Start();        //直接启动流程
        }
        Response.Redirect("~/SubModule/EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString());
    }
    protected void bt_In_Click(object sender, EventArgs e)
    {
        Save();

        foreach (GridViewRow row in gv_NotInList.Rows)
        {
            CheckBox cb_check = (CheckBox)row.FindControl("cb_Check");
            if (cb_check.Checked)
            {
                PDT_StandardPriceBLL _bll;
                if ((int)ViewState["ID"] != 0)
                    _bll = new PDT_StandardPriceBLL((int)ViewState["ID"]);
                else
                    return;

                PDT_StandardPrice_Detail pd = new PDT_StandardPrice_Detail();
                pd.Product = int.Parse(gv_NotInList.DataKeys[row.RowIndex]["ID"].ToString());

                PDT_ProductBLL productbll = new PDT_ProductBLL(pd.Product);
                PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo((int)Session["OwnerClient"]);
                if (extinfo != null)
                    pd.Price = extinfo.SalesPrice;
                else
                    pd.Price = productbll.Model.StdPrice;
                _bll.AddDetail(pd);
            }
        }
        Response.Redirect("StandardPriceDetail.aspx?ID=" + ViewState["ID"].ToString());
    }
    protected void bt_Out_Click(object sender, EventArgs e)
    {
        Save();
        if ((int)ViewState["PriceID"] == 0)
        {
            return;
        }

        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        foreach (GridViewRow row in gv_List.Rows)
        {
            CheckBox cb_check = (CheckBox)row.FindControl("cb_Check");
            if (cb_check.Checked)
            {
                PDT_StandardPrice_Detail       item2   = _bll.GetDetailModel(int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString()));
                PDT_StandPriceChangeHistoryBLL history = new PDT_StandPriceChangeHistoryBLL();
                history.Model.StandardPrice    = _bll.Model.ID;
                history.Model.ChangeType       = 3;
                history.Model.ChageTime        = DateTime.Now;
                history.Model.ChangeStaff      = (int)Session["UserID"];
                history.Model.Product          = item2.Product;
                history.Model.PreFactoryPrice  = item2.FactoryPrice;
                history.Model.PreTradeOutPrice = item2.TradeOutPrice;
                history.Model.PreTradeInPrice  = item2.TradeInPrice;
                history.Model.PreStdPrice      = item2.StdPrice;
                history.Add();
                _bll.DeleteDetail(int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString()));
            }
        }
        Response.Redirect("PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString());
    }
        private void FillModel(int PriceID)
        {
            PDT_StandardPriceBLL bll = new PDT_StandardPriceBLL(PriceID);
            if (bll.Model == null) return;

            ID = PriceID;
            Name = bll.Model.Name;
            FitSalesArea = bll.Model.FitSalesArea;
            FitRTChannel = bll.Model.FitRTChannel;
            Remark = bll.Model.Remark;

            #region 获取价表明细
            Items = new List<TDPStandardPriceDetail>(bll.Items.Count);
            foreach (PDT_StandardPrice_Detail item in bll.Items)
            {
                Items.Add(new TDPStandardPriceDetail(item));
            }
            #endregion

            #region 获取渠道名称
            if (FitRTChannel > 0)
            {
                CM_RTChannel_TDP channel = new CM_RTChannel_TDPBLL(FitRTChannel).Model;
                if (channel != null) FitRTChannelName = channel.Name;
            }
            #endregion

            #region 获取区域名称
            if (FitSalesArea > 0)
            {
                CM_RTSalesArea_TDP area = new CM_RTSalesArea_TDPBLL(FitSalesArea).Model;
                if (area != null) FitSalesAreaName = area.Name;
            }
            #endregion
        }
    protected void bt_In_Click(object sender, EventArgs e)
    {
        Save();

        CM_Client client = new CM_ClientBLL((int)ViewState["ClientID"]).Model;
        if (client == null) return;

        PDT_StandardPriceBLL standardprice = new PDT_StandardPriceBLL((int)ViewState["StandardPrice"]);

        foreach (GridViewRow row in gv_List_FacProd.Rows)
        {
            CheckBox cb_check = (CheckBox)row.FindControl("cb_Check");
            if (cb_check.Checked)
            {
                PDT_ProductPriceBLL _bll;
                if ((int)ViewState["PriceID"] != 0)
                    _bll = new PDT_ProductPriceBLL((int)ViewState["PriceID"]);
                else
                    return;

                PDT_ProductPrice_Detail pd = new PDT_ProductPrice_Detail();
                pd.PriceID = (int)ViewState["PriceID"];
                pd.Product = int.Parse(gv_List_FacProd.DataKeys[row.RowIndex]["ID"].ToString());

                #region 将标准价表中的价格设置到价表中
                if ((int)ViewState["StandardPrice"] > 0)
                {
                    PDT_StandardPrice_Detail d = standardprice.Items.FirstOrDefault(p => p.Product == pd.Product);
                    if (d != null)
                    {
                        pd.FactoryPrice = d.FactoryPrice;

                        if (client.ClientType == 3)      //门店
                        {
                            pd.BuyingPrice = d.TradeInPrice;
                            pd.SalesPrice = d.StdPrice;
                        }
                        else if (client.ClientType == 2)
                        {
                            if (client["DIClassify"] == "1")    //一级经销商
                            {
                                pd.BuyingPrice = d.FactoryPrice;
                                pd.SalesPrice = d.TradeInPrice;
                            }
                            else if (client["DIClassify"] == "2")     //分销商
                            {
                                pd.BuyingPrice = d.TradeOutPrice;
                                pd.SalesPrice = d.TradeInPrice;
                            }
                        }
                    }
                }
                #endregion

                _bll.AddDetail(pd);
            }
        }
        Response.Redirect("PDT_ProductPriceDetail2.aspx?PriceID=" + ViewState["PriceID"].ToString());
    }
    private void BindData()
    {
        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);
        panel1.BindData(_bll.Model);
        panel1.SetControlsEnable(false);

        BindGrid();
    }
    private void BindData()
    {
        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        panel1.BindData(_bll.Model);
        panel1.SetControlsEnable(false);

        BindGrid();
    }
    private void BindGrid()
    {
        string condition = " 1 = 1 ";

        condition += " ORDER BY PDT_Product.Code";

        PDT_StandardPriceBLL bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        gv_List.BindGrid(bll.GetDetail(condition));
    }
Esempio n. 10
0
    protected void select_Client_SelectChange(object sender, MCSControls.MCSWebControls.SelectChangeEventArgs e)
    {
        tr_OrganizeCity.SelectValue = new CM_ClientBLL(int.Parse(select_Client.SelectValue)).Model.OrganizeCity.ToString();
        Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue));

        ddl_StandardPrice.DataSource = PDT_StandardPriceBLL.GetModelList("ActiveFlag=1 AND ApproveFlag=1 AND ID IN (SELECT StandardPrice FROM PDT_StandardPrice_ApplyCity WHERE OrganizeCity IN (" + orgcity.GetAllSuperNodeIDs() + "," + tr_OrganizeCity.SelectValue + ")) ");
        ddl_StandardPrice.DataBind();
        ddl_StandardPrice.Items.Insert(0, new ListItem("请选择....", "0"));
        ddl_StandardPrice.SelectedValue = "0";
    }
    protected void btn_UnActive_Click(object sender, EventArgs e)
    {
        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        if (_bll.Model.ActiveFlag == 1)
        {
            _bll.UnActive((int)Session["UserID"]);
            MessageBox.ShowAndRedirect(this, "标准价表停用成功!", "PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString());
        }
    }
    protected void btn_UnApprove_Click(object sender, EventArgs e)
    {
        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        _bll.Model.ActiveFlag  = 1;
        _bll.Model.ApproveFlag = 2;
        _bll.Model.TaskID      = 0;
        _bll.Model.UpdateStaff = (int)Session["UserID"];
        _bll.Update();
        MessageBox.ShowAndRedirect(this, "取消审核成功!", "PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString());
    }
    protected void btn_Approve_Click(object sender, EventArgs e)
    {
        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);
        if (_bll.GetApplyCityDetail().Count == 0 && _bll.Model["IsRebatePrice"] != "1")
        {
            MessageBox.Show(this, "请点击【适用区域】按钮,选择该标准价表适用于的区域!");
            return;
        }

        _bll.Approve((int)Session["UserID"]);
        MessageBox.ShowAndRedirect(this, "审核成功!", "PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString());
    }
    protected void btn_Approve_Click(object sender, EventArgs e)
    {
        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        if (_bll.GetApplyCityDetail().Count == 0 && _bll.Model["IsRebatePrice"] != "1")
        {
            MessageBox.Show(this, "请点击【适用区域】按钮,选择该标准价表适用于的区域!");
            return;
        }

        _bll.Approve((int)Session["UserID"]);
        MessageBox.ShowAndRedirect(this, "审核成功!", "PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString());
    }
Esempio n. 15
0
    protected void select_Product_SelectChange(object sender, MCSControls.MCSWebControls.SelectChangeEventArgs e)
    {
        int product = 0;

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

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


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

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

            foreach (ListItem item in cbl_ApplyCity.Items)
            {
                if (item.Selected)
                {
                    bll.DeleteApplyCity(int.Parse(item.Value));
                }
            }

            BindCheckBoxList();
        }
    }
    protected void bt_In_Click(object sender, EventArgs e)
    {
        Save();
        if ((int)ViewState["PriceID"] == 0)
        {
            return;
        }

        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        foreach (GridViewRow row in gv_List_FacProd.Rows)
        {
            CheckBox cb_check = (CheckBox)row.FindControl("cb_Check");
            if (cb_check.Checked)
            {
                PDT_Product product = new PDT_ProductBLL((int)gv_List_FacProd.DataKeys[row.RowIndex]["ID"]).Model;
                if (product != null)
                {
                    PDT_StandardPrice_Detail detail = new PDT_StandardPrice_Detail();
                    detail.StandardPrice = (int)ViewState["PriceID"];
                    detail.Product       = product.ID;
                    detail.FactoryPrice  = product.FactoryPrice;
                    detail.TradeOutPrice = product.TradePrice;
                    detail.TradeInPrice  = product.NetPrice;
                    detail.StdPrice      = product.StdPrice;
                    PDT_StandPriceChangeHistoryBLL history = new PDT_StandPriceChangeHistoryBLL();
                    history.Model.StandardPrice    = _bll.Model.ID;
                    history.Model.ChangeType       = 1;
                    history.Model.ChageTime        = DateTime.Now;
                    history.Model.ChangeStaff      = (int)Session["UserID"];
                    history.Model.Product          = detail.Product;
                    history.Model.AftFactoryPrice  = detail.FactoryPrice;
                    history.Model.AftTradeOutPrice = detail.TradeOutPrice;
                    history.Model.AftTradeInPrice  = detail.TradeInPrice;
                    history.Model.AftStdPrice      = detail.StdPrice;
                    history.Add();

                    _bll.AddDetail(detail);
                }
            }
        }

        Response.Redirect("PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString());
    }
    private void BindGrid()
    {
        int category = 0;
        int.TryParse(tr_Category.SelectValue, out category);

        if (MCSTabControl1.SelectedIndex == 0)
        {

            string condition = " 1 = 1 ";

            #region 获取产品分类
            if (category > 1)
            {
                condition += " AND PDT_StandardPrice_Detail.Product IN (SELECT Product FROM MCS_PUB.dbo.PDT_ProductExtInfo WHERE Supplier=" + Session["OwnerClient"].ToString();
                string _categoryids = "";
                DataTable dt = TreeTableBLL.GetAllChildByNodes("MCS_Pub.dbo.PDT_Category", "ID", "SuperID", tr_Category.SelectValue);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    _categoryids += dt.Rows[i]["ID"].ToString() + ",";
                }
                _categoryids += tr_Category.SelectValue;

                condition += " AND PDT_ProductExtInfo.Category IN (" + _categoryids + ")";

                condition += ")";
            }
            #endregion

            if (tbx_ProductText.Text != "")
            {
                condition += "AND PDT_StandardPrice_Detail.Product IN (SELECT ID FROM MCS_PUB.dbo.PDT_Product WHERE ";
                condition += " (FullName like '%" + tbx_ProductText.Text + "%' OR ShortName like '%" + tbx_ProductText.Text + "%' OR FactoryCode like '%" + tbx_ProductText.Text +
                    "%' OR PDT_Product.ID IN (SELECT Product FROM MCS_PUB.dbo.PDT_ProductExtInfo WHERE Supplier=" + Session["OwnerClient"].ToString() + " AND PDT_ProductExtInfo.Code LIKE '%" + tbx_ProductText.Text + "%'))";
                condition += ")";
            }

            IList<PDT_StandardPrice_Detail> list = new PDT_StandardPriceBLL((int)ViewState["ID"]).GetDetail(condition);
            gv_List.BindGrid<PDT_StandardPrice_Detail>(list);
        }
        else
        {
            //获取非价表产品列表
            string condition = "PDT_Product.ID NOT IN (SELECT Product FROM MCS_PUB.dbo.PDT_StandardPrice_Detail WHERE PriceID=" + ViewState["ID"].ToString() + ")";
            condition += " AND State = 1 AND ApproveFlag = 1";
            condition += " AND PDT_Product.ID IN (SELECT Product FROM MCS_PUB.dbo.PDT_ProductExtInfo WHERE Supplier=" + Session["OwnerClient"].ToString();

            #region 获取产品分类
            if (category > 1)
            {
                string _categoryids = "";
                DataTable dt = TreeTableBLL.GetAllChildByNodes("MCS_Pub.dbo.PDT_Category", "ID", "SuperID", tr_Category.SelectValue);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    _categoryids += dt.Rows[i]["ID"].ToString() + ",";
                }
                _categoryids += tr_Category.SelectValue;

                condition += " AND PDT_ProductExtInfo.Category IN (" + _categoryids + ")";
            }
            #endregion

            condition += ")";

            if (tbx_ProductText.Text != "")
                condition += " AND (FullName like '%" + tbx_ProductText.Text + "%' OR ShortName like '%" + tbx_ProductText.Text + "%' OR Code like '%" + tbx_ProductText.Text +
                    "%' OR PDT_Product.ID IN (SELECT Product FROM MCS_PUB.dbo.PDT_ProductExtInfo WHERE Supplier=" + Session["OwnerClient"].ToString() + " AND PDT_ProductExtInfo.Code LIKE '%" + tbx_ProductText.Text + "%'))";

            IList<PDT_Product> products = PDT_ProductBLL.GetModelList(condition);

            gv_NotInList.BindGrid<PDT_Product>(products);
        }

        cb_SelectAll.Checked = false;
    }
Esempio n. 19
0
        private void FillModel(int OrderID)
        {
            PBM_OrderBLL bll = new PBM_OrderBLL(OrderID);

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

            PBM_Order m = bll.Model;

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

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

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

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

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

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

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

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

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

        panel1.GetData(_bll.Model);

        if (_bll.Model.OrganizeCity == 0)
        {
            MessageBox.Show(this, "适用管理片区必填!");
            return;
        }

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

            #region 修改明细
            foreach (GridViewRow row in gv_List.Rows)
            {
                PDT_StandardPrice_Detail item1 = new PDT_StandardPrice_Detail();
                item1.ID            = int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString());
                item1.StandardPrice = _bll.Model.ID;
                item1.Product       = int.Parse(gv_List.DataKeys[row.RowIndex]["Product"].ToString());
                item1.FactoryPrice  = decimal.Parse(((TextBox)row.FindControl("tbx_FactoryPrice")).Text);
                item1.TradeOutPrice = decimal.Parse(((TextBox)row.FindControl("tbx_TradeOutPrice")).Text);
                item1.TradeInPrice  = decimal.Parse(((TextBox)row.FindControl("tbx_TradeInPrice")).Text);
                item1.StdPrice      = decimal.Parse(((TextBox)row.FindControl("tbx_StdPrice")).Text);
                TextBox tbx_RebatePrice = row.FindControl("tbx_RebatePrice") == null ? null : (TextBox)row.FindControl("tbx_RebatePrice");
                if (tbx_RebatePrice != null)
                {
                    decimal rebateprice = 0;
                    decimal.TryParse(tbx_RebatePrice.Text, out rebateprice);
                    item1.RebatePrice = rebateprice;
                }
                TextBox tbx_DIRebatePrice = row.FindControl("tbx_DIRebatePrice") == null ? null : (TextBox)row.FindControl("tbx_DIRebatePrice");
                if (tbx_DIRebatePrice != null)
                {
                    decimal direbateprice = 0;
                    decimal.TryParse(tbx_DIRebatePrice.Text, out direbateprice);
                    item1.DIRebatePrice = direbateprice;
                }
                CheckBox cbx_ISFL = row.FindControl("cbx_ISFL") == null ? null : (CheckBox)row.FindControl("cbx_ISFL");
                if (cbx_ISFL != null)
                {
                    item1.ISFL = cbx_ISFL.Checked ? 1 : 2;
                }
                CheckBox cbx_ISJH = row.FindControl("cbx_ISJH") == null ? null : (CheckBox)row.FindControl("cbx_ISJH");
                if (cbx_ISJH != null)
                {
                    item1.ISJH = cbx_ISJH.Checked ? 1 : 2;
                }

                CheckBox cbx_ISCheckJF = row.FindControl("cbx_ISCheckJF") == null ? null : (CheckBox)row.FindControl("cbx_ISCheckJF");
                if (cbx_ISCheckJF != null)
                {
                    item1.ISCheckJF = cbx_ISCheckJF.Checked ? 1 : 2;
                }
                PDT_StandardPrice_Detail item2 = _bll.GetDetailModel(item1.ID);
                if (item1.FactoryPrice != item2.FactoryPrice || item1.TradeInPrice != item2.TradeInPrice || item1.TradeOutPrice != item2.TradeOutPrice || item1.StdPrice != item2.StdPrice)
                {
                    PDT_StandPriceChangeHistoryBLL history = new PDT_StandPriceChangeHistoryBLL();
                    history.Model.StandardPrice    = _bll.Model.ID;
                    history.Model.ChangeType       = 2;
                    history.Model.ChageTime        = DateTime.Now;
                    history.Model.ChangeStaff      = (int)Session["UserID"];
                    history.Model.Product          = item1.Product;
                    history.Model.PreFactoryPrice  = item2.FactoryPrice;
                    history.Model.PreTradeOutPrice = item2.TradeOutPrice;
                    history.Model.PreTradeInPrice  = item2.TradeInPrice;
                    history.Model.PreStdPrice      = item2.StdPrice;
                    history.Model.AftFactoryPrice  = item1.FactoryPrice;
                    history.Model.AftTradeInPrice  = item1.TradeInPrice;
                    history.Model.AftTradeOutPrice = item1.TradeOutPrice;
                    history.Model.AftStdPrice      = item1.StdPrice;
                    history.Add();
                }
                _bll.UpdateDetail(item1);
            }
            #endregion
        }
        else
        {
            _bll.Model.ApproveFlag = 2;
            _bll.Model.ActiveFlag  = 2;
            _bll.Model.InsertStaff = int.Parse(Session["UserID"].ToString());
            _bll.Add();
            ViewState["PriceID"] = _bll.Model.ID;
        }
    }
    private bool Save()
    {
        PDT_StandardPriceBLL _bll;
        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll = new PDT_StandardPriceBLL((int)ViewState["ID"]);
        }
        else
        {
            //新增
            _bll = new PDT_StandardPriceBLL();
        }

        pl_detail.GetData(_bll.Model);

        #region 判断必填项

        #endregion

        #region 判断是否与默认价表重复
        if (_bll.Model.IsDefault.ToUpper() == "Y")
        {
            int _priceid = PDT_StandardPriceBLL.GetDefaultPrice((int)Session["OwnerClient"]);
            if (_priceid != _bll.Model.ID)
            {
                MessageBox.Show(this, "对不起,不能重复新增默认价表,新增的价表必须限制区域或渠道!");
                return false;
            }
        }

        #endregion

        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            _bll.Update();
        }
        else
        {
            //新增
            _bll.Model.Supplier = (int)Session["OwnerClient"];
            _bll.Model.ApproveFlag = 2;
            _bll.Model.InsertStaff = (int)Session["UserID"];
            ViewState["ID"] = _bll.Add();
        }

        #region 保存修改明细
        foreach (GridViewRow row in gv_List.Rows)
        {
            PDT_StandardPrice_Detail item = new PDT_StandardPrice_Detail();
            item.PriceID = _bll.Model.ID;
            item.ID = int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString());
            item.Product = int.Parse(gv_List.DataKeys[row.RowIndex]["Product"].ToString());

            PDT_Product p = new PDT_ProductBLL(item.Product).Model;

            if (row.FindControl("tbx_Price") != null)
            {
                decimal d = 0;
                if (decimal.TryParse(((TextBox)row.FindControl("tbx_Price")).Text, out d)) item.Price = d;

                PDT_ProductBLL productbll = new PDT_ProductBLL(item.Product);
                item.Price = item.Price / productbll.Model.ConvertFactor;

                PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo((int)Session["OwnerClient"]);
                if (extinfo != null)
                {
                    if (extinfo.MinSalesPrice > 0 && item.Price < extinfo.MinSalesPrice)
                    {
                        MessageBox.Show(this, "对不起,您发布的价格不能小于建议零售价!");
                        return false;
                    }
                    else if (extinfo.MaxSalesPrice > 0 && item.Price > extinfo.MaxSalesPrice)
                    {
                        MessageBox.Show(this, "对不起,您发布的价格不能过高于建议零售价!");
                        return false;
                    }
                }
            }

            if (row.FindControl("tbx_Remark") != null)
                item.Remark = ((TextBox)row.FindControl("tbx_Remark")).Text;

            _bll.UpdateDetail(item);
        }

        #endregion

        return true;
    }
Esempio n. 22
0
        private void FillModel(int OrderID)
        {
            PBM_OrderBLL bll = new PBM_OrderBLL(OrderID);
            if (bll.Model == null) { ID = -1; return; }

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

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

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

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

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

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

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

                if (OrderSource > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_OrderSource")[OrderSource.ToString()];
                    if (dic != null) OrderSourceName = dic.Name;
                }
            }
            catch (System.Exception err)
            {
                LogWriter.WriteLog("MCSFramework.WSI.Order", err);
            }
            #endregion
        }
    private void BindGrid()
    {
        if (MCSTabControl1.SelectedIndex == 0)
        {
            tr1.Visible        = false;
            tr_Product.Visible = true;

            string condition = " 1 = 1 ";

            if (ddl_Brand.SelectedValue != "0")
            {
                if (ddl_Classify.SelectedValue == "0")
                {
                    condition = " Brand =" + ddl_Brand.SelectedValue;
                }
                else
                {
                    condition = " Classify =" + ddl_Classify.SelectedValue;
                }
            }

            condition += " ORDER BY PDT_Product.Code";

            PDT_StandardPriceBLL bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);
            gv_List.BindGrid(bll.GetDetail(condition));

            if (!Right_Assign_BLL.GetAccessRight((string)Session["UserName"], 1410, "ModifyFactoryPrice"))
            {
                foreach (GridViewRow row in gv_List.Rows)
                {
                    TextBox tbx = (TextBox)row.FindControl("tbx_FactoryPrice");
                    if (tbx != null)
                    {
                        tbx.Enabled = false;
                    }
                }
            }
        }
        else
        {
            tr1.Visible        = true;
            tr_Product.Visible = false;

            //获取非价表产品列表
            string condition = "State=1 AND ID NOT IN (SELECT Product FROM PDT_StandardPrice_Detail WHERE StandardPrice=" + ViewState["PriceID"].ToString() + ")";

            if (ddl_Brand.SelectedValue == "0")
            {
                condition += " AND Brand in (SELECT ID FROM PDT_Brand WHERE IsOpponent in ('1'))";
            }
            else
            {
                if (ddl_Classify.SelectedValue == "0")
                {
                    condition += " AND Brand =" + ddl_Brand.SelectedValue;
                }
                else
                {
                    condition += " AND Classify =" + ddl_Classify.SelectedValue;
                }
            }

            IList <PDT_Product> products = PDT_ProductBLL.GetModelList(condition);

            gv_List_FacProd.BindGrid <PDT_Product>(products);
        }
    }
    protected void btn_UnActive_Click(object sender, EventArgs e)
    {
        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        if (_bll.Model.ActiveFlag == 1)
        {
            _bll.UnActive((int)Session["UserID"]);
            MessageBox.ShowAndRedirect(this, "标准价表停用成功!", "PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString());
        }
    }
    protected void btn_PublishProduct_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["PriceID"] == 0) return;

        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        foreach (GridViewRow row in gv_List.Rows)
        {
            CheckBox cb_check = (CheckBox)row.FindControl("cb_Check");
            if (cb_check.Checked)
            {
                _bll.PublishProduct(int.Parse(gv_List.DataKeys[row.RowIndex]["Product"].ToString()));
            }
        }

        MessageBox.ShowAndRedirect(this, "产品发布成功!", "PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString());
    }
    private void BindGrid()
    {
        if (MCSTabControl1.SelectedIndex == 0)
        {
            tr1.Visible = false;
            tr_Product.Visible = true;

            string condition = " 1 = 1 ";

            if (ddl_Brand.SelectedValue != "0")
            {
                if (ddl_Classify.SelectedValue == "0")
                    condition = " Brand =" + ddl_Brand.SelectedValue;
                else
                    condition = " Classify =" + ddl_Classify.SelectedValue;
            }

            condition += " ORDER BY PDT_Product.Code";

            PDT_StandardPriceBLL bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);
            gv_List.BindGrid(bll.GetDetail(condition));

            if (!Right_Assign_BLL.GetAccessRight((string)Session["UserName"], 1410, "ModifyFactoryPrice"))
            {
                foreach (GridViewRow row in gv_List.Rows)
                {
                    TextBox tbx = (TextBox)row.FindControl("tbx_FactoryPrice");
                    if (tbx != null) tbx.Enabled = false;
                }
            }
        }
        else
        {
            tr1.Visible = true;
            tr_Product.Visible = false;

            //获取非价表产品列表
            string condition = "State=1 AND ID NOT IN (SELECT Product FROM PDT_StandardPrice_Detail WHERE StandardPrice=" + ViewState["PriceID"].ToString() + ")";

            if (ddl_Brand.SelectedValue == "0")
                condition += " AND Brand in (SELECT ID FROM PDT_Brand WHERE IsOpponent in ('1'))";
            else
            {
                if (ddl_Classify.SelectedValue == "0")
                    condition += " AND Brand =" + ddl_Brand.SelectedValue;
                else
                    condition += " AND Classify =" + ddl_Classify.SelectedValue;
            }

            IList<PDT_Product> products = PDT_ProductBLL.GetModelList(condition);

            gv_List_FacProd.BindGrid<PDT_Product>(products);
        }
    }
    private void Save()
    {
        PDT_StandardPriceBLL _bll;
        if ((int)ViewState["PriceID"] != 0)
            _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);
        else
            _bll = new PDT_StandardPriceBLL();

        panel1.GetData(_bll.Model);

        if (_bll.Model.OrganizeCity == 0)
        {
            MessageBox.Show(this, "适用管理片区必填!");
            return;
        }

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

            #region 修改明细
            foreach (GridViewRow row in gv_List.Rows)
            {
                PDT_StandardPrice_Detail item1 = new PDT_StandardPrice_Detail();
                item1.ID = int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString());
                item1.StandardPrice = _bll.Model.ID;
                item1.Product = int.Parse(gv_List.DataKeys[row.RowIndex]["Product"].ToString());
                item1.FactoryPrice = decimal.Parse(((TextBox)row.FindControl("tbx_FactoryPrice")).Text);
                item1.TradeOutPrice = decimal.Parse(((TextBox)row.FindControl("tbx_TradeOutPrice")).Text);
                item1.TradeInPrice = decimal.Parse(((TextBox)row.FindControl("tbx_TradeInPrice")).Text);
                item1.StdPrice = decimal.Parse(((TextBox)row.FindControl("tbx_StdPrice")).Text);
                TextBox tbx_RebatePrice = row.FindControl("tbx_RebatePrice") == null ? null : (TextBox)row.FindControl("tbx_RebatePrice");
                if (tbx_RebatePrice != null)
                {
                    decimal rebateprice = 0;
                    decimal.TryParse(tbx_RebatePrice.Text, out rebateprice);
                    item1.RebatePrice = rebateprice;
                }
                TextBox tbx_DIRebatePrice = row.FindControl("tbx_DIRebatePrice") == null ? null : (TextBox)row.FindControl("tbx_DIRebatePrice");
                if (tbx_DIRebatePrice != null)
                {
                    decimal direbateprice = 0;
                    decimal.TryParse(tbx_DIRebatePrice.Text, out direbateprice);
                    item1.DIRebatePrice = direbateprice;
                }
                CheckBox cbx_ISFL = row.FindControl("cbx_ISFL") == null ? null : (CheckBox)row.FindControl("cbx_ISFL");
                if (cbx_ISFL != null)
                {
                    item1.ISFL = cbx_ISFL.Checked ? 1 : 2;
                }
                CheckBox cbx_ISJH = row.FindControl("cbx_ISJH") == null ? null : (CheckBox)row.FindControl("cbx_ISJH");
                if (cbx_ISJH != null)
                {
                    item1.ISJH = cbx_ISJH.Checked ? 1 : 2;
                }

                CheckBox cbx_ISCheckJF = row.FindControl("cbx_ISCheckJF") == null ? null : (CheckBox)row.FindControl("cbx_ISCheckJF");
                if (cbx_ISCheckJF != null)
                {
                    item1.ISCheckJF = cbx_ISCheckJF.Checked ? 1 : 2;
                }
                PDT_StandardPrice_Detail item2 = _bll.GetDetailModel(item1.ID);
                if (item1.FactoryPrice != item2.FactoryPrice || item1.TradeInPrice != item2.TradeInPrice || item1.TradeOutPrice != item2.TradeOutPrice || item1.StdPrice != item2.StdPrice)
                {
                    PDT_StandPriceChangeHistoryBLL history = new PDT_StandPriceChangeHistoryBLL();
                    history.Model.StandardPrice = _bll.Model.ID;
                    history.Model.ChangeType = 2;
                    history.Model.ChageTime = DateTime.Now;
                    history.Model.ChangeStaff = (int)Session["UserID"];
                    history.Model.Product = item1.Product;
                    history.Model.PreFactoryPrice = item2.FactoryPrice;
                    history.Model.PreTradeOutPrice = item2.TradeOutPrice;
                    history.Model.PreTradeInPrice = item2.TradeInPrice;
                    history.Model.PreStdPrice = item2.StdPrice;
                    history.Model.AftFactoryPrice = item1.FactoryPrice;
                    history.Model.AftTradeInPrice = item1.TradeInPrice;
                    history.Model.AftTradeOutPrice = item1.TradeOutPrice;
                    history.Model.AftStdPrice = item1.StdPrice;
                    history.Add();
                }
                _bll.UpdateDetail(item1);
            }
            #endregion
        }
        else
        {
            _bll.Model.ApproveFlag = 2;
            _bll.Model.ActiveFlag = 2;
            _bll.Model.InsertStaff = int.Parse(Session["UserID"].ToString());
            _bll.Add();
            ViewState["PriceID"] = _bll.Model.ID;
        }
    }
 protected void bt_Out_Click(object sender, EventArgs e)
 {
     foreach (GridViewRow row in gv_List.Rows)
     {
         CheckBox cb_check = (CheckBox)row.FindControl("cb_Check");
         if (cb_check.Checked)
         {
             PDT_StandardPriceBLL _bll;
             if ((int)ViewState["ID"] != 0)
                 _bll = new PDT_StandardPriceBLL((int)ViewState["ID"]);
             else
                 return;
             _bll.DeleteDetail(int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString()));
         }
     }
     Response.Redirect("StandardPriceDetail.aspx?ID=" + ViewState["ID"].ToString());
 }
 protected void btn_UnApprove_Click(object sender, EventArgs e)
 {
     PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);
     _bll.Model.ActiveFlag = 1;
     _bll.Model.ApproveFlag = 2;
     _bll.Model.TaskID = 0;
     _bll.Model.UpdateStaff = (int)Session["UserID"];
     _bll.Update();
     MessageBox.ShowAndRedirect(this, "取消审核成功!", "PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString());
 }
Esempio n. 30
0
        private void FillModel(int DeliveryID)
        {
            PBM_DeliveryBLL bll = new PBM_DeliveryBLL(DeliveryID);
            if (bll.Model == null) { ID = -1; return; }

            PBM_Delivery m = bll.Model;
            ID = m.ID;
            SheetCode = m.SheetCode;
            Supplier = m.Supplier;
            SupplierWareHouse = m.SupplierWareHouse;
            ClientWareHouse = m.ClientWareHouse;
            Client = m.Client;
            SalesMan = m.SalesMan;
            DeliveryMan = m.DeliveryMan;
            Classify = m.Classify;
            PrepareMode = m.PrepareMode;
            State = m.State;
            StandardPrice = m.StandardPrice;
            OrderID = m.OrderId;
            DiscountAmount = m.DiscountAmount;
            WipeAmount = m.WipeAmount;
            ActAmount = m.ActAmount;
            DeliveryVehicle = m.DeliveryVehicle;
            PreArrivalDate = m.PreArrivalDate;
            LoadingTime = m.LoadingTime;
            DepartTime = m.DepartTime;
            ActArriveTime = m.ActArriveTime;
            InsertTime = m.InsertTime;

            WorkList = m.WorkList;
            ApproveFlag = m.ApproveFlag;

            Remark = m.Remark;

            //发货单明细
            Items = new List<DeliveryDetail>();
            foreach (PBM_DeliveryDetail item in bll.Items)
            {
                Items.Add(new DeliveryDetail(item));
            }

            //付款信息列表
            PayInfos = new List<DeliveryPayInfo>();
            foreach (PBM_DeliveryPayInfo item in bll.GetPayInfoList())
            {
                PayInfos.Add(new DeliveryPayInfo(item));
            }

            #region 获取各字段ID对应的名称
            if (Supplier > 0)
            {
                CM_Client c = new CM_ClientBLL(Supplier).Model;
                if (c != null) SupplierName = c.FullName;
            }
            if (Client > 0)
            {
                CM_Client c = new CM_ClientBLL(Client).Model;
                if (c != null)
                {
                    ClientName = c.FullName;
                    ClientAddress = c.DeliveryAddress == "" ? c.Address : c.DeliveryAddress;
                    ClientLinkMan = c.LinkManName;
                    ClientTeleNum = c.Mobile == "" ? c.TeleNum : c.Mobile;
                }
            }
            if (SupplierWareHouse > 0)
            {
                CM_WareHouse w = new CM_WareHouseBLL(SupplierWareHouse).Model;
                if (w != null) SupplierWareHouseName = w.Name;
            }
            if (ClientWareHouse > 0)
            {
                CM_WareHouse w = new CM_WareHouseBLL(ClientWareHouse).Model;
                if (w != null) ClientWareHouseName = w.Name;
            }
            if (SalesMan > 0)
            {
                Org_Staff s = new Org_StaffBLL(SalesMan).Model;
                if (s != null) SalesManName = s.RealName;
            }
            if (DeliveryMan > 0)
            {
                Org_Staff s = new Org_StaffBLL(DeliveryMan).Model;
                if (s != null) DeliveryManName = s.RealName;
            }
            if (StandardPrice > 0)
            {
                PDT_StandardPrice s = new PDT_StandardPriceBLL(StandardPrice).Model;
                if (s != null) StandardPriceName = s.Name;
            }
            if (DeliveryVehicle > 0)
            {
                CM_Vehicle v = new CM_VehicleBLL(DeliveryVehicle).Model;
                if (v != null) DeliveryVehicleName = v.VehicleNo;
            }
            #endregion

            #region 获取字典表名称
            try
            {
                if (m.Classify > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_DeliveryClassify")[m.Classify.ToString()];
                    if (dic != null) ClassifyName = dic.Name;
                }
                if (m.PrepareMode > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_DeliveryPrepareMode")[m.PrepareMode.ToString()];
                    if (dic != null) PrepareModeName = dic.Name;
                }
                if (m.State > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PBM_DeliveryState")[m.State.ToString()];
                    if (dic != null) StateName = dic.Name;
                }
            }
            catch (System.Exception err)
            {
                LogWriter.WriteLog("MCSFramework.WSI.Delivery", err);
            }
            #endregion
        }
    protected void bt_In_Click(object sender, EventArgs e)
    {
        Save();
        if ((int)ViewState["PriceID"] == 0) return;

        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        foreach (GridViewRow row in gv_List_FacProd.Rows)
        {
            CheckBox cb_check = (CheckBox)row.FindControl("cb_Check");
            if (cb_check.Checked)
            {
                PDT_Product product = new PDT_ProductBLL((int)gv_List_FacProd.DataKeys[row.RowIndex]["ID"]).Model;
                if (product != null)
                {
                    PDT_StandardPrice_Detail detail = new PDT_StandardPrice_Detail();
                    detail.StandardPrice = (int)ViewState["PriceID"];
                    detail.Product = product.ID;
                    detail.FactoryPrice = product.FactoryPrice;
                    detail.TradeOutPrice = product.TradePrice;
                    detail.TradeInPrice = product.NetPrice;
                    detail.StdPrice = product.StdPrice;
                    PDT_StandPriceChangeHistoryBLL history = new PDT_StandPriceChangeHistoryBLL();
                    history.Model.StandardPrice = _bll.Model.ID;
                    history.Model.ChangeType = 1;
                    history.Model.ChageTime = DateTime.Now;
                    history.Model.ChangeStaff = (int)Session["UserID"];
                    history.Model.Product = detail.Product;
                    history.Model.AftFactoryPrice = detail.FactoryPrice;
                    history.Model.AftTradeOutPrice = detail.TradeOutPrice;
                    history.Model.AftTradeInPrice = detail.TradeInPrice;
                    history.Model.AftStdPrice = detail.StdPrice;
                    history.Add();

                    _bll.AddDetail(detail);
                }
            }
        }

        Response.Redirect("PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString());
    }
    protected void bt_CompareStdPrice_Click(object sender, EventArgs e)
    {
        decimal MaxRate = 0.000M;

        PDT_StandardPriceBLL bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);
        foreach (GridViewRow row in gv_List.Rows)
        {
            int id = (int)gv_List.DataKeys[row.RowIndex]["ID"];
            PDT_StandardPrice_Detail d = bll.Items.FirstOrDefault(p => p.ID == id);
            if (d == null) continue;

            PDT_Product product = new PDT_ProductBLL(d.Product).Model;
            if (product == null) continue;

            Label lb_FactoryPrice_Rate = (Label)row.FindControl("lb_FactoryPrice_Rate");
            Label lb_TradeOutPrice_Rate = (Label)row.FindControl("lb_TradeOutPrice_Rate");
            Label lb_TradeInPrice_Rate = (Label)row.FindControl("lb_TradeInPrice_Rate");
            Label lb_StdPrice_Rate = (Label)row.FindControl("lb_StdPrice_Rate");

            if (product.FactoryPrice != 0 && lb_FactoryPrice_Rate != null)
            {
                decimal price = decimal.Parse(((TextBox)row.FindControl("tbx_FactoryPrice")).Text);
                decimal rate = (price - product.FactoryPrice) / product.FactoryPrice;
                if (sender != null) lb_FactoryPrice_Rate.Text = rate.ToString("0.#%");

                if (Math.Abs(rate) > MaxRate) MaxRate = Math.Abs(rate);
            }

            if (product.TradePrice != 0 && lb_TradeOutPrice_Rate != null)
            {
                decimal price = decimal.Parse(((TextBox)row.FindControl("tbx_TradeOutPrice")).Text);
                decimal rate = (price - product.TradePrice) / product.TradePrice;
                if (sender != null) lb_TradeOutPrice_Rate.Text = rate.ToString("0.#%");

                if (Math.Abs(rate) > MaxRate) MaxRate = Math.Abs(rate);
            }

            if (product.NetPrice != 0 && lb_TradeInPrice_Rate != null)
            {
                decimal price = decimal.Parse(((TextBox)row.FindControl("tbx_TradeInPrice")).Text);
                decimal rate = (price - product.NetPrice) / product.NetPrice;
                if (sender != null) lb_TradeInPrice_Rate.Text = rate.ToString("0.#%");

                if (Math.Abs(rate) > MaxRate) MaxRate = Math.Abs(rate);
            }

            if (product.StdPrice != 0 && lb_StdPrice_Rate != null)
            {
                decimal price = decimal.Parse(((TextBox)row.FindControl("tbx_StdPrice")).Text);
                decimal rate = (price - product.StdPrice) / product.StdPrice;
                if (sender != null) lb_StdPrice_Rate.Text = rate.ToString("0.#%");

                if (Math.Abs(rate) > MaxRate) MaxRate = Math.Abs(rate);
            }
        }

        if (sender != null) lb_MaxRate.Text = string.Format("价格最大偏差{0:0.#%}", MaxRate);
        ViewState["MaxRate"] = MaxRate;
    }
Esempio n. 33
0
    protected void select_Product_SelectChange(object sender, MCSControls.MCSWebControls.SelectChangeEventArgs e)
    {
        int product = 0;

        int.TryParse(select_Product.SelectValue, out product);
        if (product != 0)
        {
            PDT_ProductBLL productbll = new PDT_ProductBLL(product);
            if (productbll.Model == null)
            {
                return;
            }
            PDT_Product p = productbll.Model;

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

            #region 显示批号及库存信息
            ddl_LotNumber.Items.Clear();
            if ((int)ViewState["Classify"] == 2)
            {
                //退货,从供货商全部仓库中获取可退货的批号
                IList <INV_Inventory> list = INV_InventoryBLL.GetListByClientAndProduct((int)ViewState["Supplier"], product);
                foreach (INV_Inventory item in list)
                {
                    ddl_LotNumber.Items.Add(new ListItem((item.LotNumber == "" ? "无批号" : item.LotNumber), item.LotNumber));
                }
            }
            else
            {
                //销售,仅获取指定仓库可销售的批号
                foreach (INV_Inventory item in INV_InventoryBLL.GetInventoryListByProduct((int)ViewState["WareHouse"], product).OrderBy(t => t.LotNumber))
                {
                    string invstr = (item.Quantity / p.ConvertFactor).ToString() + _T;
                    if (item.Quantity % p.ConvertFactor > 0)
                    {
                        invstr += " " + (item.Quantity % p.ConvertFactor).ToString() + _P;
                    }

                    ddl_LotNumber.Items.Add(new ListItem((item.LotNumber == "" ? "无批号" : item.LotNumber) +
                                                         " -【库存量:" + invstr + "】", item.LotNumber));
                }
            }
            if (ddl_LotNumber.Items.Count == 0)
            {
                ddl_LotNumber.Items.Add(new ListItem("无批号", ""));
            }
            ddl_LotNumber_SelectedIndexChanged(null, null);
            #endregion

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

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

        if ((int)ViewState["StandardPrice"] > 0)
        {
            PDT_StandardPrice s = new PDT_StandardPriceBLL((int)ViewState["StandardPrice"]).Model;
            if (s != null) lbl_StandardPrice.Text = s.FullName;
        }

        BindClient();
        tbx_begin.Text = sv.BeginDate.ToString("yyyy-MM-dd") == "1900-01-01" ? "" : sv.BeginDate.ToString("yyyy-MM-dd");
        tbx_end.Text = sv.EndDate.ToString("yyyy-MM-dd") == "1900-01-01" ? "" : sv.EndDate.ToString("yyyy-MM-dd");

        if (sv.ApproveFlag == 1)
        {
            tbx_begin.Enabled = false;
            tbx_end.Enabled = false;
            gv_List.Columns[0].Visible = false;

            btn_Save.Visible = false;
            btn_Delete.Visible = false;
            tr_tab.Visible = false;
            lb_ApproveFlag.Text = "已审核";
            btn_Approve.Visible = false;

            if (sv.EndDate < DateTime.Now)
            {
                bt_Stop.Visible = false;
                btn_UnApprove.Visible = false;
            }
        }
        else
        {
            bt_Stop.Visible = false;
            btn_UnApprove.Visible = false;
        }

        BindGrid();
    }
    protected void bt_Out_Click(object sender, EventArgs e)
    {
        Save();
        if ((int)ViewState["PriceID"] == 0) return;

        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        foreach (GridViewRow row in gv_List.Rows)
        {
            CheckBox cb_check = (CheckBox)row.FindControl("cb_Check");
            if (cb_check.Checked)
            {
                PDT_StandardPrice_Detail item2 = _bll.GetDetailModel(int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString()));
                PDT_StandPriceChangeHistoryBLL history = new PDT_StandPriceChangeHistoryBLL();
                history.Model.StandardPrice = _bll.Model.ID;
                history.Model.ChangeType = 3;
                history.Model.ChageTime = DateTime.Now;
                history.Model.ChangeStaff = (int)Session["UserID"];
                history.Model.Product = item2.Product;
                history.Model.PreFactoryPrice = item2.FactoryPrice;
                history.Model.PreTradeOutPrice = item2.TradeOutPrice;
                history.Model.PreTradeInPrice = item2.TradeInPrice;
                history.Model.PreStdPrice = item2.StdPrice;
                history.Add();
                _bll.DeleteDetail(int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString()));
            }
        }
        Response.Redirect("PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString());
    }
 private void BindData()
 {
     PDT_StandardPrice m = new PDT_StandardPriceBLL((int)ViewState["ID"]).Model;
     if (m != null)
     {
         pl_detail.BindData(m);
         BindGrid();
         if (m.IsDefault == "Y")
         {
             //默认价表,不允许修改属性
             pl_detail.SetControlsEnable(false);
             gv_List.SetControlsEnable(false);
             bt_Out.Enabled = false;
             bt_In.Enabled = false;
         }
     }
 }
    private void BindCheckBoxList()
    {
        if ((int)ViewState["PriceID"] > 0)
        {
            cbl_ApplyCity.Items.Clear();

            PDT_StandardPriceBLL bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

            foreach (PDT_StandardPrice_ApplyCity city in bll.ApplyCityItems)
            {
                string cityname = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", city.OrganizeCity);
                cbl_ApplyCity.Items.Add(new ListItem(cityname, city.ID.ToString()));
            }

            tr_OrganizeCity.DataSource = TreeTableBLL.GetAllChildNodeByNodes("MCS_SYS.dbo.Addr_OrganizeCity", "ID", "SuperID", bll.Model.OrganizeCity.ToString());
            tr_OrganizeCity.RootValue = bll.Model.OrganizeCity.ToString();
            tr_OrganizeCity.SelectValue = tr_OrganizeCity.RootValue;

            if (bll.Model.ApproveFlag == 1)
            {
                bt_Add.Visible = false;
                bt_Delete.Visible = false;
                tr_OrganizeCity.Enabled = false;
            }
        }
    }
    private void BindData()
    {
        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);
        panel1.BindData(_bll.Model);

        if (_bll.Model.ApproveFlag == 1 || (_bll.Model.TaskID != 0 && _bll.Model.ApproveFlag == 2))
        {
            btn_Save.Visible = false;
            tr_tab.Visible = false;
            btn_Apply.Visible = false;
            panel1.SetControlsEnable(false);
            btn_Approve.Visible = false;

            if (_bll.Model.ActiveFlag == 2)
            {
                btn_UnActive.Visible = false;
                btn_UnApprove.Visible = false;
                btn_PublishProduct.Visible = false;
            }

        }

        if (_bll.Model.ApproveFlag == 2)
        {
            btn_UnActive.Visible = false;
            btn_UnApprove.Visible = false;
            btn_PublishProduct.Visible = false;
        }
        if (_bll.Model["IsRebatePrice"] == "1")
        {
            gv_List.Columns[gv_List.Columns.Count - 3].Visible = true;//是否计算我司返利
            gv_List.Columns[gv_List.Columns.Count - 4].Visible = true;//经销商返利价
            gv_List.Columns[gv_List.Columns.Count - 5].Visible = true;//我司返利价
            gv_List.Columns[gv_List.Columns.Count - 1].Visible = true;//是否需要判断积分店状态
            gv_List.Columns[gv_List.Columns.Count - 2].Visible = true;//是否计算经销商返利
        }
        BindGrid();
    }
    private void BindGrid()
    {
        string condition = " 1 = 1 ";

        condition += " ORDER BY PDT_Product.Code";

        PDT_StandardPriceBLL bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);
        gv_List.BindGrid(bll.GetDetail(condition));
    }
Esempio n. 40
0
        private void FillClientInfo(CM_Client m, int TDP)
        {
            if (m == null) return;

            CM_ClientBLL ClientBLL = new CM_ClientBLL(m.ID);
            if (ClientBLL.Model == null) return;

            #region 绑定基本资料
            ID = m.ID;
            Code = m.Code;
            FullName = m.FullName == "" ? m.ShortName : m.FullName;
            ShortName = m.ShortName;
            OfficialCity = m.OfficialCity;
            Address = m.Address;
            ClientType = m.ClientType;
            LinkManName = m.LinkManName;
            TeleNum = m.TeleNum;
            Mobile = m.Mobile == "" ? m.TeleNum : m.Mobile;

            OfficialCityName = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OfficialCity", m.OfficialCity).Replace("->", " ");
            #endregion

            #region 绑定供货信息
            CM_ClientSupplierInfo SupplierInfo = ClientBLL.GetSupplierInfo(TDP);
            if (SupplierInfo != null)
            {
                CodeBySupplier = SupplierInfo.Code;
                Supplier = SupplierInfo.Supplier;
                StandardPrice = SupplierInfo.StandardPrice;
                TDPChannel = SupplierInfo.TDPChannel;
                TDPSalesArea = SupplierInfo.TDPSalesArea;
                VisitRoute = SupplierInfo.VisitRoute;
                VisitSequence = SupplierInfo.VisitSequence;
                VisitTemplate = SupplierInfo.VisitTemplate;

                #region 获取供货商名称
                CM_Client s = new CM_ClientBLL(Supplier).Model;
                if (s != null)
                {
                    SupplierName = s.ShortName == "" ? s.ShortName : s.FullName;
                }
                #endregion

                #region 获取价表名称
                if (StandardPrice != 0)
                {
                    PDT_StandardPrice price = new PDT_StandardPriceBLL(StandardPrice).Model;
                    if (price != null)
                    {
                        StandardPriceName = price.Name;
                    }
                }
                #endregion

                #region 获取渠道名称
                if (TDPChannel > 0)
                {
                    CM_RTChannel_TDP channel = new CM_RTChannel_TDPBLL(TDPChannel).Model;
                    if (channel != null) TDPChannelName = channel.Name;
                }
                #endregion

                #region 获取区域名称
                if (TDPSalesArea > 0)
                {
                    CM_RTSalesArea_TDP area = new CM_RTSalesArea_TDPBLL(TDPSalesArea).Model;
                    if (area != null) TDPSalesAreaName = area.Name;
                }
                #endregion

                #region 获取路线及拜访模板名称
                if (VisitRoute != 0)
                {
                    VST_Route r = new VST_RouteBLL(VisitRoute).Model;
                    if (r != null) VisitRouteName = r.Name;
                }

                if (VisitTemplate != 0)
                {
                    VST_VisitTemplate t = new VST_VisitTemplateBLL(VisitTemplate).Model;
                    if (t != null) VisitTemplateName = t.Name;
                }
                #endregion

                #region 获取销售员名称
                if (Salesman != 0)
                {
                    Org_Staff staff = new Org_StaffBLL(Salesman).Model;
                    if (staff != null) SalesmanName = staff.RealName;
                }
                #endregion

            }
            #endregion

            #region 绑定厂商管理信息
            int manufacturer = 0;           //归属厂商
            if (m.ClientType == 3)
            {
                //门店的归属厂商为当前TDP所归属的厂商
                CM_Client supplier = new CM_ClientBLL(TDP).Model;
                if (supplier != null) manufacturer = supplier.OwnerClient;
            }
            else if (m.ClientType == 2)
            {
                //TDP经销商的归属厂商
                manufacturer = m.OwnerClient;
            }

            CM_ClientManufactInfo ManufactInfo = ClientBLL.GetManufactInfo(manufacturer);
            if (ManufactInfo != null)
            {
                CodeByManufaturer = ManufactInfo.Code;
            }
            #endregion

            #region 绑定客户定位信息
            CM_ClientGeoInfo geo = CM_ClientGeoInfoBLL.GetGeoInfoByClient(m.ID);
            if (geo != null)
            {
                Latitude = (float)geo.Latitude;
                Longitude = (float)geo.Longitude;
            }
            #endregion

            #region 绑定客户供货产品目录
            ClientProductLists = new List<ProductList>();
            foreach (CM_ClientProductList item in CM_ClientProductListBLL.GetModelList
                ("Client=" + m.ID.ToString() + (TDP == 0 ? "" : " AND Supplier=" + TDP.ToString())))
            {
                ClientProductLists.Add(new ProductList(item));
            }
            #endregion

            #region 查询预收款余额
            AC_CurrentAccount ac = AC_CurrentAccountBLL.GetByTradeClient(TDP, m.ID);
            if (ac != null) ARBalance = ac.PreReceivedAmount - ac.AR;
            #endregion

            #region 获取附件明细
            IList<ATMT_Attachment> atts = ATMT_AttachmentBLL.GetAttachmentList(30, m.ID, DateTime.Today.AddMonths(-3), new DateTime(2100, 1, 1));
            Atts = new List<Attachment>(atts.Count);
            foreach (ATMT_Attachment item in atts.OrderByDescending(p => p.UploadTime))
            {
                Atts.Add(new Attachment(item));
            }
            #endregion
        }