Пример #1
0
        public DataTable AddMyCollections([FromBody] MyCollections json)
        {
            DataTable dt = null;

            try
            {
                if (json.id > 0 && json.userid > 0)
                {
                    EPData    ep    = new EPData();
                    ValidInfo valid = ep.AddMyCollectionByCP(json);
                    if (valid.valid)
                    {
                        dt = GetTable("true", "");
                    }
                }
                else
                {
                    dt = GetTable("false", "参数错误");
                }
            }
            catch (Exception ex)
            {
                dt = GetTable("false", ex.Message);
                Log.WriteError(ex, "我的收藏(SettMyCollections)");
            }
            return(dt);
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmMain frmmain = (frmMain)this.Owner;
            string  addList = string.Empty;
            string  addMac  = string.Empty;

            if (ValidInfo.IsAllowOrDeny(cbbAddList.Text) == true)
            {
                addList = cbbAddList.Text;
            }
            else
            {
                MessageBox.Show("LIST必须为Allow或者Deny", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (ValidInfo.IsMAC(txtAddMAC.Text) == true)
            {
                addMac = txtAddMAC.Text;
            }
            else
            {
                MessageBox.Show("MACADDRESS必须是MAC地址", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string addDes  = txtAddDescription.Text;
            string addFrom = dtpAddFrom.Text;
            string addThru = dtpAddThru.Text;
            string ADsql   = "insert into DhcpFilterStatus(LIST, MACADDRESS, DESCRIPTION, VALIDFROM, VALIDTHRU, STATUS) values(@addList, @addMac, @addDes, @addFrom, @addThru, 'adding')";

            SqlParameter[] paras =
            {
                new SqlParameter("@addList", addList),
                new SqlParameter("@addMac",  addMac),
                new SqlParameter("@addDes",  addDes),
                new SqlParameter("@addFrom", Convert.ToDateTime(addFrom)),
                new SqlParameter("@addThru", Convert.ToDateTime(addThru))
            };
            try
            {
                SqlHelpers.ExecuteNonQuery(CommandType.Text, ADsql, paras);
                MessageBox.Show("添加成功", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                string sql = "select LIST,MACADDRESS,DESCRIPTION,VALIDFROM,VALIDTHRU from DhcpFilterStatus where STATUS !='deleting'";
                frmmain.dt = SqlHelpers.ExecuteDataTable(CommandType.Text, sql);
                frmmain.dgvData.DataSource = frmmain.dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show("添加到数据库失败,原因:" + ex.Message, "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #3
0
        public bool Save(ValidInfo objVld)
        {
            try
            {
                SqlParameter[] @Params = new SqlParameter[3];
                @Params[0] = new SqlParameter("@DealId", objVld.DealID);
                @Params[1] = new SqlParameter("@ValidTo", objVld.ValidTo);
                @Params[2] = new SqlParameter("@ValidFrom", objVld.ValidFrom);

                SqlHelper.ExecuteNonQuery(ConnectionSettings.cnString, CommandType.StoredProcedure, "[proc_Insert_Valid]", @Params);
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public ValidInfo ResetMyPasswordByCP(User user)
        {
            ValidInfo valid = new ValidInfo();

            try
            {
                List <SqlParameter> sqllist = new List <SqlParameter>();
                sqllist.Add(new SqlParameter {
                    ParameterName = "@userid", SqlDbType = SqlDbType.Int, Value = user.userid
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@account", SqlDbType = SqlDbType.Int, Value = user.account
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@password", SqlDbType = SqlDbType.VarChar, Value = user.password
                });

                sqllist.Add(new SqlParameter {
                    ParameterName = "@outvalid", SqlDbType = SqlDbType.Bit, Direction = ParameterDirection.Output
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@outmsg", SqlDbType = SqlDbType.VarChar, Size = 100, Direction = ParameterDirection.Output
                });
                EPData     ep       = new common.EPData();
                SqlCommand cmd      = ep.CallProcCommon("cp_ResetPassword", sqllist.ToArray());
                string     outvalid = cmd.Parameters["@outvalid"].Value == null ? "" : cmd.Parameters["@outvalid"].Value.ToString().ToLower();
                string     outmsg   = cmd.Parameters["@outmsg"].Value == null ? "" : cmd.Parameters["@outmsg"].Value.ToString();
                cmd.Parameters.Clear();
                if (outvalid == "true" || outvalid == "True")
                {
                    valid.valid  = true;
                    valid.errmsg = "";
                }
                else
                {
                    valid.valid  = false;
                    valid.errmsg = outmsg;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(valid);
        }
Пример #5
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="info">注册信息</param>
        /// <returns></returns>
        public ValidInfo UserRegisterByCp(RegisterInfo info)
        {
            ValidInfo     valid  = new ValidInfo();
            SqlConnection sqlcon = new SqlConnection(con);

            try
            {
                //string str = string.Empty;
                SqlCommand cmd = new SqlCommand("cp_RegisterUser", sqlcon);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@account", SqlDbType.VarChar, 100).Value         = info.account;
                cmd.Parameters.Add("@accounttype", SqlDbType.Int).Value              = info.accounttype;
                cmd.Parameters.Add("@password", SqlDbType.VarChar, 100).Value        = info.password;
                cmd.Parameters.Add("@code", SqlDbType.VarChar, 100).Value            = info.code;
                cmd.Parameters.Add("@outvalid", SqlDbType.Bit).Direction             = ParameterDirection.Output;
                cmd.Parameters.Add("@outerrormsg", SqlDbType.VarChar, 100).Direction = ParameterDirection.Output;
                sqlcon.Open();
                cmd.ExecuteNonQuery();
                string outvalid = cmd.Parameters["@outvalid"].Value.ToString();
                string errormsg = cmd.Parameters["@outerrormsg"].Value.ToString();
                //string valid = cmd.Parameters["@outvalid"].Value.ToString();
                //string errormsg = cmd.Parameters["@outerrormsg"].Value.ToString();
                //str = "{\"IsSuccess\":" + valid + ",\"ErrMsg\":" + errormsg + "}";
                cmd.Parameters.Clear();
                sqlcon.Dispose();
                sqlcon.Close();
                if (outvalid == "true" || outvalid == "True")
                {
                    valid.valid  = true;
                    valid.errmsg = "";
                }
                else
                {
                    valid.valid  = false;
                    valid.errmsg = errormsg;
                }
            }
            catch (Exception ex)
            {
                sqlcon.Dispose();
                sqlcon.Close();
                throw ex;
            }
            return(valid);
        }
Пример #6
0
        public ValidInfo AddMyNotesByCp(MyNotes note)
        {
            ValidInfo     valid  = new ValidInfo();
            SqlConnection sqlcon = new SqlConnection(con);

            try
            {
                SqlCommand cmd = new SqlCommand("cp_AddMyNotes", sqlcon);

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@userid", SqlDbType.Int).Value             = note.userid;
                cmd.Parameters.Add("@notetype", SqlDbType.Int).Value           = note.notettype;
                cmd.Parameters.Add("@notefromid", SqlDbType.Int).Value         = note.notefromid;
                cmd.Parameters.Add("@notetitle", SqlDbType.VarChar).Value      = note.notetitle;
                cmd.Parameters.Add("@notecontent", SqlDbType.VarChar).Value    = note.notecontent;
                cmd.Parameters.Add("@noteurl", SqlDbType.VarChar).Value        = note.noteurl;
                cmd.Parameters.Add("@notecontentdes", SqlDbType.VarChar).Value = note.notecontentdes;
                cmd.Parameters.Add("@noteimageurl", SqlDbType.VarChar).Value   = note.noteimageurl;
                cmd.Parameters.Add("@outvalid", SqlDbType.Bit).Direction       = ParameterDirection.Output;
                cmd.Parameters.Add("@outmsg", SqlDbType.VarChar).Direction     = ParameterDirection.Output;

                sqlcon.Open();
                cmd.ExecuteNonQuery();
                SqlDisAndClose(sqlcon);
                string outvalid = cmd.Parameters["@outvalid"].Value == null ? "" : cmd.Parameters["@outvalid"].Value.ToString().ToLower();
                string outmsg   = cmd.Parameters["@outmsg"].Value == null ? "" : cmd.Parameters["@outmsg"].Value.ToString();
                cmd.Parameters.Clear();
                if (outvalid == "true" || outvalid == "True")
                {
                    valid.valid  = true;
                    valid.errmsg = "";
                }
                else
                {
                    valid.valid  = false;
                    valid.errmsg = outmsg;
                }
            }
            catch (Exception ex)
            {
                SqlDisAndClose(sqlcon);
                throw ex;
            }
            return(valid);
        }
        /// <summary>
        /// 验证验证码是否正确
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public ValidInfo VerificationCodeValid(CodeInfo code)
        {
            ValidInfo valid = new ValidInfo();

            try
            {
                List <SqlParameter> sqllist = new List <SqlParameter>();
                sqllist.Add(new SqlParameter {
                    ParameterName = "@phone", SqlDbType = SqlDbType.VarChar, Value = code.phone
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@code", SqlDbType = SqlDbType.VarChar, Value = code.code
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@codetype", SqlDbType = SqlDbType.Int, Value = code.codetype
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@outvalid", SqlDbType = SqlDbType.Bit, Direction = ParameterDirection.Output
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@outmsg", SqlDbType = SqlDbType.VarChar, Size = 100, Direction = ParameterDirection.Output
                });
                EPData     ep       = new EPData();
                SqlCommand cmd      = ep.CallProcCommon("cp_EqualVerificationCode", sqllist.ToArray());
                string     outvalid = cmd.Parameters["@outvalid"].Value == null ? "" : cmd.Parameters["@outvalid"].Value.ToString().ToLower();
                string     outmsg   = cmd.Parameters["@outmsg"].Value == null ? "" : cmd.Parameters["@outmsg"].Value.ToString();
                cmd.Parameters.Clear();
                if (outvalid == "true" || outvalid == "True")
                {
                    valid.valid  = true;
                    valid.errmsg = "";
                }
                else
                {
                    valid.valid  = false;
                    valid.errmsg = outmsg;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(valid);
        }
Пример #8
0
        public DataTable UserRegister([FromBody] RegisterInfo json)
        {
            DataTable dt = null;

            try
            {
                EPData    ep    = new EPData();
                ValidInfo valid = ep.UserRegisterByCp(json);
                if (valid.valid)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendFormat("SELECT 'true' AS IsSuccess,'' AS Error,* FROM dbo.EP_User WHERE Phone = '{0}'", json.account);
                    dt = ep.GetData(sb.ToString());
                }
                else
                {
                    dt = new DataTable();
                    dt.Columns.Add("IsSuccess", typeof(string));
                    dt.Columns.Add("Error", typeof(string));
                    DataRow dr = dt.NewRow();
                    dr["IsSuccess"] = valid.valid.ToString();
                    dr["Error"]     = valid.errmsg;
                    dt.Rows.Add(dr);
                }
            }
            catch (Exception ex)
            {
                dt = new DataTable();
                dt.Columns.Add("IsSuccess", typeof(string));
                dt.Columns.Add("Error", typeof(string));
                DataRow dr = dt.NewRow();
                dr["IsSuccess"] = "false";
                dr["Error"]     = ex.Message;
                dt.Rows.Add(dr);
                Log.WriteError(ex, "注册(UserRegister)");
            }



            return(dt);
        }
Пример #9
0
        private void btnAlter_Click(object sender, EventArgs e)
        {
            frmMain frmmain   = (frmMain)this.Owner;
            string  alterList = string.Empty;

            if (ValidInfo.IsAllowOrDeny(cbbAlterList.Text) == true)
            {
                alterList = cbbAlterList.Text;
            }
            else
            {
                MessageBox.Show("LIST必须为Allow或者Deny", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string currentMAC = frmmain.dgvData.CurrentRow.Cells[1].Value.ToString();
            string alterDes   = txtAlterDescription.Text;
            string alterFrom  = dtpAlterValidFrom.Text;
            string alterThru  = dtpAlterValidThru.Text;
            string ATsql      = "update DhcpFilterStatus set LIST=@alterList, DESCRIPTION=@alterDes, VALIDFROM=@alterFrom, VALIDTHRU=@alterThru, STATUS='altering' where MACADDRESS=@currentMAC";

            SqlParameter[] paras =
            {
                new SqlParameter("@currentMAC", currentMAC),
                new SqlParameter("@alterList",  alterList),
                new SqlParameter("@alterDes",   alterDes),
                new SqlParameter("@alterFrom",  Convert.ToDateTime(alterFrom)),
                new SqlParameter("@alterThru",  Convert.ToDateTime(alterThru))
            };
            try
            {
                SqlHelpers.ExecuteNonQuery(CommandType.Text, ATsql, paras);
                MessageBox.Show("修改成功", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                string sql = "select LIST,MACADDRESS,DESCRIPTION,VALIDFROM,VALIDTHRU from DhcpFilterStatus where STATUS !='deleting'";
                frmmain.dt = SqlHelpers.ExecuteDataTable(CommandType.Text, sql);
                frmmain.dgvData.DataSource = frmmain.dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show("修改到数据库失败,原因:" + ex.Message, "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #10
0
        /// <summary>
        /// 插入消息 存储过程
        /// </summary>
        /// <param name="mymsg"></param>
        /// <returns></returns>
        public ValidInfo InsertMessagesToUserByCP(MyMessages mymsg)
        {
            ValidInfo     valid  = new ValidInfo();
            SqlConnection sqlcon = new SqlConnection(con);

            try
            {
                SqlCommand cmd = new SqlCommand("cp_InsertMessagesToUser", sqlcon);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@userids", SqlDbType.VarChar, 1000).Value    = mymsg.userids;
                cmd.Parameters.Add("@msgtitle", SqlDbType.VarChar, 500).Value    = mymsg.msgtitle;
                cmd.Parameters.Add("@msgcontent", SqlDbType.VarChar, 8000).Value = mymsg.msgcontent;
                cmd.Parameters.Add("@outvalid", SqlDbType.Bit).Direction         = ParameterDirection.Output;
                cmd.Parameters.Add("@outmsg", SqlDbType.VarChar).Direction       = ParameterDirection.Output;
                sqlcon.Open();
                cmd.ExecuteNonQuery();
                sqlcon.Dispose();
                sqlcon.Close();
                string outvalid = cmd.Parameters["@outvalid"].Value == null ? "" : cmd.Parameters["@outvalid"].Value.ToString().ToLower();
                string outmsg   = cmd.Parameters["@outmsg"].Value == null ? "" : cmd.Parameters["@outmsg"].Value.ToString();
                cmd.Parameters.Clear();
                if (outvalid == "true" || outvalid == "True")
                {
                    valid.valid  = true;
                    valid.errmsg = "";
                }
                else
                {
                    valid.valid  = false;
                    valid.errmsg = outmsg;
                }
            }
            catch (Exception ex)
            {
                sqlcon.Dispose();
                sqlcon.Close();
                throw ex;
            }
            return(valid);
        }
Пример #11
0
        public ValidInfo EditMyNoteByCP(MyNotes note)
        {
            ValidInfo     valid  = new ValidInfo();
            SqlConnection sqlcon = new SqlConnection(con);

            try
            {
                SqlCommand cmd = new SqlCommand("cp_EditMyNotes", sqlcon);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@id", SqlDbType.Int).Value                 = note.id;
                cmd.Parameters.Add("@userid", SqlDbType.Int).Value             = note.userid;
                cmd.Parameters.Add("@notetitle", SqlDbType.VarChar).Value      = note.notetitle;
                cmd.Parameters.Add("@notecontent", SqlDbType.VarChar).Value    = note.notecontent;
                cmd.Parameters.Add("@noteurl", SqlDbType.VarChar).Value        = note.noteurl;
                cmd.Parameters.Add("@notecontentdes", SqlDbType.VarChar).Value = note.notecontentdes;
                cmd.Parameters.Add("@noteimageurl", SqlDbType.VarChar).Value   = note.noteimageurl;
                //foreach (var item in note.GetType().GetProperties())
                //{
                //    object value = item.GetValue(note);
                //    if (value != null)
                //    {
                //        string param = "@" + item.Name.ToLower();
                //        cmd.Parameters.Add(param, GetSqlDbType(item.PropertyType.Name)).Value = value;
                //    }
                //}
                //cmd.Parameters.Add(sqlparams);
                sqlcon.Open();
                cmd.ExecuteNonQuery();
                SqlDisAndClose(sqlcon);
                cmd.Parameters.Clear();
            }
            catch (Exception ex)
            {
                SqlDisAndClose(sqlcon);
                throw ex;
            }
            return(valid);
        }
Пример #12
0
        public DataTable VerificationCodeValid([FromBody] CodeInfo json)
        {
            DataTable dt = null;

            try
            {
                if (!string.IsNullOrWhiteSpace(json.phone) && !string.IsNullOrWhiteSpace(json.code) && json.codetype > 0)
                {
                    OperationData od    = new OperationData();
                    ValidInfo     valid = od.VerificationCodeValid(json);
                    dt = GetTable(valid.valid, valid.errmsg);
                }
                else
                {
                    dt = GetTable("false", "参数错误");
                }
            }
            catch (Exception ex)
            {
                dt = GetTable("false", ex.Message);
                Log.WriteError(ex, "验证码验证是否正确(VerificationCodeValid)");
            }
            return(dt);
        }
Пример #13
0
        public ValidInfo AddMyCollectionByCP(MyCollections coll)
        {
            ValidInfo     valid  = new ValidInfo();
            SqlConnection sqlcon = new SqlConnection(con);

            try
            {
                SqlCommand cmd = new SqlCommand("", sqlcon);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@userid", SqlDbType.Int).Value           = coll.userid;
                cmd.Parameters.Add("@collectiontype", SqlDbType.Int).Value   = coll.collectiontype;
                cmd.Parameters.Add("@contentid", SqlDbType.Int).Value        = coll.contentid;
                cmd.Parameters.Add("@contenturl", SqlDbType.VarChar).Value   = coll.contenturl;
                cmd.Parameters.Add("@imageurl", SqlDbType.VarChar).Value     = coll.imageurl;
                cmd.Parameters.Add("@title", SqlDbType.VarChar).Value        = coll.title;
                cmd.Parameters.Add("@descriptions", SqlDbType.VarChar).Value = coll.descriptions;
                cmd.Parameters.Add("@outvalid", SqlDbType.Bit).Direction     = ParameterDirection.Output;
                sqlcon.Open();
                cmd.ExecuteNonQuery();
                sqlcon.Dispose();
                sqlcon.Close();
                string outvalid = cmd.Parameters["@outvalid"].Value == null ? "false" : cmd.Parameters["@outvalid"].Value.ToString().ToLower();
                if (outvalid == "true")
                {
                    valid.valid = true;
                }
            }
            catch (Exception ex)
            {
                sqlcon.Dispose();
                sqlcon.Close();
                throw ex;
            }

            return(valid);
        }
Пример #14
0
        public DataTable InsertMessagesToUser([FromBody] MyMessages json)
        {
            DataTable dt = null;

            try
            {
                if (!string.IsNullOrWhiteSpace(json.userids))
                {
                    EPData    ep    = new EPData();
                    ValidInfo valid = ep.InsertMessagesToUserByCP(json);
                    dt = GetTable(valid.valid.ToString(), valid.errmsg);
                }
                else
                {
                    dt = GetTable("false", "参数错误");
                }
            }
            catch (Exception ex)
            {
                dt = GetTable("false", ex.Message);
                Log.WriteError(ex, "我的消息(SendMessagesToUser)");
            }
            return(dt);
        }
Пример #15
0
        public DataTable AddMyNotes([FromBody] MyNotes json)
        {
            DataTable dt = null;

            try
            {
                if (json.userid > 0)
                {
                    EPData    ep    = new EPData();
                    ValidInfo valid = ep.AddMyNotesByCp(json);
                    dt = GetTable(valid.valid, valid.errmsg);
                }
                else
                {
                    dt = GetTable("false", "参数错误");
                }
            }
            catch (Exception ex)
            {
                dt = GetTable("false", ex.Message);
                Log.WriteError(ex, "我的笔记(AddMyNotes)");
            }
            return(dt);
        }
Пример #16
0
        public DataTable AddMyCollectionVideos([FromBody] MyCollectionVideos json)
        {
            DataTable dt = null;

            try
            {
                if (json.userid > 0)
                {
                    OperationData od    = new common.OperationData();
                    ValidInfo     valid = od.AddMyCollectionVideos(json);
                    dt = GetTable(valid.valid, valid.errmsg);
                }
                else
                {
                    dt = GetTable("false", "参数错误");
                }
            }
            catch (Exception ex)
            {
                dt = GetTable("false", ex.Message);
                Log.WriteError(ex, "我的收藏视屏(AddMyCollectionVideos)");
            }
            return(dt);
        }
Пример #17
0
        public DataTable ResetMyPassword([FromBody] User json)
        {
            DataTable dt = null;

            try
            {
                if ((json.userid > 0 || !string.IsNullOrWhiteSpace(json.account)) && !string.IsNullOrWhiteSpace(json.password))
                {
                    OperationData od    = new OperationData();
                    ValidInfo     valid = od.ResetMyPasswordByCP(json);
                    dt = this.GetTable(valid.valid, valid.errmsg);
                }
                else
                {
                    dt = GetTable("false", "参数错误");
                }
            }
            catch (Exception ex)
            {
                dt = GetTable("false", ex.Message);
                Log.WriteError(ex, "修改密码(ResetMyPassword)");
            }
            return(dt);
        }
        private void btnImport_Click(object sender, EventArgs e)
        {
            string         fileName  = string.Empty;
            string         duplicate = string.Empty;
            List <string>  database  = new List <string>();
            OpenFileDialog openfile  = new OpenFileDialog();

            openfile.Filter = "CSV文件(*.csv)|*.csv|TXT文件(*.txt)|*.txt|所有文件(*.*)|*.*";
            if (openfile.ShowDialog() == DialogResult.OK)
            {
                fileName = openfile.FileName;
            }
            else
            {
                return;
            }
            try
            {
                int k = 0;
                int t = 0;
                csv = ValidInfo.GetDataTabletFromCSVFile(fileName);
                for (int i = 0; i < csv.Columns.Count; i++)
                {
                    csv.Columns[i].ColumnName = csv.Columns[i].ColumnName.ToUpper();
                }//将列名大写
                for (int i = 0; i < csv.Rows.Count; i++)///////////添加对于CSV文件中数据的验证
                {
                    if (ValidInfo.IsAllowOrDeny(csv.Rows[i][0].ToString()) == true && ValidInfo.IsMAC(csv.Rows[i][1].ToString()) == true)//验证allow和macaddress的正确性
                    {
                        k += 1;
                    }
                    else
                    {
                        MessageBox.Show($"读取数据失败!{csv.Rows[i][1].ToString()}有误", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dgvFileData.DataSource = null;
                        return;
                    }
                    for (int j = i + 1; j < csv.Rows.Count; j++)
                    {
                        if (csv.Rows[i][1].ToString() == csv.Rows[j][1].ToString())
                        {
                            duplicate = duplicate + csv.Rows[j][1].ToString() + " ,";
                            csv.Rows.RemoveAt(j);
                            t += 1;
                        }
                    }//去除重复项
                    database.Add(csv.Rows[i][1].ToString());//获取dt csv的macaddress列,方便下一步进行数据库去重
                }
                int pre = csv.Rows.Count;
                DistinctFromDatabase(csv);//和数据库比对进行去重
                int aft   = csv.Rows.Count;
                int total = pre - aft;

                if ((duplicate == string.Empty) && (total == 0))
                {
                    MessageBox.Show($"读取数据成功,共{k}条", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show($"读取{k-total}条数据,原文件中与数据库冲突的有{total}项,{conflict.TrimEnd(',')}" + "\n" +
                                    $"原文件中重复项有{t}项,{duplicate.TrimEnd(',')}", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                conflict = string.Empty;
                dgvFileData.AutoGenerateColumns = false;
                dgvFileData.DataSource          = null;
                dgvFileData.DataSource          = csv;
                csv.Columns.Add("STATUS", Type.GetType("System.String"));
                for (int i = 0; i < csv.Rows.Count; i++)
                {
                    csv.Rows[i][csv.Columns.Count - 1] += "uploading";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("读取数据失败,原因:" + ex.Message, "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// 添加视屏收藏
        /// </summary>
        /// <param name="video"></param>
        /// <returns></returns>
        public ValidInfo AddMyCollectionVideos(MyCollectionVideos video)
        {
            ValidInfo valid = new ValidInfo();

            try
            {
                List <SqlParameter> sqllist = new List <SqlParameter>();

                sqllist.Add(new SqlParameter {
                    ParameterName = "@userid", SqlDbType = SqlDbType.Int, Value = video.userid
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videoid", SqlDbType = SqlDbType.Int, Value = video.videoid
                });

                sqllist.Add(new SqlParameter {
                    ParameterName = "@videocategroyid", SqlDbType = SqlDbType.Int, Value = video.videocategroyid
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videocategroy", SqlDbType = SqlDbType.VarChar, Value = video.videocategroy
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videotitile", SqlDbType = SqlDbType.VarChar, Value = video.videotitile
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videodes", SqlDbType = SqlDbType.VarChar, Value = video.videodes
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videoimageurl", SqlDbType = SqlDbType.VarChar, Value = video.videoimageurl
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videoprice", SqlDbType = SqlDbType.Decimal, Value = video.videoprice
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videolecturerid", SqlDbType = SqlDbType.Int, Value = video.videolecturerid
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@videolecturer", SqlDbType = SqlDbType.VarChar, Value = video.videolecturer
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@issign", SqlDbType = SqlDbType.VarChar, Value = video.issign
                });

                sqllist.Add(new SqlParameter {
                    ParameterName = "@watchcounts", SqlDbType = SqlDbType.Int, Value = video.watchcounts
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@mywatchcounts", SqlDbType = SqlDbType.Int, Value = video.mywatchcounts
                });

                sqllist.Add(new SqlParameter {
                    ParameterName = "@outvalid", SqlDbType = SqlDbType.Bit, Direction = ParameterDirection.Output
                });
                sqllist.Add(new SqlParameter {
                    ParameterName = "@outmsg", SqlDbType = SqlDbType.VarChar, Size = 100, Direction = ParameterDirection.Output
                });                                                                                                                                          //错误提示:string[x]:size 属性具有无效大小值0  //解决方案: 输出参数需要明确指定长度

                EPData     ep  = new EPData();
                SqlCommand cmd = ep.CallProcCommon("cp_AddMyCollectionVideos", sqllist.ToArray());

                string outvalid = cmd.Parameters["@outvalid"].Value == null ? "" : cmd.Parameters["@outvalid"].Value.ToString().ToLower();
                string outmsg   = cmd.Parameters["@outmsg"].Value == null ? "" : cmd.Parameters["@outmsg"].Value.ToString();
                cmd.Parameters.Clear();
                if (outvalid == "true" || outvalid == "True")
                {
                    valid.valid  = true;
                    valid.errmsg = "";
                }
                else
                {
                    valid.valid  = false;
                    valid.errmsg = outmsg;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(valid);
        }
Пример #20
0
        public bool SaveValid(ValidInfo oVld)
        {
            Validdb oDb = new Validdb();

            return(oDb.Save(oVld));
        }