Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public decimal Add(Model.standard_price model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into td_standard_price(");
            strSql.Append("good_id,standard_ids,standards,standard_value_ids,standard_values,market_price,sell_price,stock_quantity,add_time,action_price,user_price,good_no");
            strSql.Append(") values (");
            strSql.Append("@good_id,@standard_ids,@standards,@standard_value_ids,@standard_values,@market_price,@sell_price,@stock_quantity,@add_time,@action_price,@user_price,@good_no");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@good_id",            SqlDbType.Int,         4),
                new SqlParameter("@standard_ids",       SqlDbType.VarChar,   100),
                new SqlParameter("@standards",          SqlDbType.NVarChar,  200),
                new SqlParameter("@standard_value_ids", SqlDbType.VarChar,   200),
                new SqlParameter("@standard_values",    SqlDbType.NVarChar,  300),
                new SqlParameter("@market_price",       SqlDbType.Decimal,     9),
                new SqlParameter("@sell_price",         SqlDbType.Decimal,     9),
                new SqlParameter("@stock_quantity",     SqlDbType.Int,         4),
                new SqlParameter("@add_time",           SqlDbType.DateTime),
                new SqlParameter("@action_price",       SqlDbType.Decimal,     9),
                new SqlParameter("@user_price",         SqlDbType.Decimal,     9),
                new SqlParameter("@good_no",            SqlDbType.NVarChar, 100)
            };

            parameters[0].Value  = model.good_id;
            parameters[1].Value  = model.standard_ids;
            parameters[2].Value  = model.standards;
            parameters[3].Value  = model.standard_value_ids;
            parameters[4].Value  = model.standard_values;
            parameters[5].Value  = model.market_price;
            parameters[6].Value  = model.sell_price;
            parameters[7].Value  = model.stock_quantity;
            parameters[8].Value  = model.add_time;
            parameters[9].Value  = model.action_price;
            parameters[10].Value = model.user_price;
            parameters[11].Value = model.good_no;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToDecimal(obj));
            }
        }
