Exemple #1
0
        public static string OperateRecords(string ids, int op)
        {
            string[] array = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            using (BLLProductDetail bll = new BLLProductDetail())
            {
                foreach (string id in array)
                {
                    switch (op)
                    {
                    case 7:
                        if (File.Exists(StringPlus.MapPath(bll.GetSingle(id).ProductPic)))
                        {
                            File.Delete(StringPlus.MapPath(bll.GetSingle(id).ProductPic));
                            if (File.Exists(StringPlus.MapPath(phoneImgUrl(bll.GetSingle(id).ProductPic))))
                            {
                                File.Delete(StringPlus.MapPath(phoneImgUrl(bll.GetSingle(id).ProductPic)));
                            }
                            bll.Delete(id);
                        }
                        else
                        {
                            bll.Delete(id);
                        }
                        break;
                    }
                }

                if (bll.IsFail)
                {
                    return(ExceptionManager.GetErrorMsg(bll.DevNetException));
                }
            }
            return(string.Empty);
        }
        private void ShowPro()
        {
            int IsEnglish = Session["isEnglish"] == null ? 1 : Convert.ToInt32(Session["isEnglish"]);

            string[] fileds = new string[] { "id", "IsEnglish" };
            object[] values = new object[] { id, IsEnglish };
            using (BLLProductDetail BLL = new BLLProductDetail())
            {
                ProductDetail obj = new ProductDetail();
                obj = BLL.GetSingle(fileds, values);
                if (obj != null)
                {
                    lblTitle.Text   = GetStrByByteLength(obj.ProductName, 30, true);
                    lblContent.Text = obj.ProductContent;
                    image.Src       = phoneImgUrl(Convert.ToString(obj.ProductPic));
                    //lblTime.Text = string.Format("{0:D}", obj.AddTime);
                }
            }

            using (BLLCompanyInformationType bll = new BLLCompanyInformationType())
            {
                CompanyInformationType contype = bll.GetSingle(type);
                if (contype != null)
                {
                    Title = contype.CompanyInformationName;
                }
            }
        }
Exemple #3
0
 private void bindinfo()
 {
     if (ddlProType.SelectedValue == "")
     {
         return;
     }
     if (IsHaveSecondType(Convert.ToInt32(ddlProType.SelectedValue)))
     {
         ddlProSecondType.Visible = true;
         SearchProductSecondType search = new SearchProductSecondType();
         search.ProductTypeID = Convert.ToInt32(ddlProType.SelectedValue);
         using (BLLProductSecondType bll = new BLLProductSecondType())
         {
             DataTable dt = bll.GetTable(search);
             if (dt != null)
             {
                 ddlProSecondType.DataSource     = dt;
                 ddlProSecondType.DataTextField  = ProductSecondType.ProductSecondTypeName_FieldName;
                 ddlProSecondType.DataValueField = ProductSecondType.ID_FieldName;
                 ddlProSecondType.DataBind();
                 ddlProSecondType.Items.Insert(0, new ListItem("==请选择类型==", "0"));
             }
         }
     }
     if (id > 0)
     {
         using (BLLProductDetail bll = new BLLProductDetail())
         {
             ProductDetail obj = bll.GetSingle(id);
             if (obj != null)
             {
                 if (obj.IsEnglish == 1)
                 {
                     rbtnIsChinese.Checked = true;
                 }
                 else if (obj.IsEnglish == 2)
                 {
                     rbtnIsEnglish.Checked = true;
                 }
                 txtProName.Text = obj.ProductName;
                 //txtProEngName.Text = obj.ProductEngName;
                 ddlProType.SelectedValue = obj.ProTypeID.ToString();
                 if (IsHaveSecondType(obj.ProTypeID))
                 {
                     ddlProSecondType.SelectedValue = obj.ProSecondTypeID.ToString();
                     ddlProSecondType.Visible       = true;
                 }
                 else
                 {
                     ddlProSecondType.Visible = false;
                 }
                 txtContent.Value = obj.ProductContent;
                 txtAutoSort.Text = obj.AutoSort.ToString();
                 txtRemarks.Text  = obj.Remarks;
                 Image1.ImageUrl  = obj.ProductPic.ToString();
             }
         }
     }
 }
        private void ShowMenu()
        {
            int IsEnglish = Session["isEnglish"] == null ? 1 : Convert.ToInt32(Session["isEnglish"]);

            string[] fileds = new string[] { "id", "IsEnglish" };
            object[] values = new object[] { id, IsEnglish };
            using (BLLProductDetail BLL = new BLLProductDetail())
            {
                ProductDetail obj = new ProductDetail();
                obj = BLL.GetSingle(fileds, values);
                if (obj != null)
                {
                    lblTitle.Text   = obj.ProductName;
                    lblContent.Text = obj.ProductContent;
                    picpro.ImageUrl = obj.ProductPic;
                }
            }
        }
