Exemple #1
0
 /// <summary> 
 /// 删除数据 
 /// </summary> 
 /// <param name="entity"></param> 
 /// <returns></returns> 
 public int Delete(AgentType entity)
 {
     string sql = "DELETE FROM agent_type WHERE agentNo=@agentNo and agentType=@agentType and agentFeeMonth=@agentFeeMonth";
     using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
     {
         mycn.Open();
         MySqlCommand command = new MySqlCommand(sql, mycn);
         command.Parameters.AddWithValue("@agentNo", entity.agentNo);
         command.Parameters.AddWithValue("@agentType", entity.agentType);
         command.Parameters.AddWithValue("@agentFeeMonth", entity.agentFeeMonth);
         int i = command.ExecuteNonQuery();
         mycn.Close();
         mycn.Dispose();
         return i;
     }
 }
Exemple #2
0
 public const string mysqlConnection = DBConstant.mysqlConnection;//"User Id=root;Host=115.29.229.134;Database=chinaunion;password=c513324665;charset=utf8";
 /// <summary> 
 /// 添加数据 
 /// </summary> 
 /// <returns></returns> 
 public int Add(AgentType entity)
 {
     string sql = "INSERT INTO agent_type (agentNo,agentType,agentFeeMonth) VALUE (@agentNo,@agentType,@agentFeeMonth)";
     using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
     {
         mycn.Open();
         MySqlCommand command = new MySqlCommand(sql, mycn);
         command.Parameters.AddWithValue("@agentNo", entity.agentNo);
         command.Parameters.AddWithValue("@agentType", entity.agentType);
         command.Parameters.AddWithValue("@agentFeeMonth", entity.agentFeeMonth);
         int i = command.ExecuteNonQuery();
         mycn.Close();
         mycn.Dispose();
         return i;
     }
 }
Exemple #3
0
        /// <summary> 
        /// 修改数据 
        /// </summary> 
        /// <param name="entity"></param> 
        /// <returns></returns> 
        public int Update(AgentType entity)
        {
            string sql = "UPDATE  agent_type SET agentNo=@agentNo,agentType=@agentType where agentNo=@agentNo  and agentFeeMonth=@agentFeeMonth";

            //string sql = "UPDATE cimuser SET userNickName=@userNickName WHERE userid=@userid";
            using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
            {
                mycn.Open();
                MySqlCommand command = new MySqlCommand(sql, mycn);
                command.Parameters.AddWithValue("@agentNo", entity.agentNo);
                command.Parameters.AddWithValue("@agentType", entity.agentType);
                command.Parameters.AddWithValue("@agentFeeMonth", entity.agentFeeMonth);
                int i = command.ExecuteNonQuery();
                mycn.Close();
                mycn.Dispose();
                return i;
            }
        }
        /// <summary>
        /// 异步 开始事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            //需要执行的代码
           

          
            worker.ReportProgress(5, "开始导入代理商类型...\r\n");

            //导入代理商类型
            AgentTypeDao agentTypeDao = new AgentTypeDao();
            for (int i = 0; i < dgAgentType.RowCount; i++)
            {
                AgentType agentType = new AgentType();
                agentType.agentNo = dgAgentType[0, i].Value.ToString();
                agentType.agentType = dgAgentType[1, i].Value.ToString();
                agentType.agentFeeMonth = this.dtFeeMonth.Value.ToString("yyyy-MM");
                agentTypeDao.Delete(agentType);
                agentTypeDao.Add(agentType);
            }

          
            worker.ReportProgress(6, "导入代理商类型完成...\r\n");
            worker.ReportProgress(7, "开始导入代理商类型说明...\r\n");


            //导入代理商类型说明
            AgentTypeCommentDao agentTypeCommentDao = new AgentTypeCommentDao();
            for (int i = 0; i < dgAgentTypeComment.RowCount; i++)
            {
                AgentTypeComment agentTypeComment = new AgentTypeComment();

                agentTypeComment.agentType = dgAgentTypeComment[0, i].Value.ToString();
                agentTypeComment.agentTypeComment = dgAgentTypeComment[1, i].Value.ToString();
                agentTypeComment.agentFeeMonth = this.dtFeeMonth.Value.ToString("yyyy-MM");
                agentTypeCommentDao.Delete(agentTypeComment);
                agentTypeCommentDao.Add(agentTypeComment);
            }

            ImportLog importLog = new ChinaUnion_BO.ImportLog();
            importLog.type="Agent";
            importLog.import_month = this.dtFeeMonth.Value.ToString("yyyy-MM");
            ImportLogDao importLogDao = new ChinaUnion_DataAccess.ImportLogDao();
            importLogDao.Delete(importLog);
            importLogDao.Add(importLog);
            worker.ReportProgress(8, "导入代理商类型完成...\r\n");
           

            //MessageBox.Show("数据上传完毕");

        }