Пример #2
0
        protected DataTable dt_other_goods     = new DataTable(); //其他商品表

        /// <summary>
        /// 重写虚方法,此方法将在Init事件前执行
        /// </summary>
        protected override void ShowPage()
        {
            id   = DTRequest.GetQueryInt("id");
            page = DTRequest.GetQueryString("page");
            BLL.article bll = new BLL.article();

            if (id > 0) //如果ID获取到,将使用ID
            {
                if (!bll.Exists(id))
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!")));
                    return;
                }
                model = bll.GetModel(id);
            }
            else if (!string.IsNullOrEmpty(page)) //否则检查设置的别名
            {
                if (!bll.Exists(page))
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!")));
                    return;
                }
                model = bll.GetModel(page);
            }
            else
            {
                return;
            }
            //跳转URL
            if (model.link_url != null)
            {
                model.link_url = model.link_url.Trim();
            }
            if (!string.IsNullOrEmpty(model.link_url))
            {
                HttpContext.Current.Response.Redirect(model.link_url);
            }


            //销量
            DataTable dt_order_good_count = new BLL.orders().get_order_good_count(id).Tables[0];

            if (dt_order_good_count != null && dt_order_good_count.Rows.Count > 0)
            {
                order_sum = Convert.ToDecimal(dt_order_good_count.Rows[0]["quantity"]);
            }
            Model.article_category model_category = new BLL.article_category().GetModel(model.category_id);
            #region
            //规格表
            BLL.standard_price bll_standard_price = new BLL.standard_price();
            DataTable          dt_standard_price  = bll_standard_price.GetList("good_id=" + id).Tables[0];
            if (dt_standard_price != null && dt_standard_price.Rows.Count > 0)
            {
                BLL.standard bll_standard = new BLL.standard();

                if (model_category != null)
                {
                    DataTable dt_old_standard = bll_standard.GetList("'" + model_category.class_list + "' like '%,'+convert(nvarchar(10),category_id)+',%'").Tables[0];

                    dt_standard.Columns.Add("id", typeof(int));
                    dt_standard.Columns.Add("title", typeof(string));
                    dt_standard.Columns.Add("value", typeof(string));
                    dt_standard.PrimaryKey = new DataColumn[] { dt_standard.Columns["id"] };

                    foreach (DataRow dr in dt_old_standard.Rows)
                    {
                        //if(Convert.ToInt32(dr[""]))
                        DataRow new_dr = dt_standard.NewRow();
                        new_dr["id"]    = dr["id"];
                        new_dr["title"] = dr["title"];
                        DataTable dt_standard_value = new BLL.standard_value().GetList("standard_id=" + dr["id"].ToString()).Tables[0];
                        if (dt_standard_value != null || dt_standard_value.Rows.Count > 0)
                        {
                            string str_value = "";
                            foreach (DataRow dr_value in dt_standard_value.Rows)
                            {
                                str_value += dr_value["id"].ToString() + "|" + dr_value["value"].ToString() + ",";
                            }
                            new_dr["value"] = str_value.TrimEnd(',');
                            dt_standard.Rows.Add(new_dr);
                        }
                    }
                }
            }
            #endregion

            //单位表
            BLL.unit bll_unit = new BLL.unit();
            dt_unit = bll_unit.GetList("good_id=" + id).Tables[0];


            //套餐()
            BLL.meal_good bll_meal_good = new BLL.meal_good();
            BLL.meal      bll_meal      = new BLL.meal();
            dt_meal = bll_meal.GetMealByGood(id, "jiejuefangan").Tables[0];

            dt_meal.TableName = "dt_meal";
            if (dt_meal != null && dt_meal.Rows.Count > 0)
            {
                //套餐商品
                DataTable old_dt_meal_good = bll_meal_good.GetList("meal_id=" + dt_meal.Rows[0]["id"].ToString()).Tables[0];
                dt_meal_good = new DataTable();
                dt_meal_good.Columns.Add("meal_id");
                dt_meal_good.Columns.Add("good_standard_price");
                dt_meal_good.Columns.Add("title");
                dt_meal_good.Columns.Add("all_title");
                dt_meal_good.Columns.Add("img_url");
                dt_meal_good.Columns.Add("good_id");
                dt_meal_good.Columns.Add("price");
                string str_meal_good_ids = ",";
                if (old_dt_meal_good != null && old_dt_meal_good.Rows.Count > 0)
                {
                    foreach (DataRow dr in old_dt_meal_good.Rows)
                    {
                        if (str_meal_good_ids.IndexOf("," + dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ",") > -1)
                        {
                            continue;
                        }
                        str_meal_good_ids += dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ",";
                        Model.article modelt = bll.GetModel(Convert.ToInt32(dr["good_id"]));
                        if (modelt != null)
                        {
                            Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dr["standard_price_id"]));
                            string str_standard_price = "";
                            string str_unit           = "";
                            if (model_standard_price != null)
                            {
                                for (int i = 0; i < model_standard_price.standards.Split(',').Length; i++)
                                {
                                    if (!string.IsNullOrEmpty(model_standard_price.standards.Split(',')[i]))
                                    {
                                        str_standard_price += model_standard_price.standards.Split(',')[i];
                                        if (i < model_standard_price.standard_values.Split(',').Length)
                                        {
                                            str_standard_price += ":" + model_standard_price.standard_values.Split(',')[i];
                                        }
                                    }
                                }
                            }

                            Model.unit model_unit = bll_unit.GetModel(Convert.ToDecimal(dr["unit_id"]));
                            if (model_unit != null)
                            {
                                str_unit += "单位:" + model_unit.title + (string.IsNullOrEmpty(model_unit.content) ? "" : model_unit.content);
                            }


                            DataRow new_dr = dt_meal_good.NewRow();
                            new_dr["meal_id"]             = dr["meal_id"];
                            new_dr["title"]               = Utils.CutString(modelt.title, 10);
                            new_dr["good_standard_price"] = dr["good_id"].ToString() + dr["standard_price_id"].ToString();
                            new_dr["all_title"]           = modelt.title + " " + str_standard_price + str_unit;
                            new_dr["img_url"]             = modelt.img_url;
                            new_dr["price"]               = dr["sell_price"];
                            new_dr["good_id"]             = dr["good_id"];

                            dt_meal_good.Rows.Add(new_dr);
                        }
                    }
                    dt_meal_good.TableName = "dt_meal_good";
                }
            }


            //属性表
            BLL.property_good  bll_property_good  = new BLL.property_good();
            BLL.property       bll_property       = new BLL.property();
            BLL.property_value bll_property_value = new BLL.property_value();

            DataTable dt_old_property = bll_property_good.GetList("good_id=" + id).Tables[0];
            dt_property.Columns.Add("id");
            dt_property.Columns.Add("title");
            dt_property.Columns.Add("value");
            dt_property.PrimaryKey = new DataColumn[] { dt_property.Columns["id"] };

            foreach (DataRow dr in dt_old_property.Rows)
            {
                Model.property       model_property       = bll_property.GetModel(Convert.ToInt32(dr["property_id"]));
                Model.property_value model_property_value = bll_property_value.GetModel(Convert.ToDecimal(dr["property_value_id"]));
                if (model != null && model_property_value != null)
                {
                    if (dt_property.Rows.Find(dr["property_id"]) != null)
                    {
                        dt_property.Rows.Find(dr["property_id"])["value"] = dt_property.Rows.Find(dr["property_id"])["value"].ToString() + "," + model_property_value.value;
                    }
                    else
                    {
                        DataRow new_dr = dt_property.NewRow();
                        new_dr["id"]    = dr["property_id"];
                        new_dr["title"] = model_property.title;
                        new_dr["value"] = model_property_value.value;
                        dt_property.Rows.Add(new_dr);
                    }
                }
            }


            //标签
            BLL.tag_good bll_tag_good = new BLL.tag_good();
            DataTable    dt_tag_good  = bll_tag_good.GetList("good_id=" + id).Tables[0];
            dt_tag.Columns.Add("title");
            foreach (DataRow dr in dt_tag_good.Rows)
            {
                Model.tag model_tag = new BLL.tag().GetModel(Convert.ToInt32(dr["tag_id"]));
                if (model_tag != null)
                {
                    DataRow new_dr = dt_tag.NewRow();
                    new_dr["title"] = model_tag.title;
                    dt_tag.Rows.Add(new_dr);
                }
            }


            //推荐搭配
            dt_red = bll_meal.GetMealByGood(id, "tuijiandapei").Tables[0];

            dt_red.TableName = "dt_red";
            if (dt_red != null && dt_red.Rows.Count > 0)
            {
                DataTable old_dt_red_good = bll_meal_good.GetList("meal_id=" + dt_red.Rows[0]["id"].ToString()).Tables[0];


                dt_red_good = new DataTable();
                dt_red_good.Columns.Add("meal_id");
                dt_red_good.Columns.Add("good_standard_price");
                dt_red_good.Columns.Add("title");
                dt_red_good.Columns.Add("all_title");
                dt_red_good.Columns.Add("good_id");
                dt_red_good.Columns.Add("img_url");
                dt_red_good.Columns.Add("price");
                string str_red_good_ids = ",";
                if (old_dt_red_good != null && old_dt_red_good.Rows.Count > 0)
                {
                    foreach (DataRow dr in old_dt_red_good.Rows)
                    {
                        if (str_red_good_ids.IndexOf("," + dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ",") > -1)
                        {
                            continue;
                        }
                        str_red_good_ids += dr["good_id"].ToString() + "_" + dr["standard_price_id"].ToString() + ",";
                        Model.article modelt = bll.GetModel(Convert.ToInt32(dr["good_id"]));
                        if (modelt != null)
                        {
                            Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dr["standard_price_id"]));
                            string str_standard_price = "";
                            string str_unit           = "";
                            if (model_standard_price != null)
                            {
                                for (int i = 0; i < model_standard_price.standards.Split(',').Length; i++)
                                {
                                    if (!string.IsNullOrEmpty(model_standard_price.standards.Split(',')[i]))
                                    {
                                        str_standard_price += model_standard_price.standards.Split(',')[i];
                                        if (i < model_standard_price.standard_values.Split(',').Length)
                                        {
                                            str_standard_price += ":" + model_standard_price.standard_values.Split(',')[i];
                                        }
                                    }
                                }
                            }

                            Model.unit model_unit = bll_unit.GetModel(Convert.ToDecimal(dr["unit_id"]));
                            if (model_unit != null)
                            {
                                str_unit += "单位:" + model_unit.title + (string.IsNullOrEmpty(model_unit.content) ? "" : model_unit.content);
                            }


                            DataRow new_dr = dt_red_good.NewRow();
                            new_dr["meal_id"]             = dr["meal_id"];
                            new_dr["title"]               = Utils.CutString(modelt.title, 10);
                            new_dr["good_standard_price"] = dr["good_id"].ToString() + dr["standard_price_id"].ToString();
                            new_dr["all_title"]           = modelt.title + " " + str_standard_price + str_unit;
                            new_dr["img_url"]             = modelt.img_url;
                            new_dr["price"]               = dr["sell_price"];
                            new_dr["good_id"]             = dr["good_id"];

                            dt_red_good.Rows.Add(new_dr);
                        }
                    }
                    dt_red_good.TableName = "dt_red_good";
                }
            }

            //类别相关
            if (model_category != null)
            {
                if (new BLL.article_category().GetModel(model_category.parent_id) != null)
                {
                    parent_category_title = new BLL.article_category().GetModel(model_category.parent_id).title;
                    dt_category           = new BLL.article_category().GetList(model_category.parent_id, "goods");
                }
                dt_other_goods = bll.get_order_buy_good(5, model_category.id).Tables[0];
            }
        }
