Example #1
0
        private void FillModel(PN_Notice m)
        {
            if (m == null)
            {
                return;
            }

            ID         = m.ID;
            Topic      = m.Topic;
            KeyWord    = m.KeyWord;
            Content    = m.Content.Replace("/RMS/SubModule/DownloadAttachment.aspx?", MCSFramework.Common.ConfigHelper.GetConfigString("WebSiteURL") + "/DownloadAttachment.aspx?");
            CanComment = m.CanComment.ToUpper() == "Y";
            InsertTime = m.InsertTime;

            Abstract = m["Abstract"];
            if (Abstract == "")
            {
                if (Content.Length > 100)
                {
                    Abstract = Content.Substring(0, 100);
                }
                else
                {
                    Abstract = Content;
                }
            }

            Author = m["Author"];

            #region 替换描述中的图片链接
            Content = Content.Replace("src=\"/Admin/DownloadAttachment.aspx", "src=\"" + ConfigHelper.GetConfigString("WebSiteURL") + "DownloadAttachment.aspx");
            Content = Content.Replace("src=\"/MClub/DownloadAttachment.aspx", "src=\"" + ConfigHelper.GetConfigString("WebSiteURL") + "DownloadAttachment.aspx");
            #endregion

            #region 获取首要图片
            string condition = " RelateType=80 AND RelateID=" + m.ID.ToString() + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',1)='Y'";
            IList <ATMT_Attachment> lists = ATMT_AttachmentBLL.GetModelList(condition);
            if (lists.Count > 0 && ATMT_AttachmentBLL.IsImage(lists[0].ExtName))
            {
                ImageGUID = lists[0].GUID;
            }
            #endregion

            #region 获取附件明细
            Atts = new List <Attachment>();
            IList <ATMT_Attachment> atts = ATMT_AttachmentBLL.GetAttachmentList(80, m.ID, new DateTime(1900, 1, 1), new DateTime(2100, 1, 1));
            foreach (ATMT_Attachment att in atts.OrderBy(p => p.Name))
            {
                Attachment v = new Attachment();
                v.AttName    = att.Name;
                v.ExtName    = att.ExtName;
                v.GUID       = att.GUID;
                v.UploadTime = att.UploadTime;
                v.FileSize   = att.FileSize;
                Atts.Add(v);
            }
            #endregion
        }
    protected void bt_SetFirstPicture_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < lv_list.Items.Count; i++)
        {
            ListViewItem item = lv_list.Items[i];
            if (((CheckBox)item.FindControl("cb_ck")).Checked)
            {
                int id = (int)lv_list.DataKeys[i].Value;

                ATMT_AttachmentBLL bll = new ATMT_AttachmentBLL(id);

                if (IsImage(bll.Model.ExtName))
                {
                    bll.Model["IsFirstPicture"] = "Y";
                    bll.Update();


                    IList <ATMT_Attachment> lists = ATMT_AttachmentBLL.GetAttachmentList(RelateType, RelateID, BeginTime, EndTime, "");
                    foreach (ATMT_Attachment att in lists)
                    {
                        if (att.ID != id && att["IsFirstPicture"] == "Y")
                        {
                            ATMT_AttachmentBLL bll2 = new ATMT_AttachmentBLL(att.ID);
                            bll2.Model["IsFirstPicture"] = "N";
                            bll2.Update();
                        }
                    }
                }
                else
                {
                    MessageBox.Show(this.Page, "对不起,您选中的附件不是图片文件!");
                    return;
                }
                break;
            }
        }
        lv_list.DataBind();
    }