Exemple #5
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            using (BLLProductDetail bll = new BLLProductDetail())
            {
                string        prourlname = "";
                ProductDetail obj        = new ProductDetail();
                if (id > 0)
                {
                    obj    = bll.GetSingle(id);
                    obj.ID = id;
                }
                else
                {
                    obj.IsFlag = 0;
                }
                obj.ProductName = txtProName.Text.ToString();
                //obj.ProductEngName = txtProEngName.Text.ToString();
                obj.ProTypeID = Convert.ToInt32(ddlProType.SelectedValue);
                if (ddlProType.SelectedValue == null || ddlProType.SelectedValue == "0")
                {
                    return;
                }
                if (IsHaveSecondType(Convert.ToInt32(ddlProType.SelectedValue)))
                {
                    obj.ProSecondTypeID = Convert.ToInt32(ddlProSecondType.SelectedValue);
                }
                obj.ProductContent = txtContent.Value;
                obj.AutoSort       = Convert.ToInt32(txtAutoSort.Text.Trim().ToString() == "" ? "0" : txtAutoSort.Text.Trim().ToString());
                obj.Remarks        = txtRemarks.Text.ToString();
                #region   产品图片(前台产品图片来源于此)
                try
                {
                    if (this.UploadImg.HasFile)
                    {
                        string extName = Path.GetExtension(UploadImg.FileName);
                        string virFileFullName;
                        string fileName;

                        WebCommon.GetUploadRandFileName(extName, out virFileFullName, out fileName);
                        #region Add Begin
                        int    ind       = fileName.IndexOf(".");
                        string ofileName = fileName.Substring(0, ind);
                        prourlname = extName;
                        #endregion
                        UploadImg.SaveAs(StringPlus.MapPath(virFileFullName));
                        #region Add Begin
                        HttpFileCollection files = Request.Files;
                        string             path  = Server.MapPath("../../Upload");
                        HttpPostedFile     file  = files[0];
                        if (file != null && file.ContentLength > 0)
                        {
                            if (rbthasPhone.Checked == true)
                            {
                                //string filename = this.UpLoadImage(file, path + "/", Convert.ToInt32(ConfigHelper.GetAppString("CompressionWidth").Trim()), Convert.ToInt32(ConfigHelper.GetAppString("CompressionHeight").Trim()), ofileName);
                                string filename = this.UpLoadImage(file, path + "/", Convert.ToInt32(imgWidth.Text.ToString()), Convert.ToInt32(imgHeight.Text.ToString()), ofileName);
                            }
                        }
                        #endregion
                        if (IsAllowedExtension(StringPlus.MapPath(virFileFullName)))
                        {
                            if (id > 0)
                            {//新增时无需删除
                                string filename = bll.GetSingle(id).ProductPic;
                                if (File.Exists(StringPlus.MapPath(bll.GetSingle(id).ProductPic)))
                                {
                                    File.Delete(StringPlus.MapPath(bll.GetSingle(id).ProductPic));
                                }
                                if (File.Exists(StringPlus.MapPath(bll.GetSingle(id).ProductPic)))
                                {
                                    File.Delete(StringPlus.MapPath(bll.GetSingle(id).ProductPic));
                                }
                            }
                            obj.ProductPic = virFileFullName;
                        }
                        else
                        {
                            if (File.Exists(StringPlus.MapPath(virFileFullName)))
                            {
                                File.Delete(StringPlus.MapPath(virFileFullName));
                            }
                            ShowMsg("请上传正确的图片(.jpg,.gif,.bmp,.png)");
                            return;
                        }
                    }
                    else
                    {
                        obj.ProductPic = Image1.ImageUrl.ToString();
                    }
                }
                catch (DevNetException ex)
                {
                    ExceptionManager.ShowErrorMsg(this, ex);
                    return;
                }
                #endregion
                if (rbtnIsChinese.Checked == true)
                {
                    obj.IsEnglish = 1;
                }
                else if (rbtnIsEnglish.Checked == true)
                {
                    obj.IsEnglish = 2;
                }
                else
                {
                    ShowMsg("请选择语言类别!");
                    return;
                }
                bll.Save(obj);
                if (bll.IsFail)
                {
                    ExceptionManager.ShowErrorMsg(this, bll.DevNetException);
                }
                else
                {
                    JSMsg.ShowWinRedirect(this, "保存成功", "cpProductList.aspx");
                }
            }
        }