Пример #3
0
        private bool DoEdit(int _id)
        {
            bool result = false;
            BLL.article bll = new BLL.article();
            Model.article model = bll.GetModel(_id);

            decimal sell_price = 0;
            decimal standard_price = 0;
            decimal standard_group_price = 0;
            decimal action_price = 0;

            model.channel_id = this.channel_id;
            model.category_id = Utils.StrToInt(ddlCategoryId.SelectedValue, 0);
            model.call_index = txtCallIndex.Text.Trim();
            model.title = txtTitle.Text.Trim();
            model.link_url = txtLinkUrl.Text.Trim();
            model.img_url = txtImgUrl.Text;
            model.seo_title = txtSeoTitle.Text.Trim();
            model.seo_keywords = txtSeoKeywords.Text.Trim();
            model.seo_description = txtSeoDescription.Text.Trim();
            //内容摘要提取内容前255个字符
            if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim()))
            {
                model.zhaiyao = Utils.DropHTML(txtContent.Value, 255);
            }
            else
            {
                model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 255);
            }
            model.content = txtContent.Value;
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            model.click = int.Parse(txtClick.Text.Trim());
            model.status = Utils.StrToInt(rblStatus.SelectedValue, 0);
            model.is_msg = 0;
            model.is_top = 0;
            model.is_red = 0;
            model.is_hot = 0;
            model.is_slide = 0;
            model.is_put = 1;
            if (isPut.Items[0].Selected)
            {
                model.is_put = 0;
            }
            if (cblItem.Items[0].Selected == true)
            {
                model.is_msg = 1;
            }
            if (cblItem.Items[1].Selected == true)
            {
                model.is_top = 1;
            }
            if (cblItem.Items[2].Selected == true)
            {
                model.is_red = 1;
            }
            if (cblItem.Items[3].Selected == true)
            {
                model.is_hot = 1;
            }
            if (cblItem.Items[4].Selected == true)
            {
                model.is_slide = 1;
            }
            model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim());
            model.update_time = DateTime.Now;
            model.fields = SetFieldValues(this.channel_id); //扩展字段赋值
            sell_price = Convert.ToDecimal(model.fields["sell_price"]);

            #region 保存相册====================
            //检查是否有自定义图片
            if (txtImgUrl.Text.Trim() == "")
            {
                model.img_url = hidFocusPhoto.Value;
            }
            if (model.albums != null)
            {
                model.albums.Clear();
            }
            string[] albumArr = Request.Form.GetValues("hid_photo_name");
            string[] remarkArr = Request.Form.GetValues("hid_photo_remark");
            if (albumArr != null)
            {
                List<Model.article_albums> ls = new List<Model.article_albums>();
                for (int i = 0; i < albumArr.Length; i++)
                {
                    string[] imgArr = albumArr[i].Split('|');
                    int img_id = Utils.StrToInt(imgArr[0], 0);
                    if (imgArr.Length == 3)
                    {
                        if (!string.IsNullOrEmpty(remarkArr[i]))
                        {
                            ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2], remark = remarkArr[i] });
                        }
                        else
                        {
                            ls.Add(new Model.article_albums { id = img_id, article_id = _id, original_path = imgArr[1], thumb_path = imgArr[2] });
                        }
                    }
                }
                model.albums = ls;
            }
            #endregion

            #region 保存附件====================
            if (model.attach != null)
            {
                model.attach.Clear();
            }
            string[] attachIdArr = Request.Form.GetValues("hid_attach_id");
            string[] attachFileNameArr = Request.Form.GetValues("hid_attach_filename");
            string[] attachFilePathArr = Request.Form.GetValues("hid_attach_filepath");
            string[] attachFileSizeArr = Request.Form.GetValues("hid_attach_filesize");
            string[] attachPointArr = Request.Form.GetValues("txt_attach_point");
            if (attachIdArr != null && attachFileNameArr != null && attachFilePathArr != null && attachFileSizeArr != null && attachPointArr != null
                && attachIdArr.Length > 0 && attachFileNameArr.Length > 0 && attachFilePathArr.Length > 0 && attachFileSizeArr.Length > 0 && attachPointArr.Length > 0)
            {
                List<Model.article_attach> ls = new List<Model.article_attach>();
                for (int i = 0; i < attachFileNameArr.Length; i++)
                {
                    int attachId = Utils.StrToInt(attachIdArr[i], 0);
                    int fileSize = Utils.StrToInt(attachFileSizeArr[i], 0);
                    string fileExt = Utils.GetFileExt(attachFilePathArr[i]);
                    int _point = Utils.StrToInt(attachPointArr[i], 0);
                    ls.Add(new Model.article_attach { id = attachId, article_id = _id, file_name = attachFileNameArr[i], file_path = attachFilePathArr[i], file_size = fileSize, file_ext = fileExt, point = _point, });
                }
                model.attach = ls;
            }
            #endregion

            #region 保存会员组价格==============
            List<Model.user_group_price> priceList = new List<Model.user_group_price>();
            for (int i = 0; i < rptPrice.Items.Count; i++)
            {
                int hidPriceId = 0;
                if (!string.IsNullOrEmpty(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value))
                {
                    hidPriceId = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hidePriceId")).Value);
                }
                int hidGroupId = Convert.ToInt32(((HiddenField)rptPrice.Items[i].FindControl("hideGroupId")).Value);
                decimal _price = Convert.ToDecimal(((TextBox)rptPrice.Items[i].FindControl("txtGroupPrice")).Text.Trim());
                priceList.Add(new Model.user_group_price { id = hidPriceId, article_id = _id, group_id = hidGroupId, price = _price });
            }
            model.group_price = priceList;
            #endregion

            if (bll.Update(model))
            {
                #region  商品相关

                if (channel_name == "goods")
                {
                    //规格价格
                    BLL.standard_price bll_price = new BLL.standard_price();
                    DataTable dt = bll_price.GetList(0, "good_id=" + _id, "id asc").Tables[0];
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        if (!bll_price.Delete("good_id=" + _id))
                        {
                            JscriptMsg("价格信息清除失败!", "", "Error");
                            return false;
                        }
                    }
                    string standard_ids = DTRequest.GetFormString("ck_standard");
                    string standard_value_ids = DTRequest.GetFormString("ck_standard_value");

                    string str_standards = "";
                    BLL.standard bll_standard = new BLL.standard();
                    string[] str_standard_arr = standard_ids.Split(',');
                    foreach (string str in str_standard_arr)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            Model.standard model_standard = bll_standard.GetModel(Convert.ToInt32(str));
                            if (model_standard != null)
                            {
                                str_standards += model_standard.title + ",";
                            }
                        }
                    }

                    BLL.standard_value bll_value = new BLL.standard_value();
                    string[] str_standard_value_arr = standard_value_ids.Split(',');

                    BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price();
                    DataTable dt_standard_group_price = bll_standard_group_price.GetList("good_id=" + _id).Tables[0];
                    if (dt_standard_group_price != null && dt_standard_group_price.Rows.Count > 0)
                    {
                        if (!bll_standard_group_price.Delete(_id))
                        {
                            JscriptMsg("清除商品规格会员价格失败!", "", "Error");
                            return false;
                        }
                    }

                    foreach (string str in str_standard_value_arr)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            string str_title = "";
                            string[] str_arr = str.Split('_');
                            foreach (string s in str_arr)
                            {
                                if (!string.IsNullOrEmpty(s))
                                {
                                    Model.standard_value model_value = bll_value.GetModel(Convert.ToInt32(s));
                                    if (model_value != null)
                                    {
                                        str_title += model_value.value + ",";
                                    }
                                }
                            }

                            Model.standard_price model_price = new Model.standard_price();

                            model_price.good_id = _id;
                            model_price.standard_ids = standard_ids;
                            model_price.good_no = DTRequest.GetFormString("good_no_" + str);
                            model_price.standards = str_standards.Substring(0, str_standards.Length - 1);
                            model_price.standard_value_ids = str.Replace('_', ',');
                            model_price.standard_values = str_title.Substring(0, str_title.Length - 1);
                            model_price.stock_quantity = DTRequest.GetFormInt("stock_quantity_" + str, 0);
                            model_price.market_price = DTRequest.GetFormDecimal("market_price_" + str, 0);
                            model_price.sell_price=sell_price=standard_price = DTRequest.GetFormDecimal("sell_price_" + str, 0);
                            model_price.action_price=action_price = DTRequest.GetFormDecimal("action_price_" + str, 0);
                            model_price.user_price = DTRequest.GetFormDecimal("user_price_" + str, 0);
                            model_price.add_time = DateTime.Now;

                            decimal _standard_price_id = bll_price.Add(model_price);
                            if (_standard_price_id <= 0)
                            {
                                JscriptMsg("更新价格信息失败!", "", "Error");
                                return false;
                            }

                            //规格会员组价格

                            BLL.user_groups bll_user_group = new BLL.user_groups();

                            DataTable dt_user_group = bll_user_group.GetList(0, "", "grade asc,id desc").Tables[0];
                            foreach (DataRow dr_user_group in dt_user_group.Rows)
                            {
                                Model.standard_group_price model_standard_group_price = new Model.standard_group_price();
                                model_standard_group_price.good_id = _id;
                                model_standard_group_price.group_id = Convert.ToInt32(dr_user_group["id"]);
                                model_standard_group_price.standard_price_id = _standard_price_id;
                                model_standard_group_price.group_price=standard_group_price = DTRequest.GetFormDecimal("user_price_" + dr_user_group["id"] + "_" + str, 0);
                                model_standard_group_price.add_time = DateTime.Now;
                                if (bll_standard_group_price.Add(model_standard_group_price) <= 0)
                                {
                                    JscriptMsg("规格会员价格更新失败!", "", "Error");
                                    return false;
                                }
                            }
                        }
                    }
                    //BLL.meal_good bll_meal_good = new BLL.meal_good();
                    //if (!bll_meal_good.UpdateMealGoodPrice(_id, sell_price, standard_price, standard_group_price, action_price))
                    //{
                    //    JscriptMsg("套餐商品价格更新失败!", "", "Error");
                    //    return false;
                    //}
                    //单位

                    BLL.unit bll_unit = new BLL.unit();
                    bll_unit.Delete(_id);
                    string str_unit = DTRequest.GetFormString("ck_unit");
                    if (!string.IsNullOrEmpty(str_unit))
                    {

                        string[] arr_unit = str_unit.Split(',');
                        foreach (string s_unit in arr_unit)
                        {
                            if (!string.IsNullOrEmpty(s_unit))
                            {
                                string[] unit = s_unit.Split('_');
                                Model.unit model_unit = new Model.unit();
                                model_unit.good_id = _id;
                                model_unit.title = unit[0];
                                model_unit.quantity = Convert.ToInt32(unit[1]);
                                model_unit.rate = Convert.ToDecimal(unit[2]);
                                model_unit.content = unit[3];
                                model_unit.add_time = DateTime.Now;

                                if (bll_unit.Add(model_unit) <= 0)
                                {
                                    JscriptMsg("更新单位失败!", "", "Error");
                                    return false;
                                }
                            }
                        }
                    }

                    //别名

                    BLL.alias_good bll_alias_good = new BLL.alias_good();
                    //删除
                    bll_alias_good.Delete(_id);

                    for (int i = 0; i < ck_alias.Items.Count; i++)
                    {
                        if (ck_alias.Items[i].Selected)
                        {
                            Model.alias_good model_alias_good = new Model.alias_good();
                            model_alias_good.alias_id = Convert.ToInt32(ck_alias.Items[i].Value);
                            model_alias_good.good_id = _id;

                            bll_alias_good.Add(model_alias_good);
                        }
                    }

                    //属性

                    BLL.property_value bll_property_value = new BLL.property_value();
                    BLL.property_good bll_property_good = new BLL.property_good();

                    bll_property_good.Delete(_id);

                    string str_property_value = DTRequest.GetFormString("ck_property_value");
                    if (!string.IsNullOrEmpty(str_property_value))
                    {
                        string[] arr_property_value = str_property_value.Split(',');
                        foreach (string str_1 in arr_property_value)
                        {
                            Model.property_good model_property_good = new Model.property_good();
                            model_property_good.good_id = _id;
                            model_property_good.property_value_id = Convert.ToInt32(str_1);
                            Model.property_value model_property_value = bll_property_value.GetModel(Convert.ToInt32(str_1));
                            if (model_property_value != null)
                            {
                                model_property_good.property_id = model_property_value.property_id;
                            }

                            bll_property_good.Add(model_property_good);
                        }
                    }

                    //标签
                    BLL.tag_good bll_tag_good = new BLL.tag_good();

                    bll_tag_good.Delete(_id);

                    for (int i = 0; i < ck_tag.Items.Count; i++)
                    {
                        if (ck_tag.Items[i].Selected)
                        {
                            Model.tag_good model_tag_good = new Model.tag_good();
                            model_tag_good.tag_id = Convert.ToInt32(ck_tag.Items[i].Value);
                            model_tag_good.good_id = _id;

                            bll_tag_good.Add(model_tag_good);
                        }
                    }
                }
                #endregion

                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改" + this.channel_name + "频道内容:" + model.title); //记录日志
                result = true;
            }
            return result;
        }
