Ejemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //添加
            //保存图片



            string strsql;
            string NewID   = "";
            string img_url = UploadPicFile(FileUpload1);

            if (img_url == "")
            {
                img_url = "nopic.jpg";  //不上传图片,默认为无图片
            }
            strsql = string.Format("insert Into T_films (PathID,Film_name,Other_name,Film_director,Film_Player,"
                                   + "Film_class,Film_classID,Film_from,film_Level,film_clear,film_money,film_Pic,film_gut,"
                                   + "playtype,filmisseq,Filmisgood1,"
                                   + "filmisGood2,FilePhyPath,FileFolder,AllowDown,ShowType,SearchKey) values ({0},'{1}','{2}','{3}','{4}',"
                                   + "'{5}',{6},{7},{8},{9},{10},'{11}','{12}',"
                                   + "{13},{14},{15},"
                                   + "{16},'{17}','{18}',{19},{20},'{21}')",
                                   DwPath.SelectedValue, TbFilmname.Text, TbOthername.Text, TbDirector.Text, TbPlayer.Text,
                                   DwClass.SelectedItem.Text, DwClass.SelectedItem.Value, DwFrom.SelectedItem.Value,
                                   DwLevel.Text, DwClear.Text, (TbMoney.Text == "" ? "0" : TbMoney.Text), img_url, TbGut.Text.Replace("'", "''"),
                                   Rbfilmtype.Text, RbIsReq.Text, (CkbBest.Items[0].Selected ? 1 : 0), (CkbBest.Items[1].Selected ? 1 : 0),
                                   TbFilmPhyPath.Text, uppath.Value, Rb_AllowDown.Text, Rb_Showtype.Text,
                                   (Tb_SearchKey.Text == "" ? TbFilmname.Text : Tb_SearchKey.Text));
            try
            {
                if (DBFun.ExecuteUpdate(strsql))
                {
                    NewID = DBFun.SearchValue("select Max(ID) from T_films");

                    int ijs = 0;
                    for (int i = 1; i <= Convert.ToInt32(upjs.Value); i++)
                    {
                        strsql = string.Format("Insert Into [T_film_detail] (filename,filmid) values ('{0}',{1})",
                                               Request["urla" + i], NewID);
                        if (DBFun.ExecuteUpdate(strsql))
                        {
                            ijs++;
                        }
                    }
                    strsql = string.Format("update T_films Set film_num = {0} where id={1}", ijs, NewID);
                    DBFun.ExecuteSql(strsql);
                    Response.Write("<script>alert('影片添加成功!');window.location.href='film_edit.aspx?Action=Edit&ID=" + NewID + "';</script>");
                }
            }
            catch
            {
                Response.Write("<script>alert('影片添加失败!请确认填写正确!');</script>");
            }
        }
Ejemplo n.º 2
0
 protected void btn_Ok_Click(object sender, EventArgs e)
 {
     //保存
     if (btn_Ok.Text == "添加")
     {
         try
         {
             string strsql = string.Format("Insert into T_class(Caption,ListImg,Listpagesize,ListSamePageSize,Cidx,"
                                           + "CIsOpen,ListsortType,NotLoginIn,CSort) "
                                           + " values('{0}','{1}',{2},{3},{4},{5},{6},{7},{8})",
                                           tb_Caption.Text, tb_ListImg.Text, tb_ListPageSize.Text, tb_ListSamePageSize.Text, tb_Cidx.Text,
                                           rbl_CIsOpen.Text, rbl_ListSortType.Text, rbl_NotLogin.Text, tb_CSort.Text);
             if (DBFun.ExecuteUpdate(strsql))
             {
                 Response.Write("<script>alert('数据添加成功!');window.location.href='film_classAddEdit.aspx?Action=Edit&id=" + DBFun.SearchValue("select Max(id) from T_class") + "';</script>");
             }
             else
             {
                 Response.Write("<scritp>alert('添加失败!请检查是否填写正确。');</script>");
             }
         }
         catch (Exception ex)
         {
             Response.Write(@"<script>alert('添加失败!请检查是否填写正确!" + ex.Message + "');</script>");
         }
     }
     else if (btn_Ok.Text == "确认修改")
     {
         try
         {
             string strsql = string.Format("Update T_class Set Caption='{0}',ListImg='{1}',Listpagesize={2},ListSamePageSize={3},Cidx={4},"
                                           + "CIsOpen={5},ListsortType={6},NotLoginIn={7} ,Csort={8} where id={9}",
                                           tb_Caption.Text, tb_ListImg.Text, tb_ListPageSize.Text, tb_ListSamePageSize.Text, tb_Cidx.Text,
                                           rbl_CIsOpen.Text, rbl_ListSortType.Text, rbl_NotLogin.Text, tb_CSort.Text, Request.QueryString["ID"]);
             if (DBFun.ExecuteUpdate(strsql))
             {
                 Response.Write("<script>alert('数据修改成功!');document.reload();</script>");
             }
             else
             {
                 Response.Write("<scritp>alert('保存失败!请检查是否填写正确。');</script>");
             }
         }
         catch
         {
             Response.Write("<script>alert('保存失败!请检查是否填写正确!');</script>");
         }
     }
 }