Exemplo n.º 1
0
    /// <summary>
    /// 创建让利明细表
    /// </summary>
    /// <param name="document"></param>
    /// <param name="client"></param>
    /// <param name="documentDate"></param>
    /// <param name="year"></param>
    /// <param name="month"></param>
    /// <returns></returns>
    private Document RangLiDetailPDF(Document document, CM_Client client, string documentDate, DateTime dateBegin, DateTime dateEnd)// int year, int month)
    {
        if (!document.IsOpen())
        {
            return(null);
        }
        document = this.GetDocumentHeader(document, "让利明细表", documentDate, client);
        document.Add(Chunk.NEWLINE);

        string procName = "JD.AIS_YSL.dbo.STKD_DDFYREPORT01_CXCAI";//代垫费用余额(让利明细表)存储过程名

        DataTable dt = new DataTable();

        while (DateTime.Compare(dateBegin, dateEnd) <= 0)
        {
            //文档期间项
            int       year   = dateBegin.Year;
            int       month  = dateBegin.Month;
            DataTable dtTemp = new CM_ClientBLL().GetStatement(procName, year, month, client.Code);
            dt.Merge(dtTemp);

            dateBegin = dateBegin.AddMonths(1);
        }
        dt.Columns.RemoveAt(1);//去除“期间”列
        //dt.Columns[1].SetOrdinal(0);//“期间”列移至首列

        List <string> tableHeaders = new List <string>(5);

        //tableHeaders.Add("期间");
        tableHeaders.Add("日期");
        tableHeaders.Add("摘要");
        tableHeaders.Add("转账金额");
        tableHeaders.Add("市场费用投入");
        tableHeaders.Add("期末余额");
        for (int i = 0; i < dt.Columns.Count; i++)
        {
            dt.Columns[i].ColumnName = tableHeaders[i];
        }

        PdfPTable ptable = TableToPDFTable(dt);

        //ptable.TotalWidth = 520f;
        //ptable.LockedWidth = true;
        float[] widths = new float[] { 1f, 2f, 1f, 1f, 1f };
        ptable.SetWidths(widths);

        document.Add(ptable);

        document = this.GetDocumentNotice(document);

        document.Add(Chunk.NEWLINE);

        this.GetDocumentSign(document);

        return(document);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 为单个经销商创建PDF文档
    /// </summary>
    /// <param name="folderPath"></param>
    /// <param name="fileName"></param>
    /// <param name="client"></param>
    /// <param name="dateBegin"></param>
    /// <param name="dateEnd"></param>
    public void CreateClientPDF(string folderPath, string fileName, CM_Client client, DateTime dateBegin, DateTime dateEnd)
    {
        Document doc = GetOrCreatePDF(fileName, folderPath);
        //文档期间项
        string documentDate = dateBegin.ToString("yyyy年第MM期") + "至" + dateEnd.ToString("yyyy年第MM期");

        doc = ReceiveBillPDF(doc, client, documentDate, dateBegin, dateEnd);
        doc.Add(Chunk.NEXTPAGE);
        doc = RangLiDetailPDF(doc, client, documentDate, dateBegin, dateEnd);
        doc.Add(Chunk.NEXTPAGE);
        doc = TransferDetailPDF(doc, client, documentDate, dateBegin, dateEnd);
        doc.Add(Chunk.NEXTPAGE);

        dateBegin = dateBegin.AddMonths(1);

        DisposePdf(doc);
    }
Exemplo n.º 3
0
    private void BindData()
    {
        int clientID = 0;

        if (ViewState["ClientID"] == null || !int.TryParse(ViewState["ClientID"].ToString(), out clientID))
        {
            return;
        }

        CM_ClientBLL clientbll = new CM_ClientBLL(clientID);
        CM_Client    m         = clientbll.Model;

        if (m == null)
        {
            Response.Redirect("DistributorList.aspx");
        }

        switch (m.ClientType)
        {
        case 1:
            Response.Redirect("../Store/StoreDetail.aspx?ClientID=" + m.ID.ToString());
            break;

        case 2:
            break;

        case 3:
            Response.Redirect("../RT/RetailerDetail.aspx?ClientID=" + m.ID.ToString());
            break;

        default:
            MessageBox.ShowAndRedirect(this, "请先在‘经销商列表’中选择要查看的经销商!", "DistributorList.aspx?URL=" + Request.Url.PathAndQuery);
            break;
        }
        pl_detail.BindData(m);

        tr_OfficialCity_Selected(null, null);
        tr_OrganizeCity_Selected(null, null);

        CM_ClientSupplierInfo supplierinfo = clientbll.GetSupplierInfoByManufacturer((int)Session["Manufacturer"]);
        CM_ClientManufactInfo manufactinfo = clientbll.GetManufactInfo((int)Session["Manufacturer"]);

        if (supplierinfo != null)
        {
            pl_detail.BindData(supplierinfo);
        }
        if (manufactinfo != null)
        {
            pl_detail.BindData(manufactinfo);
        }

        MCSSelectControl select_ClientManager = (MCSSelectControl)pl_detail.FindControl("CM_ClientManufactInfo_ClientManager");

        if (select_ClientManager != null && manufactinfo != null)
        {
            select_ClientManager.PageUrl = "~/SubModule/StaffManage/Pop_Search_Staff.aspx?OrganizeCity=" + manufactinfo.OrganizeCity.ToString() + "&IncludeSuperManager=Y";
        }
        if (manufactinfo != null && manufactinfo.ApproveFlag == 1)
        {
            //已审核
            TextBox tbx_BeginDate = (TextBox)pl_detail.FindControl("CM_ClientManufactInfo_BeginDate");
            if (tbx_BeginDate != null && tbx_BeginDate.Text != "")
            {
                tbx_BeginDate.Enabled = false;
            }
            TextBox tbx_Code = (TextBox)pl_detail.FindControl("CM_ClientManufactInfo_Code");
            if (tbx_Code != null)
            {
                tbx_Code.Enabled = false;
            }

            bt_Approve.Visible = false;
            Header.Attributes["WebPageSubCode"] = "Modify";
        }
    }
Exemplo n.º 4
0
    private void BindData()
    {
        CM_ClientBLL clientbll = new CM_ClientBLL((int)ViewState["ClientID"]);
        CM_Client    m         = clientbll.Model;

        if (m == null)
        {
            Response.Redirect("RetailerList.aspx");
        }

        switch (m.ClientType)
        {
        case 1:
            Response.Redirect("../Store/StoreDetail.aspx?ClientID=" + m.ID.ToString());
            break;

        case 2:
            Response.Redirect("../DI/DistributorDetail.aspx?ClientID=" + m.ID.ToString());
            break;

        case 3:
            break;

        default:
            MessageBox.ShowAndRedirect(this, "请先在‘零售商列表’中选择要查看的零售商!", "RetailerList.aspx?URL=" + Request.Url.PathAndQuery);
            break;
        }

        CM_ClientSupplierInfo supplierinfo = clientbll.GetSupplierInfoByManufacturer((int)Session["Manufacturer"]);
        CM_ClientManufactInfo manufactinfo = clientbll.GetManufactInfo((int)Session["Manufacturer"]);

        pl_detail.BindData(m);

        if (supplierinfo != null)
        {
            pl_detail.BindData(supplierinfo);
        }
        if (manufactinfo != null)
        {
            BindGeoCode(m.OfficialCity);
            BindVisitRoute(manufactinfo.OrganizeCity);
            pl_detail.BindData(manufactinfo);
        }



        MCSSelectControl select_ClientManager = (MCSSelectControl)pl_detail.FindControl("CM_ClientManufactInfo_ClientManager");

        if (select_ClientManager != null)
        {
            select_ClientManager.PageUrl = "~/SubModule/StaffManage/Pop_Search_Staff.aspx?OrganizeCity=" + manufactinfo.OrganizeCity.ToString() + "&IncludeSuperManager=Y";
        }

        if (manufactinfo != null)
        {
            if (manufactinfo.SyncState != 0 && manufactinfo.SyncState != 1 && manufactinfo.SyncState != 8)
            {
                bt_Submit.Visible = false;
            }
            if (manufactinfo.SyncState != 2)
            {
                bt_Approve.Visible = false; bt_UnApprove.Visible = false;
            }

            //有公司客户编号后,页面为编辑权限模式
            if (!string.IsNullOrEmpty(manufactinfo.Code))
            {
                Header.Attributes["WebPageSubCode"] = "Modify";
            }
        }

        bt_Map.OnClientClick = "javascript:Pop_MapShow(" + m.ID.ToString() + ")";
    }
Exemplo n.º 5
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
        }
Exemplo n.º 6
0
 public ClientInfo(CM_Client m, int TDP)
 {
     FillClientInfo(m, TDP);
 }
    protected void Page_Load(object sender, System.EventArgs e)
    {
        // 在此处放置用户代码以初始化页面
        if (!Page.IsPostBack)
        {
            int ClientID = Request.QueryString["ClientID"] != null && int.TryParse(Request.QueryString["ClientID"].ToString(), out ClientID) ? ClientID : 0;
            ViewState["ClientID"] = ClientID;

            BindDropDown();

            if ((int)ViewState["ClientID"] > 0)
            {
                BindData();
            }
            else
            {
                #region 新增门店时的初始值
                CM_Client tdp = new CM_ClientBLL((int)Session["OwnerClient"]).Model;
                if (tdp == null)
                {
                    Response.Redirect("RetailerList.aspx");
                    return;
                }

                CM_Client m = new CM_Client();
                m.OfficialCity = tdp.OfficialCity;
                m.PostCode     = tdp.PostCode;

                CM_ClientSupplierInfo supplierinfo = new CM_ClientSupplierInfo();
                supplierinfo.State         = 1;
                supplierinfo.BeginDate     = DateTime.Today;
                supplierinfo.StandardPrice = PDT_StandardPriceBLL.GetDefaultPrice(tdp.ID);

                pl_detail.BindData(m);
                pl_detail.BindData(supplierinfo);

                bt_Map.Visible        = false;
                bt_AddLinkMan.Visible = false;
                tr_LinkMan.Visible    = false;

                #region 新增客户时,首要联系人字段不可编辑
                DropDownList ddl_ChiefLinkMan = (DropDownList)pl_detail.FindControl("CM_Client_ChiefLinkMan");
                try
                {
                    if (ddl_ChiefLinkMan != null)
                    {
                        ddl_ChiefLinkMan.Items.Clear();
                        ddl_ChiefLinkMan.Enabled = false;
                    }
                }
                catch { }
                #endregion

                #endregion
            }
        }

        #region 给活跃标志加事件
        //DropDownList ddl_ActiveFlag_1 = (DropDownList)pl_detail.FindControl("CM_Client_ActiveFlag");
        //ddl_ActiveFlag_1.AutoPostBack = true;
        //ddl_ActiveFlag_1.SelectedIndexChanged += new EventHandler(ddl_ActiveFlag_SelectedIndexChanged);
        #endregion


        #region 注册弹出窗口脚本
        string script = "function Pop_MapShow(id){\r\n";
        script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("~/SubModule/CM/Map/ClientInMap.aspx") +
                  "?ClientID=' + id + '&tempid='+tempid, window, 'dialogWidth:800px;DialogHeight=550px;status:yes;resizable=yes');}";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopShow", script, true);
        #endregion
    }