Exemple #5
0
        /// <summary> 
        /// 查询集合 
        /// </summary> 
        /// <returns></returns> 
        public IList<AgentType> GetDistinctType()
        {
            string sql = "SELECT distinct agentType FROM agent_type";
            using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
            {
                mycn.Open();
                MySqlCommand command = new MySqlCommand(sql, mycn);
               
                MySqlDataReader reader = command.ExecuteReader();
                IList<AgentType> list = new List<AgentType>();
                AgentType agent_Type = null;
                while (reader.Read())
                {
                    agent_Type = new AgentType();

                    //agent_Type.agentNo = reader["agentNo"] == DBNull.Value ? null : reader["agentNo"].ToString();
                    agent_Type.agentType = reader["agentType"] == DBNull.Value ? null : reader["agentType"].ToString();
                  //  agent_Type.agentFeeMonth = reader["agentFeeMonth"] == DBNull.Value ? null : reader["agentFeeMonth"].ToString();

                    list.Add(agent_Type);
                }
                return list;
            }
        }
Exemple #6
0
        /// <summary> 
        /// 根据主键查询 
        /// </summary> 
        /// <param name="primaryKey"></param> 
        /// <returns></returns> 
        //public Agent Get(int primaryKey)
        //{
        //    string sql = "SELECT userid,userNickName FROM cimuser where userid=@userid";
        //    using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
        //    {
        //        mycn.Open();
        //        MySqlCommand command = new MySqlCommand(sql, mycn);
        //        command.Parameters.AddWithValue("@userid", primaryKey);
        //        MySqlDataReader reader = command.ExecuteReader();
        //        Agent userBase = null;
        //        if (reader.Read())
        //        {
        //            userBase = new Agent();
        //            userBase.UserId = Convert.ToInt32(reader["userid"]);
        //            userBase.UserNickName = reader["userNickName"] == DBNull.Value ? null : reader["userNickName"].ToString();
        //        }
        //        return userBase;
        //    }
        //}
        /// <summary> 
        /// 查询集合 
        /// </summary> 
        /// <returns></returns> 
        public IList<AgentType> GetList(String agentFeeMonth)
        {
            string sql = "SELECT agentNo,agentType,agentFeeMonth FROM agent_type where agentFeeMonth=@agentFeeMonth";
            using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
            {
                mycn.Open();
                MySqlCommand command = new MySqlCommand(sql, mycn);
                command.Parameters.AddWithValue("@agentFeeMonth", agentFeeMonth);
                MySqlDataReader reader = command.ExecuteReader();
                IList<AgentType> list = new List<AgentType>();
                AgentType agent_Type = null;
                while (reader.Read())
                {
                    agent_Type = new AgentType();

                    agent_Type.agentNo = reader["agentNo"] == DBNull.Value ? null : reader["agentNo"].ToString();
                    agent_Type.agentType = reader["agentType"] == DBNull.Value ? null : reader["agentType"].ToString();
                    agent_Type.agentFeeMonth = reader["agentFeeMonth"] == DBNull.Value ? null : reader["agentFeeMonth"].ToString();

                    list.Add(agent_Type);
                }
                mycn.Close();
                return list;
            }
        }