Пример #4
0
        private void ShowInfo(int _id)
        {
            BLL.meal   bll   = new BLL.meal();
            Model.meal model = bll.GetModel(_id);
            ddlCategoryId.SelectedValue = model.category_id.ToString();
            txt_title.Text   = model.title;
            txtImgUrl.Text   = model.img_url;
            txtIndexUrl.Text = model.index_url;
            txtSortId.Text   = model.sort_id.ToString();


            BLL.meal_good bll_meal_good = new BLL.meal_good();
            DataTable     dt_meal_good  = bll_meal_good.GetList("meal_id=" + _id).Tables[0];
            string        str_ck        = "";
            string        str_standard_good_price_ids = ",";

            foreach (DataRow dr in dt_meal_good.Rows)
            {
                if (str_standard_good_price_ids.IndexOf("," + (Convert.ToInt32(dr["meal_id"]) + "-" + Convert.ToInt32(dr["good_id"]) + "-" + Convert.ToDecimal(dr["standard_price_id"]) + "-" + Convert.ToDecimal(dr["unit_id"])) + ",") > -1)
                {
                    continue;
                }
                str_standard_good_price_ids += Convert.ToInt32(dr["meal_id"]) + "-" + Convert.ToInt32(dr["good_id"]) + "-" + Convert.ToDecimal(dr["standard_price_id"]) + "-" + Convert.ToDecimal(dr["unit_id"]) + ",";

                Model.article model_good = new BLL.article().GetModel(Convert.ToInt32(dr["good_id"]));
                if (model_good != null)
                {
                    //单位
                    string     unit         = "";
                    string     str_quantity = ",数量:" + Convert.ToInt32(dr["quantity"]);
                    Model.unit model_unit   = new BLL.unit().GetModel(Convert.ToInt32(dr["unit_id"]));
                    if (model_unit != null)
                    {
                        unit = ",单位:" + model_unit.title;
                        if (!string.IsNullOrEmpty(model_unit.content))
                        {
                            unit += "(" + model_unit.content + ")";
                        }
                    }

                    //规格
                    string               standard             = "";
                    BLL.standard_price   bll_standard_price   = new BLL.standard_price();
                    Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(dr["standard_price_id"]));
                    if (model_standard_price != null)
                    {
                        if (!string.IsNullOrEmpty(model_standard_price.standards))
                        {
                            string[] arr_standard       = model_standard_price.standards.Split(',');
                            string[] arr_standard_value = model_standard_price.standard_values.Split(',');

                            for (int i = 0; i < arr_standard.Length; i++)
                            {
                                standard += arr_standard[i] + ":";
                                if (i < arr_standard_value.Length)
                                {
                                    standard += arr_standard_value[i];
                                }
                                standard += ",";
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(standard))
                    {
                        standard = standard.Substring(0, standard.Length - 1);
                    }

                    str_ck += "<span onclick='ck_goods(this)'>" + model_good.title + str_quantity + unit + " " + standard + "<input type='checkbox' name='ck_good' style='display:none;' value='" + model_good.id + "_" + Convert.ToDecimal(dr["standard_price_id"]) + "_" + Convert.ToInt32(dr["unit_id"]) + "_" + Convert.ToInt32(dr["quantity"]) + "' checked='checked'/></span><br />";
                }
                goods.InnerHtml = str_ck;
            }
        }
Пример #5
0
        private bool DoEdit(int _id)
        {
            string check_good = DTRequest.GetFormString("ck_good");

            if (string.IsNullOrEmpty(check_good))
            {
                JscriptMsg("请选择商品!", "", "Error");
                return(false);
            }

            bool result = false;

            BLL.meal   bll   = new BLL.meal();
            Model.meal model = bll.GetModel(_id);
            model.title       = txt_title.Text.Trim();
            model.img_url     = txtImgUrl.Text.Trim();
            model.category_id = Convert.ToInt32(ddlCategoryId.SelectedValue);
            model.index_url   = txtIndexUrl.Text.Trim();
            model.sort_id     = int.Parse(txtSortId.Text.ToString());

            if (bll.Update(model))
            {
                BLL.standard_price bll_standard_price = new BLL.standard_price();

                BLL.meal_good bll_meal_good = new BLL.meal_good();

                bll_meal_good.Delete(_id);

                string[] arr_str = check_good.Split(',');
                BLL.standard_group_price bll_standard_group_price = new BLL.standard_group_price();

                for (int i = 0; i < arr_str.Length; i++)
                {
                    Model.article model_good = new Model.article();
                    model_good = new BLL.article().GetModel(Convert.ToInt32(arr_str[i].Split('_')[0]));
                    if (model_good != null)
                    {
                        if (!string.IsNullOrEmpty(arr_str[i]))
                        {
                            DataTable dt_standard_group_price = bll_standard_group_price.GetList("good_id=" + arr_str[i].Split('_')[0] + " and standard_price_id=" + arr_str[i].Split('_')[1]).Tables[0];
                            if (dt_standard_group_price != null && dt_standard_group_price.Rows.Count > 0)
                            {
                                //有会员规格价格
                                foreach (DataRow dr_group_price in dt_standard_group_price.Rows)
                                {
                                    Model.meal_good model_meal_good = new Model.meal_good();
                                    model_meal_good.good_id           = Convert.ToInt32(arr_str[i].Split('_')[0]);
                                    model_meal_good.group_id          = Convert.ToInt32(dr_group_price["group_id"]);
                                    model_meal_good.meal_id           = _id;
                                    model_meal_good.standard_price_id = Convert.ToDecimal(arr_str[i].Split('_')[1]);
                                    model_meal_good.unit_id           = Convert.ToInt32(arr_str[i].Split('_')[2]);
                                    model_meal_good.quantity          = Convert.ToInt32(arr_str[i].Split('_')[3]);
                                    model_meal_good.sell_price        = Convert.ToDecimal(model_good.fields["sell_price"]);
                                    model_meal_good.standard_price    = Convert.ToDecimal(model_good.fields["sell_price"]);

                                    Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(arr_str[i].Split('_')[1]));
                                    if (model_standard_price != null)
                                    {
                                        //有库存价格
                                        model_meal_good.standard_price = model_standard_price.sell_price;
                                        model_meal_good.action_price   = model_standard_price.action_price;
                                    }
                                    model_meal_good.standard_group_price = Convert.ToDecimal(dr_group_price["group_price"]);
                                    model_meal_good.add_time             = DateTime.Now;

                                    bll_meal_good.Add(model_meal_good);
                                }
                            }
                            else
                            {
                                if (model_good.group_price.Count > 0)
                                {
                                    foreach (Model.user_group_price model_user_group in model_good.group_price)
                                    {
                                        Model.meal_good model_meal_good = new Model.meal_good();
                                        model_meal_good.good_id           = Convert.ToInt32(arr_str[i].Split('_')[0]);
                                        model_meal_good.group_id          = model_user_group.group_id;
                                        model_meal_good.meal_id           = _id;
                                        model_meal_good.standard_price_id = Convert.ToDecimal(arr_str[i].Split('_')[1]);
                                        model_meal_good.unit_id           = Convert.ToInt32(arr_str[i].Split('_')[2]);
                                        model_meal_good.quantity          = Convert.ToInt32(arr_str[i].Split('_')[3]);
                                        model_meal_good.sell_price        = Convert.ToDecimal(model_good.fields["sell_price"]);
                                        model_meal_good.standard_price    = Convert.ToDecimal(model_good.fields["sell_price"]);

                                        Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(arr_str[i].Split('_')[1]));
                                        if (model_standard_price != null)
                                        {
                                            //有库存价格
                                            model_meal_good.standard_price = model_standard_price.sell_price;
                                            model_meal_good.action_price   = model_standard_price.action_price;
                                        }
                                        model_meal_good.standard_group_price = Convert.ToDecimal(model_user_group.price);
                                        model_meal_good.add_time             = DateTime.Now;
                                        bll_meal_good.Add(model_meal_good);
                                    }
                                }
                                else
                                {
                                    Model.meal_good model_meal_good = new Model.meal_good();
                                    model_meal_good.good_id           = Convert.ToInt32(arr_str[i].Split('_')[0]);
                                    model_meal_good.group_id          = 0;
                                    model_meal_good.meal_id           = _id;
                                    model_meal_good.standard_price_id = Convert.ToDecimal(arr_str[i].Split('_')[1]);
                                    model_meal_good.unit_id           = Convert.ToInt32(arr_str[i].Split('_')[2]);
                                    model_meal_good.quantity          = Convert.ToInt32(arr_str[i].Split('_')[3]);
                                    model_meal_good.sell_price        = Convert.ToDecimal(model_good.fields["sell_price"]);
                                    model_meal_good.standard_price    = Convert.ToDecimal(model_good.fields["sell_price"]);

                                    Model.standard_price model_standard_price = bll_standard_price.GetModel(Convert.ToDecimal(arr_str[i].Split('_')[1]));
                                    if (model_standard_price != null)
                                    {
                                        //有库存价格
                                        model_meal_good.standard_price = model_standard_price.sell_price;
                                        model_meal_good.action_price   = model_standard_price.action_price;
                                    }
                                    model_meal_good.standard_group_price = Convert.ToDecimal(model_good.fields["sell_price"]);
                                    model_meal_good.add_time             = DateTime.Now;
                                    bll_meal_good.Add(model_meal_good);
                                }
                            }
                        }
                    }
                }
                //AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改用户信息:" + model.user_name); //记录日志
                result = true;
            }
            return(result);
        }
