Exemple #1
0
        /// <summary> 
        /// 删除数据 
        /// </summary> 
        /// <param name="entity"></param> 
        /// <returns></returns> 
        public int Delete(Group entity)
        {
            string sql = "DELETE FROM tb_group WHERE groupName=@groupName ";
            using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
            {
                mycn.Open();
                MySqlCommand command = new MySqlCommand(sql, mycn);
                command.Parameters.AddWithValue("@groupName", entity.groupName);
                command.Parameters.AddWithValue("@description", entity.description);

                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(Group entity)
        {
            string sql = "INSERT INTO tb_group (groupName,description) VALUE (@groupName,@description)";
            using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
            {
                mycn.Open();
                MySqlCommand command = new MySqlCommand(sql, mycn);
                command.Parameters.AddWithValue("@groupName", entity.groupName);
                command.Parameters.AddWithValue("@description", entity.description);

                int i = command.ExecuteNonQuery();
                mycn.Close();
                mycn.Dispose();
                return i;
            }
        }
Exemple #3
0
        /// <summary> 
        /// 修改数据 
        /// </summary> 
        /// <param name="entity"></param> 
        /// <returns></returns> 
        public int Update(Group entity)
        {
            string sql = "UPDATE  tb_group SET groupName=@groupName,description=@description where groupName=@groupName ";

            //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("@groupName", entity.groupName);
                command.Parameters.AddWithValue("@description", entity.description);

                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(3, "开始导入信息...\r\n");
            //导入代理商
            GroupDao groupDao = new GroupDao();
            Group group = new Group();
            group.groupName = this.txtGroupName.Text.Trim();
            group.description = group.groupName;
            groupDao.Delete(group);
            groupDao.Add(group);


            UserDefinedGroupDao userDefinedGroupDao = new UserDefinedGroupDao();
            for (int i = 0; i < dgAgent.RowCount; i++)
            {
                UserDefinedGroup userDefinedGroup = new UserDefinedGroup();
                userDefinedGroup.groupName = group.groupName;
                userDefinedGroup.member = dgAgent[0, i].Value.ToString();
                userDefinedGroup.type = "代理商/渠道";
                userDefinedGroupDao.Add(userDefinedGroup);
                worker.ReportProgress(4, "导入" + userDefinedGroup.member + "信息完成...\r\n");
               


            }
            //dgInvoice.AutoResizeColumns();
            
            worker.ReportProgress(5, "导入信息完成...\r\n");



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

        }
Exemple #5
0
        /// <summary> 
        /// 根据主键查询 
        /// </summary> 
        /// <param name="primaryKey"></param> 
        /// <returns></returns> 
        public Group Get(String primaryKey)
        {
            string sql = "SELECT groupName,description FROM tb_group where groupName=@groupName";
            using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
            {
                mycn.Open();
                MySqlCommand command = new MySqlCommand(sql, mycn);
                command.Parameters.AddWithValue("@groupName", primaryKey);
                MySqlDataReader reader = command.ExecuteReader();
                Group group = null;
                if (reader.Read())
                {
                    group = new Group();
                    group.groupName = reader["groupName"] == DBNull.Value ? null : reader["groupName"].ToString();

                    group.description = reader["description"] == DBNull.Value ? null : reader["description"].ToString();
                }
                mycn.Close();
                return group;
            }
        }
Exemple #6
0
        /// <summary> 
        /// 查询集合 
        /// </summary> 
        /// <returns></returns> 
        public IList<Group> GetAll(String groupName )
        {
            string sql = "SELECT distinct groupName,description FROM tb_group where 1=1";
            if (!String.IsNullOrEmpty(groupName))
            {
                sql = sql + " and groupName = \"%" + groupName + "%\"";
            }
            using (MySqlConnection mycn = new MySqlConnection(mysqlConnection))
            {
                mycn.Open();
                MySqlCommand command = new MySqlCommand(sql, mycn);

                MySqlDataReader reader = command.ExecuteReader();
                IList<Group> list = new List<Group>();
                Group group = null;
                while (reader.Read())
                {
                    group = new Group();

                    group.groupName = reader["groupName"] == DBNull.Value ? null : reader["groupName"].ToString();
                    group.description = reader["description"] == DBNull.Value ? null : reader["description"].ToString();
                    list.Add(group);
                }
                mycn.Close();
                return list;
            }
        }
Exemple #7
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (dgGroup.CurrentRow == null)
     {
         MessageBox.Show("请从组列表中选择选择一行进行删除");
         return;
     }
     this.Cursor = Cursors.WaitCursor;
     String groupName = dgGroup.CurrentRow.Cells[0].Value.ToString();
     userDefinedGroupDao.Delete(groupName);
     Group group = new Group();
     group.groupName = this.txtGroupName.Text.Trim();
     group.description = this.txtDescription.Text.Trim();
     groupDao.Delete(group);
     this.prepareGrid(this.txtKeyword.Text);
    
     this.Cursor = Cursors.Default;
     MessageBox.Show("操作完成");
 }
Exemple #8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this.txtGroupName.Text.Trim()))
            {
                MessageBox.Show("请输入组名!");
                this.txtGroupName.Focus();
                return;
            }
           
            this.Cursor = Cursors.WaitCursor;
            Group group = new Group();
            group.groupName = this.txtGroupName.Text.Trim();
            group.description = this.txtDescription.Text.Trim();
           
            userDefinedGroupDao.Delete(group.groupName);
            groupDao.Delete(group);
            groupDao.Add(group);
           
            foreach ( Object item in this.lstAssignType.Items)
            {
                UserDefinedGroup userDefinedGroup = new UserDefinedGroup();
                userDefinedGroup.groupName = group.groupName;
                userDefinedGroup.member = item.ToString();
                userDefinedGroup.type = "渠道类型";
                userDefinedGroupDao.Add(userDefinedGroup);
            }

            foreach (Object item in this.lstAssignAgent.Items)
            {
                UserDefinedGroup userDefinedGroup = new UserDefinedGroup();
                userDefinedGroup.groupName = group.groupName;
                userDefinedGroup.member = item.ToString().Substring(0, item.ToString().IndexOf(":"));
                userDefinedGroup.type = "代理商/渠道";
                userDefinedGroupDao.Add(userDefinedGroup);
            }
            this.prepareGrid(this.txtKeyword.Text);
            MessageBox.Show("操作完成");

            this.Cursor = Cursors.Default;
        }