Ejemplo n.º 1
0
        /// <summary> 
        /// 根据主键查询 
        /// </summary> 
        /// <param name="primaryKey"></param> 
        /// <returns></returns> 
        public ImportLog Get(ImportLog entity)
        {
            string sql = "SELECT type,import_month FROM import_log where  import_month=@import_month and type=@type";

            using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
            {
                mycn.Open();
                MySqlCommand command = new MySqlCommand(sql, mycn);
               
                command.Parameters.AddWithValue("@type", entity.type);
                command.Parameters.AddWithValue("@import_month", entity.import_month);
                MySqlDataReader reader = command.ExecuteReader();
                ImportLog importLog = null;
                if (reader.Read())
                {
                    importLog = new ImportLog();

                  
                    importLog.type = reader["type"] == DBNull.Value ? null : reader["type"].ToString();
                    importLog.import_month = reader["import_month"] == DBNull.Value ? null : reader["import_month"].ToString();
                }
                mycn.Close();
                return importLog;
            }
        }
Ejemplo n.º 2
0
 /// <summary> 
 /// 删除数据 
 /// </summary> 
 /// <param name="entity"></param> 
 /// <returns></returns> 
 public int Delete(ImportLog entity)
 {
     string sql = "DELETE FROM import_log WHERE  import_month=@import_month and type=@type";
     using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
     {
         mycn.Open();
         MySqlCommand command = new MySqlCommand(sql, mycn);
        
         command.Parameters.AddWithValue("@type", entity.type);
         command.Parameters.AddWithValue("@import_month", entity.import_month);
         int i = command.ExecuteNonQuery();
         mycn.Close();
         mycn.Dispose();
         return i;
     }
 }
Ejemplo n.º 3
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(ImportLog entity)
        {


            string sql = "INSERT INTO import_log (type,import_month) VALUE (@type,@import_month)";
            using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
            {
                mycn.Open();
                MySqlCommand command = new MySqlCommand(sql, mycn);
               
                command.Parameters.AddWithValue("@type", entity.type);
                command.Parameters.AddWithValue("@import_month", entity.import_month);

                int i = command.ExecuteNonQuery();
                mycn.Close();
                mycn.Dispose();
                return i;
            }
        }
Ejemplo n.º 4
0
        private void btnImport_Click(object sender, EventArgs e)
        {

            ImportLog importLog = new ChinaUnion_BO.ImportLog();
            importLog.type = "Agent";
            importLog.import_month = this.dtFeeMonth.Value.ToString("yyyy-MM");
            ImportLogDao importLogDao = new ChinaUnion_DataAccess.ImportLogDao();
            if (importLogDao.Get(importLog) != null)
            {
                if (MessageBox.Show("本月佣金已经导入,是否需要再次导入?", "数据导入", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    return;
                }
            }
            //异步执行开始
            worker.RunWorkerAsync();
            frmProgress frm = new frmProgress(this.worker);
            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.ShowDialog(this);
            frm.Close();
            this.btnImport.Enabled = false;
           

        }
Ejemplo n.º 5
0
        /// <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("数据上传完毕");

        }
Ejemplo n.º 6
0
        /// <summary> 
        /// 查询集合 
        /// </summary> 
        /// <returns></returns> 
        public IList<ImportLog> GetList(ImportLog entity)
        {
            string sql = "SELECT type,import_month FROM import_log where import_month=@import_month and type=@type";
            using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
            {
                mycn.Open();
                MySqlCommand command = new MySqlCommand(sql, mycn);
                MySqlDataReader reader = command.ExecuteReader();
                IList<ImportLog> list = new List<ImportLog>();
                ImportLog importLog = null;
                while (reader.Read())
                {
                    importLog = new ImportLog();

                   
                    importLog.type = reader["type"] == DBNull.Value ? null : reader["type"].ToString();
                    importLog.import_month = reader["import_month"] == DBNull.Value ? null : reader["import_month"].ToString();

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