Esempio n. 1
0
        private void InitPage()
        {
            try
            {
                string newsid = CConvert.ToString(Request["id"]);
                DBB100 db     = new DBB100();
                if (FC_Check.IsNotEmpty(newsid))//修改
                {
                    hidNewsId.Value = newsid;
                    DataSet dst = db.GetTrainInfoById(newsid);
                    if (dst != null && dst.Tables.Count > 0 && dst.Tables[0].Rows.Count > 0)
                    {
                        DataRow dr       = dst.Tables[0].Rows[0];
                        string  category = CConvert.ToString(dr["speed"]);
                        this.txtTitle.Text    = CConvert.ToString(dr["title"]);
                        this.txtWordsCnt.Text = CConvert.ToString(dr["words"]);
                        newDesc.Value         = CConvert.ToString(dr["content"]);
                        imgPhoto.ImageUrl     = "../upload/test/" + CConvert.ToString(dr["photo"]);

                        ddlSpeadBind(category);
                    }
                }
                else
                {
                    ddlSpeadBind("");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 绑定NewsCode
        /// </summary>
        /// <param name="facid"></param>
        private void ddlSpeadBind(string category)
        {
            DBB100  db  = new DBB100();
            DataSet dst = db.GetCode(category);

            this.ddlSpead.DataSource     = dst.Tables[0].DefaultView;
            this.ddlSpead.DataTextField  = "categoryname";
            this.ddlSpead.DataValueField = "category";
            this.ddlSpead.DataBind();
        }
Esempio n. 3
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //输入校验
                if (!Check())
                {
                    return;
                }

                string sTitle   = txtTitle.Text;
                string sPeed    = ddlSpead.SelectedValue;
                string sContent = newDesc.Value;
                string sWords   = txtWordsCnt.Text;
                string sPhoto   = "";

                if (sWords == "")
                {
                    sWords = sContent.Length.ToString();
                }

                if (fileImg.HasFile)
                {
                    string[] arrFile = fileImg.FileName.Split('.');
                    sPhoto = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "." + arrFile[arrFile.Length - 1];

                    string sPath = AppConfig.ImagePath + "test/";
                    if (Directory.Exists(sPath) == false)
                    {
                        Directory.CreateDirectory(sPath);
                    }

                    fileImg.SaveAs(sPath + sPhoto);

                    ReSizeImageFile(sPath + sPhoto, 300, 400);
                }

                string sId = hidNewsId.Value;

                DBB100 db   = new DBB100();
                int    iRet = 0;
                if (FC_Check.IsNotEmpty(sId))//修改
                {
                    iRet = db.Update(sId, sTitle, sPeed, sPhoto, sContent, sWords);
                }
                else//新建
                {
                    iRet = db.Insert(m_trainType, sTitle, sPeed, sPhoto, sContent, sWords);
                }
                if (iRet > 0)
                {
                    Response.Redirect("B200.aspx");
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }