Example #1
0
 /// <summary>
 /// 生成产品的二维码
 /// </summary>
 /// <param name="pd"></param>
 /// <returns></returns>
 private string createQrCode(Song.Entities.Product pd, string pathType)
 {
     try
     {
         //二维码图片名称
         string img = "";
         if (pd != null && pd.Pd_QrCode != null && pd.Pd_QrCode != "")
         {
             img = pd.Pd_QrCode;
         }
         else
         {
             img = WeiSha.Common.Request.UniqueID() + ".png";
         }
         //二维码的宽高
         int wh = Business.Do <ISystemPara>()["Product_QrCode_WidthAndHeight"].Int16 ?? 200;
         //二维码模板内容
         string template = Business.Do <ISystemPara>()["Product_QrCode_Template"].String;
         //创建二维码
         Song.Extend.QrCode.Creat4Entity(pd, template, Upload.Get[pathType].Physics + img, wh);
         return(img);
     }
     catch (Exception ex)
     {
         Message.ExceptionShow(ex);
         return(null);
     }
 }
Example #2
0
 /// <summary>
 /// 生成产品的二维码
 /// </summary>
 /// <param name="pd"></param>
 /// <returns></returns>
 private string createQrCode(Song.Entities.Product pd, string pathType, string template, int wh)
 {
     try
     {
         //二维码图片名称
         string img = "";
         if (pd != null && pd.Pd_QrCode != null && pd.Pd_QrCode != "")
         {
             img = pd.Pd_QrCode;
         }
         else
         {
             img          = WeiSha.Common.Request.UniqueID() + ".png";
             pd.Pd_QrCode = img;
             Business.Do <IContents>().ProductSave(pd);
         }
         //创建二维码
         Song.Extend.QrCode.Creat4Entity(pd, template, Upload.Get[pathType].Physics + img, wh);
         return(img);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #3
0
 /// <summary>
 /// 是否推荐
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void sbRec_Click(object sender, EventArgs e)
 {
     try
     {
         StateButton ub    = (StateButton)sender;
         int         index = ((GridViewRow)(ub.Parent.Parent)).RowIndex;
         int         id    = int.Parse(this.GridView1.DataKeys[index].Value.ToString());
         //
         Song.Entities.Product entity = Business.Do <IContents>().ProductSingle(id);
         entity.Pd_IsRec = !entity.Pd_IsRec;
         Business.Do <IContents>().ProductSave(entity);
         BindData(null, null);
     }
     catch (Exception ex)
     {
         Message.ExceptionShow(ex);
     }
 }
Example #4
0
 public void ProductDelete(int identify)
 {
     Song.Entities.Product entity = this.ProductSingle(identify);
     using (DbTrans tran = Gateway.Default.BeginTrans())
     {
         try
         {
             _ProductDelete(entity, tran);
             tran.Commit();
         }
         catch (Exception ex)
         {
             tran.Rollback();
             throw ex;
         }
         finally
         {
             tran.Close();
         }
     }
 }
 /// <summary>
 /// 设置初始产品留言相联的产品信息
 /// </summary>
 /// <param name="message">产品留言的实体</param>
 private void fillProduct(Song.Entities.ProductMessage message)
 {
     Song.Entities.Product p = Business.Do <IContents>().ProductSingle((int)message.Pd_Id);
     if (p == null)
     {
         return;
     }
     //产品名称
     lbName.Text = p.Pd_Name;
     //产品分类
     //lbColumn.Text = p.Ps_Name;
     //型号
     lbModel.Text = p.Pd_Model;
     //编号
     lbCode.Text = p.Pd_Code;
     //是否使用,是否新产品,是否推荐
     lbIsUse.Visible = !p.Pd_IsUse;
     lbIsNew.Visible = p.Pd_IsNew;
     lbIsRec.Visible = p.Pd_IsRec;
     //上市时间
     lbPushTime.Text = ((DateTime)p.Pd_PushTime).ToString("yyyy-MM-dd");
     //图片
     this.imgShow.Src = Upload.Get[_uppath].Virtual + p.Pd_Logo;
     //编辑
     lbAccName.Text = p.Acc_Name;
     //价格
     lbPrise.Text = p.Pd_Prise.ToString();
     //重量
     lbWeight.Text = p.Pd_Weight.ToString();
     //库存
     lbStocks.Text = p.Pd_Stocks.ToString();
     lbUnit.Text   = p.Pd_Unit;
     //简介
     lbIntro.Text = p.Pd_Intro;
     //内容
     lbDetails.Text = p.Pd_Details;
     //关键字
     lbKeywords.Text = p.Pd_KeyWords;
 }
Example #6
0
        /// <summary>
        /// 设置初始界面
        /// </summary>
        private void fill()
        {
            Song.Entities.Product mm;
            if (id != 0)
            {
                mm = Business.Do <IContents>().ProductSingle(id);
                //是否使用,是否新产品,是否推荐
                cbIsUse.Checked = mm.Pd_IsUse;
                cbIsNew.Checked = mm.Pd_IsNew;
                cbIsRec.Checked = mm.Pd_IsRec;
                //上市时间
                tbSaleTime.Text = ((DateTime)mm.Pd_SaleTime).ToString("yyyy-MM-dd");
                //编辑
                tbAccName.Text = mm.Acc_Name;
                //产品分类
                ListItem li = ddlColumn.Items.FindByValue(mm.Col_Id.ToString());
                if (li != null)
                {
                    li.Selected = true;
                }
                //厂家,产地,材质
                ListItem liFact = ddlFactory.Items.FindByValue(mm.Pfact_Id.ToString());
                if (liFact != null)
                {
                    liFact.Selected = true;
                }
                ListItem liOrg = ddlOrigin.Items.FindByValue(mm.Pori_Id.ToString());
                if (liOrg != null)
                {
                    liOrg.Selected = true;
                }
                ListItem liMat = ddlMaterial.Items.FindByValue(mm.Pmat_Id.ToString());
                if (liMat != null)
                {
                    liMat.Selected = true;
                }
                //上线时间
                tbPushTime.Text = mm.Pd_PushTime.ToString();
            }
            else
            {
                //如果是新增
                mm = new Song.Entities.Product();
                EmpAccount acc = Extend.LoginState.Admin.CurrentUser;
                tbAccName.Text = acc.Acc_Name;
                //上市时间
                tbSaleTime.Text = DateTime.Now.ToString("yyyy-MM-dd");
                //分类
                ListItem li = ddlColumn.Items.FindByValue(colid.ToString());
                if (li != null)
                {
                    li.Selected = true;
                }
                //上线时间
                tbPushTime.Text = DateTime.Now.ToString();
            }
            //全局UID
            ViewState["UID"] = string.IsNullOrWhiteSpace(mm.Pd_Uid) ? getUID() : mm.Pd_Uid;
            //产品名称
            tbName.Text = mm.Pd_Name;
            //型号
            tbModel.Text = mm.Pd_Model;
            //编号
            tbCode.Text = mm.Pd_Code;
            //价格
            tbPrise.Text = mm.Pd_Prise.ToString();
            //重量
            tbWeight.Text = mm.Pd_Weight.ToString();
            //库存
            tbStocks.Text = mm.Pd_Stocks.ToString();
            ListItem li1 = ddlUnit.Items.FindByText(mm.Pd_Unit);

            if (li1 != null)
            {
                li1.Selected = true;
            }
            //简介
            tbIntro.Text = mm.Pd_Intro;
            //标签
            tbLabel.Text = mm.Pd_Label;
            //内容
            tbDetails.Text = mm.Pd_Details;

            //发布信息,SEO优化
            tbKeywords.Text = mm.Pd_KeyWords;
            tbDescr.Text    = mm.Pd_Descr;
        }
Example #7
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnEnter_Click(object sender, EventArgs e)
 {
     try
     {
         Song.Entities.Product mm;
         if (id != 0)
         {
             mm = Business.Do <IContents>().ProductSingle(id);
         }
         else
         {
             //如果是新增
             mm            = new Song.Entities.Product();
             mm.Pd_CrtTime = DateTime.Now;
         }
         //产品名称
         mm.Pd_Name = tbName.Text;
         //是否使用,是否新产品,是否推荐
         mm.Pd_IsUse = cbIsUse.Checked;
         mm.Pd_IsNew = cbIsNew.Checked;
         mm.Pd_IsRec = cbIsRec.Checked;
         //产品分类
         mm.Col_Id = Convert.ToInt32(ddlColumn.SelectedValue);
         //型号
         mm.Pd_Model = tbModel.Text.Trim();
         //编号
         mm.Pd_Code = tbCode.Text.Trim();
         //上市时间
         mm.Pd_SaleTime = Convert.ToDateTime(tbSaleTime.Text);
         //厂家,产地,材质
         mm.Pfact_Id = Convert.ToInt32(ddlFactory.SelectedValue);
         mm.Pori_Id  = Convert.ToInt32(ddlOrigin.SelectedValue);
         mm.Pmat_Id  = Convert.ToInt32(ddlMaterial.SelectedValue);
         //价格
         mm.Pd_Prise = Convert.ToSingle(tbPrise.Text.Trim() == "" ? "0" : tbPrise.Text);
         //重量
         mm.Pd_Weight = Convert.ToInt32(tbWeight.Text.Trim());
         //库存
         mm.Pd_Stocks = Convert.ToInt32(tbStocks.Text.Trim());
         mm.Pd_Unit   = ddlUnit.SelectedItem.Text;
         //简介
         mm.Pd_Intro = tbIntro.Text.Trim();
         //内容
         mm.Pd_Details = tbDetails.Text;
         //标签
         mm.Pd_Label = tbLabel.Text.Trim();
         //编辑
         mm.Acc_Name = tbAccName.Text.Trim();
         //发布信息,SEO优化
         mm.Pd_KeyWords = tbKeywords.Text;
         mm.Pd_Descr    = tbDescr.Text;
         mm.Pd_PushTime = tbPushTime.Text.Trim() != "" ? Convert.ToDateTime(tbPushTime.Text) : DateTime.Now;
         //唯一值
         mm.Pd_Uid = this.getUID();
         if (mm.Acc_Name != "")
         {
             EmpAccount acc = Business.Do <IEmployee>().GetSingleByName(mm.Acc_Name);
             if (acc != null)
             {
                 mm.Acc_Name = acc.Acc_Name;
                 mm.Acc_Id   = acc.Acc_Id;
             }
         }
         //生成二维码
         mm.Pd_QrCode = createQrCode(mm, type);
         if (id != 0)
         {
             Business.Do <IContents>().ProductSave(mm);
         }
         else
         {
             //如果是新增
             id = Business.Do <IContents>().ProductAdd(mm);
         }
         Master.AlertCloseAndRefresh("操作成功!");
     }
     catch (Exception ex)
     {
         Message.ExceptionShow(ex);
     }
 }