Exemplo n.º 8
0
        /// <summary>
        /// 同步经销商进货单
        /// </summary>
        /// <param name="begindate"></param>
        /// <param name="enddate"></param>
        /// <param name="clientcode"></param>
        private void SyncSellOut(DateTime begindate, DateTime enddate, string clientcode)
        {
            try
            {
                int success = 0;

                //从进销存数据库中读取出货数据
                DataTable dtShipHeader = null;

                if (string.IsNullOrEmpty(clientcode))
                {
                    dtShipHeader = ERPIF.GetShipHeader(begindate, enddate);
                }
                else
                {
                    SendMessage(0, "经销商代码:" + clientcode);
                    dtShipHeader = ERPIF.GetShipHeader(begindate, enddate, clientcode);
                }
                SendMessage(0, "本次共获取到" + dtShipHeader.Rows.Count.ToString() + "条发货单待同步!" + _sClientCode);

                for (int i = 0; i < dtShipHeader.Rows.Count; i++)
                {
                    DataRow dr = dtShipHeader.Rows[i];

                    if (_bCancelSync)
                    {
                        SendMessage(0, "同步进行中时,被用户取消!");
                        break;
                    }
                    #region 逐条同步发货单
                    try
                    {
                        string   SheetCode  = dr["DELIVERY_ID"].ToString().Trim();
                        string   ClientCode = dr["CUST_NUMBER"].ToString().Trim();
                        DateTime SalesDate  = DateTime.Parse(dr["CARRY_SDATE"].ToString().Trim());
                        string   DJType     = dr["ORDER_TYPE"].ToString().Trim();
                        decimal  discount   = 0;
                        decimal.TryParse(dr["DISCOUNT"].ToString().Trim(), out discount);

                        if (DJType == "R")
                        {
                            continue;
                        }

                        if (ORD_OrderDeliveryBLL.GetModelList(" SheetCode = '" + SheetCode + "'").Count > 0)
                        {
                            continue;
                        }

                        #region 判断客户号有效否
                        IList <CM_Client> clients = CM_ClientBLL.GetModelList(" Code= '" + ClientCode.ToString() + "' AND ActiveFlag=1 AND ApproveFlag=1");
                        if (clients.Count == 0)
                        {
                            SendMessage(-11, "经销商编号为" + ClientCode.ToString() + "的匹配错误!");
                            continue;
                        }
                        CM_Client client = clients[0];
                        if (client["DIClassify"] == "3")
                        {
                            //经销商子户头
                            client = new CM_ClientBLL(client.Supplier).Model;
                            if (client == null)
                            {
                                SendMessage(-12, "经销商编号为" + ClientCode.ToString() + "对应的经销商为子户头,但未关联正确的主户头!");
                                continue;
                            }
                        }

                        if (client["DIClassify"] != "1")
                        {
                            SendMessage(-13, "经销商编号为" + ClientCode.ToString() + "对应的经销商不是主户头!");
                            continue;
                        }
                        #endregion

                        #region 生成销量单头
                        ORD_OrderDeliveryBLL bll = new ORD_OrderDeliveryBLL();
                        bll.Model.SheetCode    = SheetCode;
                        bll.Model.AccountMonth = AC_AccountMonthBLL.GetMonthByDate(SalesDate);
                        bll.Model.OrganizeCity = client.OrganizeCity;
                        bll.Model.State        = 1; //未发货
                        bll.Model.Client       = client.ID;
                        bll.Model.Store        = client.Supplier;
                        if (dr["CARRY_EDATE"].ToString() != "")
                        {
                            bll.Model.PreArrivalDate = DateTime.Parse(dr["CARRY_EDATE"].ToString().Trim());
                        }
                        else
                        {
                            bll.Model.PreArrivalDate = SalesDate.AddDays(7);      //默认7天后到货
                        }
                        bll.Model.ApproveFlag       = 1;
                        bll.Model.InsertStaff       = 1;
                        bll.Model["DeliveryTime"]   = SalesDate.ToString("yyyy-MM-dd HH:mm");
                        bll.Model["TruckNo"]        = dr["CARRY_CAR"].ToString().Trim();
                        bll.Model["DeliveryStaff"]  = "1";
                        bll.Model["DeliveryRemark"] = "ERP发货单提取";
                        bll.Model["Discount"]       = discount.ToString("0.###");
                        bll.Model["CarrySheetCode"] = dr["REQUEST_NUMBER"].ToString().Trim();
                        #endregion

                        //获取进销存明细
                        DataTable dt_detail = ERPIF.GetShipDetail(SheetCode);

                        #region 生成销量明细
                        foreach (DataRow dr_detail in dt_detail.Rows)
                        {
                            string  productcode = dr_detail["ITEM_NO"].ToString();
                            decimal price       = decimal.Parse(dr_detail["PRICE"].ToString());
                            int     quantity    = (int)decimal.Parse(dr_detail["SHIP_QTY"].ToString());
                            string  packaging   = dr_detail["UOM"].ToString();

                            if (quantity == 0)
                            {
                                continue;
                            }

                            #region 验证产品信息
                            PDT_Product product = null;
                            if (price == 0)
                            {
                                #region 价格为0,表示为赠品,取赠品目录中的物料
                                IList <PDT_Product> _products = PDT_ProductBLL.GetModelList("Code='" + productcode + "' AND Brand IN (SELECT ID FROM MCS_Pub.dbo.PDT_Brand WHERE IsOpponent=9)");
                                if (_products.Count > 0)
                                {
                                    product = _products[0];
                                }
                                else
                                {
                                    _products = PDT_ProductBLL.GetModelList("Code='" + productcode + "' AND Brand IN (SELECT ID FROM MCS_Pub.dbo.PDT_Brand WHERE IsOpponent <> 9)");
                                    if (_products.Count == 0)
                                    {
                                        SendMessage(-21, string.Format("发货单号为{0}内,产品编号{1}未在产品目录库中未找到!", SheetCode, productcode));
                                        continue;
                                    }
                                    else
                                    {
                                        //在成品目录里找到,但未在赠品目录中,自动在赠品目录中增加一条本品赠品目录
                                        PDT_ProductBLL productbll = new PDT_ProductBLL();
                                        productbll.Model             = _products[0];
                                        productbll.Model.Brand       = 3;   //本品赠品
                                        productbll.Model.Classify    = 100; //其他品类
                                        productbll.Model.State       = 2;   //停用
                                        productbll.Model.ApproveFlag = 2;   //未审核
                                        int productid = productbll.Add();

                                        product = new PDT_ProductBLL(productid).Model;
                                        SendMessage(0, string.Format("发货单号为{0}内,产品编号{1}未在本品赠品目录库中未找到,自动从产品库中增加该赠品信息!", SheetCode, productcode));
                                    }
                                }
                                #endregion
                            }
                            else
                            {
                                #region 从产品目录中取该产品信息
                                IList <PDT_Product> _products = PDT_ProductBLL.GetModelList("Code='" + productcode + "' AND Brand IN (SELECT ID FROM MCS_Pub.dbo.PDT_Brand WHERE IsOpponent<>9)");
                                if (_products.Count > 0)
                                {
                                    product = _products[0];
                                }
                                else
                                {
                                    _products = PDT_ProductBLL.GetModelList("Code='" + productcode + "' AND Brand IN (SELECT ID FROM MCS_Pub.dbo.PDT_Brand WHERE IsOpponent = 9)");
                                    if (_products.Count == 0)
                                    {
                                        SendMessage(-22, string.Format("发货单号为{0}内,产品编号{1}未在产品物料目录库中未找到!", SheetCode, productcode));
                                        continue;
                                    }
                                    else
                                    {
                                        //在赠品目录中找到,则使用赠品目录的产品ID
                                        //不在产品中增加该成品 2012-04-25
                                        product = _products[0];

                                        ////在赠品目录里找到,但未在成品目录中,自动在成品目录中增加一条本品成品目录
                                        //PDT_ProductBLL productbll = new PDT_ProductBLL();
                                        //productbll.Model = _products[0];
                                        //productbll.Model.Brand = 1;
                                        //productbll.Model.Classify = 1;
                                        //productbll.Model.State = 2;         //停用
                                        //productbll.Model.ApproveFlag = 2;   //未审核
                                        //int productid = productbll.Add();

                                        //product = new PDT_ProductBLL(productid).Model;
                                        //SendMessage(0, string.Format("发货单号为{0}内,产品编号{1}未在成品目录库中未找到,自动从赠品库中增加该产品信息!", SheetCode, productcode));
                                    }
                                }
                                #endregion
                            }

                            if (product.State == 2 && product.ApproveFlag == 1)
                            {
                                //确认被停用的产品,不再同步
                                continue;
                            }

                            if (product.State == 3 && !string.IsNullOrEmpty(product["MasterProduct"]) && product["MasterProduct"] != "0")
                            {
                                //是子产品,自动归属到主产品
                                PDT_Product _p = new PDT_ProductBLL(int.Parse(product["MasterProduct"])).Model;
                                if (_p != null)
                                {
                                    product = _p;
                                }
                            }

                            if (product == null)
                            {
                                SendMessage(-23, productcode + "为无效产品编号!");
                                continue;
                            }
                            #endregion

                            if (packaging == "Ea" && product.ConvertFactor > 1)
                            {
                                //整箱单位,转换为零售单位
                                quantity = quantity * product.ConvertFactor;
                                price    = price / product.ConvertFactor;
                            }

                            ORD_OrderDeliveryDetail item = bll.Items.FirstOrDefault
                                                               (p => p.Product == product.ID && p.Client == client.ID);

                            if (item != null)
                            {
                                item.DeliveryQuantity += quantity;
                            }
                            else
                            {
                                item                  = new ORD_OrderDeliveryDetail();
                                item.Client           = client.ID;
                                item.Product          = product.ID;
                                item.Price            = price;
                                item.FactoryPrice     = price == 0 ? product.FactoryPrice : price;
                                item.DeliveryQuantity = quantity;
                                item.SignInQuantity   = 0;
                                item.BadQuantity      = 0;
                                item.LostQuantity     = 0;

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

                        if (bll.Items.Count == 0)
                        {
                            SendMessage(0, "发货单号" + bll.Model.SheetCode + ",未获取到发货单产品明细");
                            continue;
                        }

                        #region 写入发货单
                        if (bll.Add() > 0)
                        {
                            //bll.Delivery(1);        //设为发货状态(20140708修改为数据库作业执行)
                            SendMessage(0, "成功导入发货数据!单号:" + bll.Model.SheetCode + ",发生日期:" + SalesDate.ToString("yyyy-MM-dd") + ",产品明细条数:" + bll.Items.Count.ToString() + ",同步进度:" + (i + 1).ToString() + "/" + dtShipHeader.Rows.Count.ToString());
                        }
                        else
                        {
                            SendMessage(-40, "导入发货数据失败!单号" + bll.Model.SheetCode);
                            continue;
                        }
                        #endregion
                        success += 1;
                    }
                    catch (Exception err)
                    {
                        SendMessage(0, err.StackTrace + err.Source + err.Message);
                        continue;
                    }
                    #endregion
                }

                SendMessage(0, "------" + begindate.ToString("yyyy-MM-dd HH:mm") +
                            "至" + enddate.ToString("yyyy-MM-dd HH:mm") +
                            "。总共同步完成" + success.ToString() + "条发货单记录!-------");
            }
            catch (Exception err)
            {
                SendMessage(0, "SyncSellOut()" + err.StackTrace + err.Source + err.Message);
            }
        }
    private void BindData()
    {
        CM_ClientBLL _bll = new CM_ClientBLL((int)ViewState["ClientID"]);
        CM_Client    m    = _bll.Model;

        switch (m.ClientType)
        {
        case 1:
            Response.Redirect("../Store/StoreDetail.aspx?ClientID=" + m.ID.ToString());
            break;

        case 2:
            Response.Redirect("../DI/DistributorDetail.aspx?ClientID=" + m.ID.ToString());
            break;

        case 3:
            break;

        default:
            MessageBox.ShowAndRedirect(this, "请先在‘零售商列表’中选择要查看的零售商!", "RetailerList.aspx?URL=" + Request.Url.PathAndQuery);
            break;
        }

        pl_detail.BindData(m);


        //lbl_preSales.Text = _bll.GetSalesVolume(AC_AccountMonthBLL.GetCurrentMonth() - 1).ToString();
        //lbl_AvageSales.Text = _bll.GetSalesVolumeAvg().ToString();

        MCSSelectControl select_ClientManager = (MCSSelectControl)pl_detail.FindControl("CM_Client_ClientManager");

        if (select_ClientManager != null)
        {
            select_ClientManager.PageUrl = "~/SubModule/StaffManage/Pop_Search_Staff.aspx?OrganizeCity=" + m.OrganizeCity + "&IncludeSuperManager=Y";
        }

        MCSSelectControl select_Supplier = (MCSSelectControl)pl_detail.FindControl("CM_Client_Supplier");

        if (select_Supplier != null)
        {
            select_Supplier.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType=2&OrganizeCityEnabled=Y&OrganizeCity=" + m.OrganizeCity + "&ExtCondition=\"MCS_SYS.dbo.UF_Spilt(CM_Client.ExtPropertys,~|~,7) IN (1,2)\"";
        }

        MCSSelectControl select_Supplier2 = (MCSSelectControl)pl_detail.FindControl("CM_Client_Supplier2");

        if (select_Supplier2 != null)
        {
            select_Supplier2.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType=2&OrganizeCityEnabled=Y&OrganizeCity=" + m.OrganizeCity + "&ExtCondition=\"MCS_SYS.dbo.UF_Spilt(CM_Client.ExtPropertys,~|~,7) IN (1,2)\"";
        }

        if (m.ApproveFlag == 1)
        {
            //已审核
            TextBox tbx_OpenTime = (TextBox)pl_detail.FindControl("CM_Client_OpenTime");

            if (m.ActiveFlag == 1)
            {
                if (tbx_OpenTime != null && tbx_OpenTime.Text != "")
                {
                    tbx_OpenTime.Enabled = false;
                }
                bt_AddApply.Visible = false;
            }
            else
            {
                TextBox tbx_CloseTime = (TextBox)pl_detail.FindControl("CM_Client_CloseTime");
                if (tbx_CloseTime != null && tbx_CloseTime.Text != "")
                {
                    tbx_CloseTime.Enabled = false;
                }
                bt_RevocationApply.Visible = false;
            }

            Header.Attributes["WebPageSubCode"] = "Modify";
            bt_Approve.Visible = false;
        }
        else
        {
            bt_RevocationApply.Visible = false;
        }

        if (string.IsNullOrEmpty(m["TaskID"]))
        {
            bt_Record.Visible = false;
        }
        else
        {
            if (m["State"] == "2")
            {
                //审批中,不可修改数据
                bt_AddApply.Visible        = false;
                bt_RevocationApply.Visible = false;
                bt_OK.Visible = false;
                bt_RevocationApply.Visible = false;
            }
        }


        #region 绑定该客户的首要联系人
        DropDownList ddl_ChiefLinkMan = pl_detail.FindControl("CM_Client_ChiefLinkMan") != null ? (DropDownList)pl_detail.FindControl("CM_Client_ChiefLinkMan") : null;
        try
        {
            ddl_ChiefLinkMan.DataTextField  = "Name";
            ddl_ChiefLinkMan.DataValueField = "ID";
            ddl_ChiefLinkMan.DataSource     = CM_LinkManBLL.GetModelList("ClientID=" + ViewState["ClientID"].ToString());
            ddl_ChiefLinkMan.DataBind();

            ddl_ChiefLinkMan.Items.Insert(0, new ListItem("请选择", "0"));
            ddl_ChiefLinkMan.SelectedValue = m.ChiefLinkMan.ToString();
        }
        catch { }

        #endregion

        BindGrid();
        //MessageBox.Show(this, Session["UserID"].ToString());
        bt_ReplaceClientManager.OnClientClick = "javascript:PopReplaceClientManager(" + m.ClientManager.ToString() + "," + m.ClientType.ToString() + ")";

        //管理员登录状况下  雅慧电商的流通店  数据有误发出警报
        if (Session["UserID"].ToString() == "1" && m["RTChannel"] != "20" && m["RTClassify"] == "1" &&
            (m["IsRMSClient"] != "2" || m["RMSAccountEnabled"] != "2"))
        {
            MessageBox.Show(this, "非雅慧电商的流通店积分店状态(" + m["IsRMSClient"] + ")或积分账户启用否(" + m["RMSAccountEnabled"] + ")数据有误");
        }
    }
Exemplo n.º 10
0
    /// <summary>
    /// 创建客户对账单
    /// </summary>
    /// <param name="document"></param>
    /// <param name="client"></param>
    /// <param name="documentDate"></param>
    /// <param name="year"></param>
    /// <param name="month"></param>
    /// <returns></returns>
    private Document ReceiveBillPDF(Document document, CM_Client client, string documentDate, DateTime dateBegin, DateTime dateEnd)
    {
        if (!document.IsOpen())
        {
            return(null);
        }
        document = this.GetDocumentHeader(document, "客户对账单", documentDate, client);
        document.Add(Chunk.NEWLINE);

        string procName = "KD.AIS20140109134912.dbo.STKD_ARREPORT_CXCAI";//应收账款存储过程名

        DataTable dt = new DataTable();

        while (DateTime.Compare(dateBegin, dateEnd) <= 0)
        {
            //文档期间项
            int       year   = dateBegin.Year;
            int       month  = dateBegin.Month;
            DataTable dtTemp = new CM_ClientBLL().GetStatement(procName, year, month, client.Code);
            dt.Merge(dtTemp);

            dateBegin = dateBegin.AddMonths(1);
        }


        //DataColumn col = new DataColumn("dateStr");
        //col.DefaultValue = ViewState["dateStr"].ToString();
        //dt.Columns.Add(col);
        //dt.Columns["dateStr"].SetOrdinal(0);

        List <string> tableHeaders = new List <string>(5);

        tableHeaders.Add("单据日期");
        tableHeaders.Add("单据类型");
        tableHeaders.Add("单据编号");
        tableHeaders.Add("摘要");
        tableHeaders.Add("本期应收");
        tableHeaders.Add("本期实收");
        tableHeaders.Add("期末余额");
        for (int i = 0; i < dt.Columns.Count; i++)
        {
            dt.Columns[i].ColumnName = tableHeaders[i];
        }

        PdfPTable ptable = TableToPDFTable(dt);

        float[] widths = new float[] { 1f, 1.5f, 1f, 2f, 1f, 1f, 1f };
        ptable.SetWidths(widths);

        Paragraph paragraph = new Paragraph();

        paragraph.Add(ptable);
        paragraph.Alignment = Element.PTABLE;
        document.Add(paragraph);

        document.Add(Chunk.NEWLINE);

        this.GetDocumentSign(document);

        return(document);
    }
Exemplo n.º 11
0
    /// <summary>
    /// 获取单据头
    /// </summary>
    /// <param name="document"></param>
    /// <param name="documentTitle"></param>
    /// <param name="documentDate"></param>
    /// <param name="client"></param>
    /// <returns></returns>
    public Document GetDocumentHeader(Document document, string documentTitle, string documentDate, CM_Client client)
    {
        Font font = GetPdfFont();

        Paragraph paragraph = null;

        paragraph           = new Paragraph(documentTitle, new Font(GetPdfBaseFont(), 16));
        paragraph.Alignment = iTextSharp.text.Element.TITLE;
        document.Add(paragraph);

        paragraph.Clear();
        paragraph.Font = GetPdfFont();

        string str1 = "经销商:";

        str1 += client == null || string.IsNullOrEmpty(client.Code) ? string.Empty : " [" + client.Code + "] " + client.FullName;
        str1 += "           期间项:" + documentDate;
        Chunk chunk1 = new Chunk(str1, font);

        paragraph.Add(chunk1);
        paragraph.Alignment = Element.ALIGN_LEFT;
        document.Add(paragraph);

        paragraph.Clear();

        string str2 = "打印时间:" + DateTime.Now.ToString("yyyy-MM-dd") + "                           币别:人民币";

        paragraph.Add(new Chunk(str2, font));
        document.Add(paragraph);

        return(document);
    }