public int insert(DocumentModels item)
        {
            StringBuilder sqlBuilder = new StringBuilder();
            sqlBuilder.Append("INSERT ");
            sqlBuilder.Append("INTO ");
            sqlBuilder.Append("gov_doc_draft ");
            sqlBuilder.Append("( ");
            sqlBuilder.Append("doc_code, ");
            sqlBuilder.Append("doc_name, ");
            sqlBuilder.Append("doc_summany, ");
            sqlBuilder.Append("doc_content, ");
            sqlBuilder.Append("kind_id, ");
            sqlBuilder.Append("department_id, ");
            sqlBuilder.Append("date_start_promulgate, ");
            sqlBuilder.Append("date_end_promulgate, ");
            sqlBuilder.Append("user_sign, ");
            sqlBuilder.Append("active_flg, ");
            sqlBuilder.Append("note, ");
            sqlBuilder.Append("attach_file_name, ");
            sqlBuilder.Append("attach_file_path, ");
            sqlBuilder.Append("update_username, ");
            sqlBuilder.Append("update_datetime ");
            sqlBuilder.Append(") ");
            sqlBuilder.Append("values(");
            sqlBuilder.Append("@1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15");
            sqlBuilder.Append(")");
            
            this.Sql = sqlBuilder.ToString();
            MySqlCommand objCmd = new MySqlCommand(Sql, getConnection());
            objCmd.Parameters.AddWithValue("@1", item.DocCode);
            objCmd.Parameters.AddWithValue("@2", item.DocName);
            objCmd.Parameters.AddWithValue("@3", item.DocSummany);
            objCmd.Parameters.AddWithValue("@4", null);
            objCmd.Parameters.AddWithValue("@5", item.KindId);
            objCmd.Parameters.AddWithValue("@6", item.DepartmentId);
            objCmd.Parameters.AddWithValue("@7", item.DateStartpromulgate);
            objCmd.Parameters.AddWithValue("@8", item.DateEndPromulgate);
            objCmd.Parameters.AddWithValue("@9", item.UserSign);
            objCmd.Parameters.AddWithValue("@10", item.ActiveFlg);
            objCmd.Parameters.AddWithValue("@11", item.Note);
            objCmd.Parameters.AddWithValue("@12", item.AttachFileName);
            objCmd.Parameters.AddWithValue("@13", item.AttachFilePath);
            objCmd.Parameters.AddWithValue("@14", item.UpdateUsername);
            objCmd.Parameters.AddWithValue("@15", item.UpdateDatetime);
            objCmd.ExecuteNonQuery();

            objCmd.Parameters.Clear();
            objCmd.CommandText = "SELECT @@IDENTITY";

            int identity = Convert.ToInt32(objCmd.ExecuteScalar());
            return identity;
        }
        public int update(DocumentModels item)
        {
            StringBuilder sqlBuilder = new StringBuilder();
            sqlBuilder.Append("UPDATE ");
            sqlBuilder.Append("gov_doc_draft ");
            sqlBuilder.Append("SET ");
            sqlBuilder.Append("doc_code = @1, ");
            sqlBuilder.Append("doc_name = @2, ");
            sqlBuilder.Append("doc_summany = @3, ");
            sqlBuilder.Append("doc_content = @4, ");
            sqlBuilder.Append("kind_id = @5, ");
            sqlBuilder.Append("department_id = @6, ");
            sqlBuilder.Append("date_start_promulgate = @7, ");
            sqlBuilder.Append("date_end_promulgate = @8, ");
            sqlBuilder.Append("user_sign = @9, ");
            sqlBuilder.Append("active_flg = @10, ");
            sqlBuilder.Append("note = @11, ");
            sqlBuilder.Append("attach_file_name = @12, ");
            sqlBuilder.Append("attach_file_path = @13, ");
            sqlBuilder.Append("update_username = @14, ");
            sqlBuilder.Append("update_datetime = @15 ");
            sqlBuilder.Append("WHERE ");
            sqlBuilder.Append("id = @16");

            this.Sql = sqlBuilder.ToString();
            MySqlCommand objCmd = new MySqlCommand(Sql, getConnection());
            objCmd.Parameters.AddWithValue("@1", item.DocCode);
            objCmd.Parameters.AddWithValue("@2", item.DocName);
            objCmd.Parameters.AddWithValue("@3", item.DocSummany);
            objCmd.Parameters.AddWithValue("@4", null);
            objCmd.Parameters.AddWithValue("@5", item.KindId);
            objCmd.Parameters.AddWithValue("@6", item.DepartmentId);
            objCmd.Parameters.AddWithValue("@7", item.DateStartpromulgate);
            objCmd.Parameters.AddWithValue("@8", item.DateEndPromulgate);
            objCmd.Parameters.AddWithValue("@9", item.UserSign);
            objCmd.Parameters.AddWithValue("@10", item.ActiveFlg);
            objCmd.Parameters.AddWithValue("@11", item.Note);
            objCmd.Parameters.AddWithValue("@12", item.AttachFileName);
            objCmd.Parameters.AddWithValue("@13", item.AttachFilePath);
            objCmd.Parameters.AddWithValue("@14", item.UpdateUsername);
            objCmd.Parameters.AddWithValue("@15", item.UpdateDatetime);
            objCmd.Parameters.AddWithValue("@16", item.Id);
            int rs = objCmd.ExecuteNonQuery();
            return rs;
        }
        public List<DocumentModels> select(int page, int limit)
        {
            int offset = (page - 1) * limit;
            StringBuilder sqlBuilder = new StringBuilder();
            DocumentModels item;
            sqlBuilder.Append("SELECT ");
            sqlBuilder.Append("* ");
            sqlBuilder.Append("FROM ");
            sqlBuilder.Append("gov_doc_draft gdd ");
            sqlBuilder.Append(getBaseSQL());
            if (page > 0 && limit > 0)
            {
                sqlBuilder.Append(" LIMIT @limit ");
                sqlBuilder.Append(" OFFSET @offset ");
            }
            this.Sql = sqlBuilder.ToString();

            MySqlCommand objCmd = new MySqlCommand(Sql, getConnection());
            if (page > 0 && limit > 0)
            {
                objCmd.Parameters.AddWithValue("@limit", limit);
                objCmd.Parameters.AddWithValue("@offset", offset);
            }
            MySqlDataReader dataReader = objCmd.ExecuteReader();
            List<DocumentModels> lstDocument = new List<DocumentModels>();
            while (dataReader.Read())
            {
                item = new DocumentModels();
                item.Id = Convert.ToInt32(dataReader["id"]);
                item.DocName = dataReader["doc_name"].ToString();
                item.DocCode = dataReader["doc_code"].ToString();
                item.DocContent = dataReader["doc_content"].ToString();
                item.DocSummany = dataReader["doc_summany"].ToString();
                item.DepartmentId = Convert.ToInt32(dataReader["department_id"]);
                item.KindId = Convert.ToInt32(dataReader["kind_id"]);
                item.UserSign = dataReader["user_sign"].ToString();
                item.DateStartpromulgate = Convert.ToDateTime(dataReader["date_start_promulgate"]);
                item.DateEndPromulgate = Convert.ToDateTime(dataReader["date_end_promulgate"]);
                item.AttachFileName = dataReader["attach_file_name"].ToString();
                item.AttachFilePath = dataReader["attach_file_path"].ToString();
                lstDocument.Add(item);
            }
            getConnection().Close();
            return lstDocument;
        }