Пример #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.standard_price GetModel(decimal id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select id, good_id, standard_ids, standards, standard_value_ids, standard_values, market_price, sell_price, stock_quantity, add_time, action_price, user_price ,good_no ");
            strSql.Append("  from td_standard_price ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Decimal)
            };
            parameters[0].Value = id;

            Model.standard_price model = new Model.standard_price();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = decimal.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["good_id"].ToString() != "")
                {
                    model.good_id = int.Parse(ds.Tables[0].Rows[0]["good_id"].ToString());
                }
                model.standard_ids = ds.Tables[0].Rows[0]["standard_ids"].ToString();
                model.standards = ds.Tables[0].Rows[0]["standards"].ToString();
                model.standard_value_ids = ds.Tables[0].Rows[0]["standard_value_ids"].ToString();
                model.standard_values = ds.Tables[0].Rows[0]["standard_values"].ToString();
                if (ds.Tables[0].Rows[0]["market_price"].ToString() != "")
                {
                    model.market_price = decimal.Parse(ds.Tables[0].Rows[0]["market_price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["sell_price"].ToString() != "")
                {
                    model.sell_price = decimal.Parse(ds.Tables[0].Rows[0]["sell_price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["stock_quantity"].ToString() != "")
                {
                    model.stock_quantity = int.Parse(ds.Tables[0].Rows[0]["stock_quantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["action_price"].ToString() != "")
                {
                    model.action_price = decimal.Parse(ds.Tables[0].Rows[0]["action_price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_price"].ToString() != "")
                {
                    model.user_price = decimal.Parse(ds.Tables[0].Rows[0]["user_price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["good_no"].ToString() != "")
                {
                    model.good_no = "";
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Пример #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.standard_price model)
 {
     return(dal.Update(model));
 }
Пример #8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public decimal Add(Model.standard_price model)
 {
     return(dal.Add(model));
 }
Пример #9
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.standard_price GetModel(decimal id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, good_id, standard_ids, standards, standard_value_ids, standard_values, market_price, sell_price, stock_quantity, add_time, action_price, user_price ,good_no ");
            strSql.Append("  from td_standard_price ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Decimal)
            };
            parameters[0].Value = id;


            Model.standard_price model = new Model.standard_price();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = decimal.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["good_id"].ToString() != "")
                {
                    model.good_id = int.Parse(ds.Tables[0].Rows[0]["good_id"].ToString());
                }
                model.standard_ids       = ds.Tables[0].Rows[0]["standard_ids"].ToString();
                model.standards          = ds.Tables[0].Rows[0]["standards"].ToString();
                model.standard_value_ids = ds.Tables[0].Rows[0]["standard_value_ids"].ToString();
                model.standard_values    = ds.Tables[0].Rows[0]["standard_values"].ToString();
                if (ds.Tables[0].Rows[0]["market_price"].ToString() != "")
                {
                    model.market_price = decimal.Parse(ds.Tables[0].Rows[0]["market_price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["sell_price"].ToString() != "")
                {
                    model.sell_price = decimal.Parse(ds.Tables[0].Rows[0]["sell_price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["stock_quantity"].ToString() != "")
                {
                    model.stock_quantity = int.Parse(ds.Tables[0].Rows[0]["stock_quantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["action_price"].ToString() != "")
                {
                    model.action_price = decimal.Parse(ds.Tables[0].Rows[0]["action_price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_price"].ToString() != "")
                {
                    model.user_price = decimal.Parse(ds.Tables[0].Rows[0]["user_price"].ToString());
                }
                if (ds.Tables[0].Rows[0]["good_no"].ToString() != "")
                {
                    model.good_no = "";
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #10
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.standard_price model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update td_standard_price set ");

            strSql.Append(" good_id = @good_id , ");
            strSql.Append(" standard_ids = @standard_ids , ");
            strSql.Append(" standards = @standards , ");
            strSql.Append(" standard_value_ids = @standard_value_ids , ");
            strSql.Append(" standard_values = @standard_values , ");
            strSql.Append(" market_price = @market_price , ");
            strSql.Append(" sell_price = @sell_price , ");
            strSql.Append(" stock_quantity = @stock_quantity , ");
            strSql.Append(" add_time = @add_time , ");
            strSql.Append(" action_price = @action_price , ");
            strSql.Append(" user_price = @user_price , ");
            strSql.Append(" good_no=@good_no ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",                 SqlDbType.Decimal,     9),
                new SqlParameter("@good_id",            SqlDbType.Int,         4),
                new SqlParameter("@standard_ids",       SqlDbType.VarChar,   100),
                new SqlParameter("@standards",          SqlDbType.NVarChar,  200),
                new SqlParameter("@standard_value_ids", SqlDbType.VarChar,   200),
                new SqlParameter("@standard_values",    SqlDbType.NVarChar,  300),
                new SqlParameter("@market_price",       SqlDbType.Decimal,     9),
                new SqlParameter("@sell_price",         SqlDbType.Decimal,     9),
                new SqlParameter("@stock_quantity",     SqlDbType.Int,         4),
                new SqlParameter("@add_time",           SqlDbType.DateTime),
                new SqlParameter("@action_price",       SqlDbType.Decimal,     9),
                new SqlParameter("@user_price",         SqlDbType.Decimal,     9),
                new SqlParameter("@good_no",            SqlDbType.NVarChar, 100)
            };

            parameters[0].Value  = model.id;
            parameters[1].Value  = model.good_id;
            parameters[2].Value  = model.standard_ids;
            parameters[3].Value  = model.standards;
            parameters[4].Value  = model.standard_value_ids;
            parameters[5].Value  = model.standard_values;
            parameters[6].Value  = model.market_price;
            parameters[7].Value  = model.sell_price;
            parameters[8].Value  = model.stock_quantity;
            parameters[9].Value  = model.add_time;
            parameters[10].Value = model.action_price;
            parameters[11].Value = model.user_price;
            parameters[12].Value = model.good_no;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }