Ejemplo n.º 1
0
 public void ToSqlServer()
 {
     //string strCon = @"Data Source=bds13396396.my3w.com;initial catalog=bds13396396_db;user id=bds13396396;password=icox2015;multipleactiveresultsets=True;";
     //data source=bds13396396.my3w.com;initial catalog=bds13396396_db;user id=bds13396396;password=icox2015;multipleactiveresultsets=True;
     try {
         int yes = 0;
         int no  = 0;
         int c1  = GridView2.Rows.Count;
         //MessageBox.Show("表格行数=" + GridView2.Rows.Count, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         for (int i = 0; i < c1; i++)
         {
             if (GridView2.Rows[i].Cells[2].Text == "youku")
             {
                 string temppath = GridView2.Rows[i].Cells[3].Text.ToString();
                 string sql      = "insert into dbo.VideoUrl(Vid,Source,Path,sort,Describe) values(" + GridView2.Rows[i].Cells[0].Text + ",'"
                                   + GridView2.Rows[i].Cells[2].Text.ToString() + "','" + GridView2.Rows[i].Cells[3].Text.ToString() + "','"
                                   + GridView2.Rows[i].Cells[4].Text.ToString() + "','" + GridView2.Rows[i].Cells[5].Text.ToString() + "') ";
                 if (SqlFunction.Sql_ReturnNumberENQ(sql) > 0)
                 {
                     yes++;
                 }
                 else
                 {
                     no++;
                 }
             }
             else
             {
                 string temppath = GridView2.Rows[i].Cells[3].Text.ToString();
                 temppath = AES.Encrypt(temppath);
                 string sql = "insert into dbo.VideoUrl(Vid,Source,TempPath,sort,Describe) values(" + GridView2.Rows[i].Cells[0].Text + ",'"
                              + GridView2.Rows[i].Cells[2].Text.ToString() + "','" + temppath + "','"
                              + GridView2.Rows[i].Cells[4].Text.ToString() + "','" + GridView2.Rows[i].Cells[5].Text.ToString() + "') ";
                 if (SqlFunction.Sql_ReturnNumberENQ(sql) > 0)
                 {
                     yes++;
                 }
                 else
                 {
                     no++;
                 }
             }
         }
         string clientIP = HttpContext.Current.Request.UserHostAddress;
         u = (user)Session["Adminu"];
         Buckup.Buckup_Add("添加信道", u.name, clientIP, yes);
         //MessageBox.Show("导入SqlServer成功!成功数:" + yes + "失败数:" + no, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         Label2.Text = "导入成功:" + yes + "; 失败:" + no;
     } catch (Exception ex) {
         Label2.Text = ("导入过程中出错,请联系开发人员:" + ex.Message).Replace("'", "〞");
         Layer(string.Format(@"layer.alert('{0}', {
                       icon: 5,title: false,shade:false,
                       shadeClose: true,skin: 'layer-ext-moon'  
                     })", Label2.Text), Page);
     } finally {
     }
 }
Ejemplo n.º 2
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     if (TreeView1.SelectedValue == "")
     {
         Layer(@"layer.alert('请选中左侧节点类型', {
                       icon: 0,title: false,
                       shadeClose: true,skin: 'layer-ext-moon'  
                     })", Page);
     }
     else
     {
         if (title.Value != "" && img.Value != "" && sort.Value != "")
         {
             if (TreeView1.SelectedNode.ChildNodes.Count == 0)  //判断选择节点下是否有类型,没有则将原来tid替换成新的tid
             {
                 string sql = "insert into  videotype (Tid,Title,Cover,Sort,State) Values(" + TreeView1.SelectedValue + ",'" + title.Value + "','" + img.Value + "'," + sort.Value + ",1 )";
                 if (SqlFunction.Sql_ReturnNumberENQ(sql) > 0)
                 {
                     string clientIP = HttpContext.Current.Request.UserHostAddress;
                     u = (user)Session["Adminu"];
                     Buckup.Buckup_Add("添加类型", u.name, clientIP, 1);
                     string rtid = "select  id from videotype where title='" + title.Value + "'";
                     Text1.Value = SqlFunction.Sql_ReturnNumberES(rtid);
                     if (SqlFunction.Sql_ReturnNumberENQ("update video set tid=(" + rtid + ") where tid=" + TreeView1.SelectedValue) > 0)
                     {
                         bing();
                         Layer(@"layer.alert('类型添加成功,原类型转移成功', {
                               icon: 6,title: false,
                               shadeClose: true,skin: 'layer-ext-moon'  
                             })", Page);
                     }
                     else
                     {
                         bing();
                         Layer(@"layer.alert('类型添加成功,但原类型转移失败,请通知开发者转移', {
                               icon: 0,title: false,
                               shadeClose: true,skin: 'layer-ext-moon'  
                             })", Page);
                     }
                 }
                 else
                 {
                     Layer(@"layer.alert('添加失败', {
                               icon: 5,title: false,
                               shadeClose: true,skin: 'layer-ext-moon'  
                             })", Page);
                 }
             }
             else
             {
                 string sql = "insert into  videotype (Tid,Title,Cover,Sort,State) Values(" + TreeView1.SelectedValue + ",'" + title.Value + "','" + img.Value + "'," + sort.Value + ",0 )";
                 if (SqlFunction.Sql_ReturnNumberENQ(sql) > 0)
                 {
                     string rtid = "select  id from videotype where title='" + title.Value + "'";
                     Text1.Value = SqlFunction.Sql_ReturnNumberES(rtid); bing();
                     Layer(@"layer.alert('添加成功', {
                               icon: 6,title: false,
                               shadeClose: true,skin: 'layer-ext-moon'  
                             })", Page);
                 }
                 else
                 {
                     bing();
                     Layer(@"layer.alert('添加失败', {
                               icon: 5,title: false,
                               shadeClose: true,skin: 'layer-ext-moon'  
                             })", Page);
                 }
             }
         }
         else
         {
             Layer(@"layer.alert('有数据未填写', {
                               icon: 0,title: false,
                               shadeClose: true,skin: 'layer-ext-moon'  
                             })", Page);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 开始更新数据库
        /// </summary>
        /// <returns></returns>
        protected void startUpdate()
        {
            int  count        = GridView1.Rows.Count;
            bool isok         = false;
            int  sourcenum    = 0;
            int  state0source = 0;

            string [] state0index = new string[3];
            int       index       = 0;
            string    error       = "";

            for (int j = 0; j < count; j++)
            {
                int    xindaoNum = 0, xindaoIndex = 0;
                string sort = "";
                for (int i = 17; i > 0; i -= 7)
                {
                    if (GridView1.Rows[j].Cells[i].Text == "" || GridView1.Rows[j].Cells[i].Text == "&nbsp;")
                    {
                    }
                    else
                    {
                        xindaoNum++;
                        xindaoIndex = i;
                        switch (xindaoIndex)
                        {
                        case 3: sort = "999"; break;

                        case 10: sort = "99"; break;

                        case 17: sort = "9"; break;
                        }
                    }
                }

                DateTime dt = DateTime.Now;
                string   sql = "";
                string   cover = "", Describe = "";
                cover    = GridView1.Rows[j].Cells[1].Text.ToString();
                Describe = GridView1.Rows[j].Cells[xindaoIndex + 2].Text.ToString();
                if (cover == "&nbsp;")
                {
                    cover = "";
                }
                if (Describe == "&nbsp;")
                {
                    Describe = "";
                }
                //video表增加
                sql = "insert into video (tid,title,cover,Describe,CreateDate,Sort,State,Definition,Advertisement)" +
                      "values(" + "'" + GridView1.Rows[j].Cells[2].Text.ToString() + "',"
                      + "'" + GridView1.Rows[j].Cells[0].Text.ToString() + "',"
                      + "'" + cover + "',"
                      + "'" + Describe + "',"                                                 //描述默认为信道1的原标题
                      + "'" + dt.ToString() + "',"
                      + "'" + GridView1.Rows[j].Cells[xindaoIndex + 1].Text.ToString() + "'," //优先级默认为信道1的优先级
                      + "'" + GridView1.Rows[j].Cells[xindaoIndex + 4].Text.ToString() + "'," //状态默认为信道1的状态
                      + "'',"                                                                 //清晰度在video表中默认为空
                      + "'')";                                                                //是否存在广告在video表中默认为空
                int Vnum = SqlFunction.Sql_UpdatePL(sql);
                if (Vnum > 0)
                {
                    //Alert("成功添加"+Vnum+"条数据",Page);
                }
                else
                {
                    Layer(@"layer.alert('给Video表添加数据失败,已停止', {
                              icon: 5,title: false,
                              shadeClose: true,skin: 'layer-ext-moon'  
                            })", Page);
                    return;
                }
                //获取VideoId添加信道
                string sql_id = "select id from Video where title='" + GridView1.Rows[j].Cells[0].Text.ToString() + "'";
                string vid    = SqlFunction.Sql_ReturnNumberES(sql_id);


                //videourl表增加
                List <bool> bl = new List <bool>();
                bl.Add(false);
                bl.Add(false);
                bl.Add(false);
                if (GridView1.Rows[j].Cells[17].Text != "" && GridView1.Rows[j].Cells[17].Text != "&nbsp;")
                {
                    bl[2] = true;//有信道1
                }
                if (GridView1.Rows[j].Cells[10].Text != "" && GridView1.Rows[j].Cells[10].Text != "&nbsp;")
                {
                    bl[1] = true;//有信道2
                }
                if (GridView1.Rows[j].Cells[3].Text != "" && GridView1.Rows[j].Cells[3].Text != "&nbsp;")
                {
                    bl[0] = true;//有信道3
                }
                for (int i = 0; i < 3; i++)
                {
                    if (bl[i])
                    {
                        int uindex = 0;
                        switch (i)
                        {
                        case 0: sort = "999"; uindex = 3; break;

                        case 1: sort = "99"; uindex = 10; break;

                        case 2: sort = "9"; uindex = 17; break;
                        }
                        string Definition = "", Advertisement = "";
                        Definition    = GridView1.Rows[j].Cells[uindex + 5].Text.ToString();
                        Advertisement = GridView1.Rows[j].Cells[uindex + 6].Text.ToString();

                        if (Definition == "&nbsp;")
                        {
                            Definition = "";
                        }
                        if (Advertisement == "&nbsp;")
                        {
                            Advertisement = "";
                        }
                        DateTime dtU = DateTime.Now;
                        if (GridView1.Rows[j].Cells[uindex].Text.ToString() == "youku")
                        {
                            sql = "insert into videoUrl (Vid,Source,Path,State,Sort,CreateDate,Definition,Advertisement,Describe)values("
                                  + "'" + vid + "',"
                                  + "'" + GridView1.Rows[j].Cells[uindex].Text.ToString() + "',"
                                  + "'" + GridView1.Rows[j].Cells[uindex + 3].Text.ToString() + "',"
                                  + "'" + GridView1.Rows[j].Cells[uindex + 4].Text.ToString() + "',"
                                  + "'" + GridView1.Rows[j].Cells[uindex + 1].Text.ToString() + "',"
                                  + "'" + dtU.ToString() + "',"
                                  + "'" + Definition + "',"
                                  + "'" + Advertisement + "',"
                                  + "'" + GridView1.Rows[j].Cells[uindex + 2].Text.ToString() + "')";
                        }
                        else
                        {
                            string temppath = GridView1.Rows[i].Cells[uindex + 3].Text.ToString();
                            temppath = AES.Encrypt(temppath);
                            sql      = "insert into videoUrl (Vid,Source,TempPath,State,Sort,CreateDate,Definition,Advertisement,Describe)values("
                                       + "'" + vid + "',"
                                       + "'" + GridView1.Rows[j].Cells[uindex].Text.ToString() + "',"
                                       + "'" + temppath + "',"
                                       + "'" + GridView1.Rows[j].Cells[uindex + 4].Text.ToString() + "',"
                                       + "'" + GridView1.Rows[j].Cells[uindex + 1].Text.ToString() + "',"
                                       + "'" + dtU.ToString() + "',"
                                       + "'" + Definition + "',"
                                       + "'" + Advertisement + "',"
                                       + "'" + GridView1.Rows[j].Cells[uindex + 2].Text.ToString() + "')";
                        }
                        int Unum = SqlFunction.Sql_UpdatePL(sql);
                        if (Unum > 0)
                        {
                            isok = true;
                            sourcenum++;
                        }
                    }
                }
                if (isok)
                {
                    try {
                        if (SqlFunction.Sql_ReturnNumberENQ("update videoType set state=1 where id=" + GridView1.Rows[1].Cells[2].Text.ToString()) > 0)
                        {
                            //sourcenum++;
                        }
                    } catch (Exception e) {
                        state0source++;
                        error = e.Message;
                        state0index[index] = j.ToString(); index++;
                    }
                }
                else
                {
                    Label1.Text = "添加中出现问题:Vnum=" + Vnum;
                    Layer(string.Format(@"layer.alert('{0}', {{
                              icon: 5,title: false,
                              shadeClose: true,skin: 'layer-ext-moon'  
                            }})", Label1.Text), Page);
                }
            }
            string clientIP = HttpContext.Current.Request.UserHostAddress;

            u = (user)Session["Adminu"];
            if (sourcenum > 0)
            {
                Buckup.Buckup_Add("添加视频", u.name, clientIP, count);
                Label1.Text = "添加成功," + sourcenum + "条信道" + count + "行数据";
                Layer(string.Format(@"layer.alert('{0}', {{
                              icon: 6,title: false,
                              shadeClose: true,skin: 'layer-ext-moon'  
                            }})", Label1.Text), Page);
            }
            else
            {
                if (state0source == 0)
                {
                    Layer(string.Format(@"layer.alert('{0}', {{
                              icon: 5,title: false,
                              shadeClose: true,skin: 'layer-ext-moon'  
                            }})", "全部行添加失败"), Page);
                }
                else
                {
                    Buckup.Buckup_Add("添加视频", u.name, clientIP, count);
                    string errorinfo = "";
                    for (int m = 0; m < state0index.Length; m++)
                    {
                        if (state0index[m] != null && state0index[m] != "")
                        {
                            errorinfo += state0index[m] + ",";
                        }
                    }
                    errorinfo   = errorinfo.Substring(0, errorinfo.Length - 1);
                    Label1.Text = ("添加成功," + count +
                                   "行数据,但是当前类型是状态为0,请修改为1就可以显示,发生在第" + errorinfo + "条信道" +
                                   error).Replace("'", "〞");
                    Layer(string.Format(@"layer.alert('{0}', {{
                              icon: 6,title: false,
                              shadeClose: true,skin: 'layer-ext-moon'  
                            }})", Label1.Text), Page);
                }
            }
        }