Example #3
0
        private void FillModel(PDT_Product m, int TDP)
        {
            ID            = m.ID;
            FullName      = m.FullName;
            ShortName     = m.ShortName;
            Code          = m.Code;
            BarCode       = m.BarCode;
            BoxBarCode    = m.BoxBarCode;
            ConvertFactor = m.ConvertFactor;
            Spec          = m.Spec;
            Remark        = m.Remark;
            Grade         = m.Grade;
            Category      = m.Category;
            FactoryCode   = m.FactoryCode;
            FactoryName   = m.FactoryName;

            #region 获取商品的TDP扩展管理信息
            if (TDP != 0)
            {
                IList <PDT_ProductExtInfo> exts = PDT_ProductExtInfoBLL.GetModelList("Supplier=" + TDP.ToString() + " AND Product=" + m.ID.ToString());
                if (exts.Count > 0)
                {
                    TDPCode = exts[0].Code;
                    if (exts[0].Category != 0)
                    {
                        Category = exts[0].Category;
                    }
                    BuyPrice   = exts[0].BuyPrice;
                    SalesPrice = exts[0].SalesPrice;
                }
            }
            #endregion

            #region 获取品牌、系列、类别名称
            if (m.Brand > 0)
            {
                PDT_Brand brand = new PDT_BrandBLL(m.Brand).Model;
                if (brand != null)
                {
                    BrandName = brand.Name;
                }
            }
            if (m.Classify > 0)
            {
                PDT_Classify classify = new PDT_ClassifyBLL(m.Classify).Model;
                if (classify != null)
                {
                    ClassifyName = classify.Name;
                }
            }
            if (Category > 0)
            {
                CategoryName = PDT_CategoryBLL.GetFullCategoryName(Category);
            }
            #endregion

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

                if (m.TrafficPackaging > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PDT_Packaging")[m.TrafficPackaging.ToString()];
                    if (dic != null)
                    {
                        TrafficPackagingName = dic.Name;
                    }
                }
                if (m.Packaging > 0)
                {
                    Dictionary_Data dic = DictionaryBLL.GetDicCollections("PDT_Packaging")[m.Packaging.ToString()];
                    if (dic != null)
                    {
                        PackagingName = dic.Name;
                    }
                }
            }
            catch (System.Exception err)
            {
                LogWriter.WriteLog("MCSFramework.WSI.Product", err);
            }
            #endregion

            #region 获取首要图片
            string condition = " RelateType=11 AND RelateID=" + m.ID.ToString() + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',1)='Y'";
            IList <ATMT_Attachment> lists = ATMT_AttachmentBLL.GetModelList(condition);
            if (lists.Count > 0 && ATMT_AttachmentBLL.IsImage(lists[0].ExtName))
            {
                ImageGUID = lists[0].GUID;
            }
            #endregion

            #region 获取附件明细
            Atts = new List <Attachment>();
            IList <ATMT_Attachment> atts = ATMT_AttachmentBLL.GetAttachmentList(11, m.ID, new DateTime(1900, 1, 1), new DateTime(2100, 1, 1));
            foreach (ATMT_Attachment item in atts.OrderBy(p => p.Name))
            {
                Atts.Add(new Attachment(item));
            }
            #endregion
        }
    protected void btn_Add_Click(object sender, EventArgs e)
    {
        try
        {
            if (RelateID == 0)
            {
                MessageBox.Show(this.Page, "请先关联要上传的对象! RelateID can not null!");
                return;
            }

            #region 保存文件
            if (!FileUpload1.HasFile)
            {
                MessageBox.Show(this.Page, "请选择要上传的文件!");
                return;
            }
            int FileSize = (FileUpload1.PostedFile.ContentLength / 1024);

            if (!Roles.IsUserInRole("管理员") && FileSize > ConfigHelper.GetConfigInt("MaxAttachmentSize"))
            {
                MessageBox.Show(this.Page, "上传的文件不能大于" + ConfigHelper.GetConfigInt("MaxAttachmentSize") +
                                "KB!当前上传文件大小为:" + FileSize.ToString() + "KB");
                return;
            }

            //判断文件格式
            string FileName = FileUpload1.PostedFile.FileName;
            FileName = FileName.Substring(FileName.LastIndexOf('\\') + 1);
            FileName = FileName.Substring(0, FileName.LastIndexOf('.'));

            string PicType = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf(".") + 1).ToLowerInvariant();

            byte[] filedata;
            Stream filestream = FileUpload1.PostedFile.InputStream;

            #region 自动压缩上传的图片
            if (cb_AutoCompress.Checked && IsImage(PicType))
            {
                try
                {
                    System.Drawing.Image originalImage = System.Drawing.Image.FromStream(filestream);
                    filestream.Position = 0;

                    int width = originalImage.Width;

                    if (width > 1024 || PicType == "bmp")
                    {
                        if (width > 1024)
                        {
                            width = 1024;
                        }

                        System.Drawing.Image thumbnailimage = ImageProcess.MakeThumbnail(originalImage, width, 0, "W");

                        MemoryStream thumbnailstream = new MemoryStream();
                        thumbnailimage.Save(thumbnailstream, System.Drawing.Imaging.ImageFormat.Jpeg);
                        thumbnailstream.Position = 0;
                        FileSize = (int)(thumbnailstream.Length / 1024);
                        PicType  = "jpg";

                        filestream = thumbnailstream;
                    }
                }
                catch { }
            }
            #endregion

            filedata = new byte[filestream.Length];
            filestream.Read(filedata, 0, (int)filestream.Length);
            filestream.Close();
            #endregion

            ATMT_AttachmentBLL atm = new ATMT_AttachmentBLL();

            atm.Model.RelateType = RelateType;
            atm.Model.RelateID   = RelateID;
            atm.Model.Name       = tbx_Name.Text.Trim() == "" ? FileName : tbx_Name.Text.Trim();
            //atm.Model.Path = SaveFullPath;
            atm.Model.ExtName     = PicType;
            atm.Model.FileSize    = FileSize;
            atm.Model.Description = tbx_Description.Text;
            atm.Model.UploadUser  = Session["UserName"].ToString();
            atm.Model.IsDelete    = "N";

            #region 判断当前关联对象有没有其他图片附件
            if (IsImage(PicType))
            {
                IList <ATMT_Attachment> lists = ATMT_AttachmentBLL.GetAttachmentList(RelateType, RelateID, BeginTime, EndTime, "lower(ExtName) in ('bmp','jpg','gif','png')");

                //如果当前上传的图片是第一张图片,则默认设为首要图片
                if (lists.Count == 0)
                {
                    atm.Model["IsFirstPicture"] = "Y";
                }
            }
            #endregion

            if (atm.Add(filedata) > 0)
            {
                MessageBox.Show(this.Page, "上传成功!");
            }
            else
            {
                MessageBox.Show(this.Page, "上传失败请重新上传!");
            }
            BindGrid();
        }
        catch (System.Exception err)
        {
            MessageBox.Show(this.Page, err.Message);
        }
    }
Example #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
        }