コード例 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.article_company GetCompanyModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 id,channel_id,category_id,title,link_url,img_url,seo_title,seo_keywords,seo_description,content,sort_id,click,is_lock,user_id,add_time,call_index,is_msg,is_red,address,telephone,[user],is_top,remark1,remark2,digg_good,digg_bad,x_lng,y_lat,line,price,sell_price,flight_num,seat_price,begin_date,end_date,entry_port,visa_type,visa_nation,visa_data from view_article_company ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) };
            parameters[0].Value = id;

            Model.article_company model = new Model.article_company();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["channel_id"] != null && ds.Tables[0].Rows[0]["channel_id"].ToString() != "")
                {
                    model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["category_id"] != null && ds.Tables[0].Rows[0]["category_id"].ToString() != "")
                {
                    model.category_id = int.Parse(ds.Tables[0].Rows[0]["category_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["link_url"] != null && ds.Tables[0].Rows[0]["link_url"].ToString() != "")
                {
                    model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString();
                }
                if (ds.Tables[0].Rows[0]["img_url"] != null && ds.Tables[0].Rows[0]["img_url"].ToString() != "")
                {
                    model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_title"] != null && ds.Tables[0].Rows[0]["seo_title"].ToString() != "")
                {
                    model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_keywords"] != null && ds.Tables[0].Rows[0]["seo_keywords"].ToString() != "")
                {
                    model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seo_description"] != null && ds.Tables[0].Rows[0]["seo_description"].ToString() != "")
                {
                    model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString();
                }
                if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "")
                {
                    model.content = ds.Tables[0].Rows[0]["content"].ToString();
                }
                if (ds.Tables[0].Rows[0]["sort_id"] != null && ds.Tables[0].Rows[0]["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["click"] != null && ds.Tables[0].Rows[0]["click"].ToString() != "")
                {
                    model.click = int.Parse(ds.Tables[0].Rows[0]["click"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "")
                {
                    model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"] != null && 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]["call_index"] != null && ds.Tables[0].Rows[0]["call_index"].ToString() != "")
                {
                    model.call_index = ds.Tables[0].Rows[0]["call_index"].ToString();
                }
                if (ds.Tables[0].Rows[0]["is_msg"].ToString() != "")
                {
                    model.is_msg = int.Parse(ds.Tables[0].Rows[0]["is_msg"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_red"].ToString() != "")
                {
                    model.is_red = int.Parse(ds.Tables[0].Rows[0]["is_red"].ToString());
                }

                if (ds.Tables[0].Rows[0]["address"].ToString() != "")
                {
                    model.address = ds.Tables[0].Rows[0]["address"].ToString();
                }
                if (ds.Tables[0].Rows[0]["telephone"].ToString() != "")
                {
                    model.telephone = ds.Tables[0].Rows[0]["telephone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["user"].ToString() != "")
                {
                    model.user = ds.Tables[0].Rows[0]["user"].ToString();
                }
                if (ds.Tables[0].Rows[0]["remark1"].ToString() != "")
                {
                    model.remark1 = ds.Tables[0].Rows[0]["remark1"].ToString();
                }
                if (ds.Tables[0].Rows[0]["is_top"].ToString() != "")
                {
                    model.is_top = int.Parse(ds.Tables[0].Rows[0]["is_top"].ToString());
                }
                if (ds.Tables[0].Rows[0]["remark2"].ToString() != "")
                {
                    model.remark2 = int.Parse(ds.Tables[0].Rows[0]["remark2"].ToString());
                }

                if (ds.Tables[0].Rows[0]["digg_good"].ToString() != "")
                {
                    model.digg_good = int.Parse(ds.Tables[0].Rows[0]["digg_good"].ToString());
                }
                if (ds.Tables[0].Rows[0]["digg_bad"].ToString() != "")
                {
                    model.digg_bad = int.Parse(ds.Tables[0].Rows[0]["digg_bad"].ToString());
                }
                if (ds.Tables[0].Rows[0]["x_lng"].ToString() != "")
                {
                    model.x_lng = ds.Tables[0].Rows[0]["x_lng"].ToString();
                }
                if (ds.Tables[0].Rows[0]["y_lat"].ToString() != "")
                {
                    model.y_lat = ds.Tables[0].Rows[0]["y_lat"].ToString();
                }

                if (ds.Tables[0].Rows[0]["line"].ToString() != "")
                {
                    model.line = ds.Tables[0].Rows[0]["line"].ToString();
                }

                if (ds.Tables[0].Rows[0]["price"].ToString() != "")
                {
                    model.price = decimal.Parse(ds.Tables[0].Rows[0]["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]["flight_num"].ToString() != "")
                {
                    model.flight_num = ds.Tables[0].Rows[0]["flight_num"].ToString();
                }
                if (ds.Tables[0].Rows[0]["seat_price"].ToString() != "")
                {
                    model.seat_price = ds.Tables[0].Rows[0]["seat_price"].ToString();
                }
                if (ds.Tables[0].Rows[0]["begin_date"].ToString() != "")
                {
                    model.begin_date = ds.Tables[0].Rows[0]["begin_date"].ToString();
                }
                if (ds.Tables[0].Rows[0]["end_date"].ToString() != "")
                {
                    model.end_date = ds.Tables[0].Rows[0]["end_date"].ToString();
                }
                if (ds.Tables[0].Rows[0]["entry_port"].ToString() != "")
                {
                    model.entry_port = ds.Tables[0].Rows[0]["entry_port"].ToString();
                }
                if (ds.Tables[0].Rows[0]["visa_type"].ToString() != "")
                {
                    model.visa_type = ds.Tables[0].Rows[0]["visa_type"].ToString();
                }
                if (ds.Tables[0].Rows[0]["visa_nation"].ToString() != "")
                {
                    model.visa_nation = ds.Tables[0].Rows[0]["visa_nation"].ToString();
                }
                if (ds.Tables[0].Rows[0]["visa_data"].ToString() != "")
                {
                    model.visa_data = ds.Tables[0].Rows[0]["visa_data"].ToString();
                }

                model.albums = new article_albums().GetList(id); //相册信息
                return model;
            }
            else
            {
                return null;
            }
        }
コード例 #2
0
        private bool DoAdd()
        {
            bool result = true;
            Model.article_company model = new Model.article_company();
            BLL.article bll = new BLL.article();

            model.channel_id = this.channel_id;
            model.title = txtTitle.Text.Trim();

            model.category_id = int.Parse(ddlCategoryId.SelectedValue);
            model.link_url = txtLinkUrl.Text.Trim();
            model.img_url = txtImgUrl.Text.Trim();
            model.seo_title = txtSeoTitle.Text.Trim();
            model.seo_keywords = txtSeoKeywords.Text.Trim();
            model.seo_description = txtSeoDescription.Text.Trim();
            model.sort_id = int.Parse(txtSortId.Text.Trim());
            model.click = int.Parse(txtClick.Text.Trim());
            model.content = Utils.ToHtml(txtContent.Text);
            model.digg_good = int.Parse(txtDiggGood.Text.Trim());
            model.digg_bad = int.Parse(txtDiggBad.Text.Trim());
            model.is_msg = 0;
            model.is_red = 0;
            model.is_top = 0;
            model.is_lock = 0;
            model.telephone = txtTelephone.Text.Trim();
            model.user = txtContact.Text.Trim();
            model.address = txtAddress.Text.Trim();
            model.remark1 = "";
            model.remark2 = 0;
            model.x_lng = "";
            model.y_lat = "";
            model.line =  Utils.ToHtml(txtLine.Text.Trim());
            model.price = decimal.Parse(txtPrice.Text.Trim());
            model.sell_price = decimal.Parse(txtSellPrice.Text.Trim());
            model.flight_num = txtFlightNum.Text.Trim();
            model.seat_price = txtFlightSeat.Text.Trim();
            model.begin_date = txtBeginDate.Text.Trim();
            model.end_date = txtEndDate.Text.Trim();
            model.entry_port = txtEntryPort.Text.Trim();
            model.visa_type = txtVisaType.Text.Trim();
            model.visa_nation = txtVisaNation.Text.Trim();
            model.visa_data =  Utils.ToHtml(txtVisaData.Text.Trim());

            //if (cblItem.Items[0].Selected == true)
            //{
            //    model.is_msg = 1;
            //}
            if (cblItem.Items[0].Selected == true)
            {
                model.is_red = 1;
            }

            //检查是否有自定义图片
            if (txtImgUrl.Text.Trim() != "")
            {
                model.img_url = txtImgUrl.Text;
            }
            else
            {
                model.img_url = focus_photo.Value;
            }
            //保存相册
            string[] albumArr = Request.Form.GetValues("hide_photo_name");
            string[] remarkArr = Request.Form.GetValues("hide_photo_remark");
            if (albumArr != null && albumArr.Length > 0)
            {
                List<Model.article_albums> ls = new List<Model.article_albums>();
                for (int i = 0; i < albumArr.Length; i++)
                {
                    string[] imgArr = albumArr[i].Split('|');
                    if (imgArr.Length == 3)
                    {
                        if (!string.IsNullOrEmpty(remarkArr[i]))
                        {
                            ls.Add(new Model.article_albums { big_img = imgArr[1], small_img = imgArr[2], remark = remarkArr[i] });
                        }
                        else
                        {
                            ls.Add(new Model.article_albums { big_img = imgArr[1], small_img = imgArr[2] });
                        }
                    }
                }
                model.albums = ls;
            }
            if (bll.Add(model) < 1)
            {
                result = false;
            }

            return result;
        }