⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nraaaaaa.a

📁 人事管理系统
💻 A
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using MODEL;
using DBManage;
using IDAL;

namespace SQLServerDAL
{
    public class MyNoteService:IMyNoteService
    {
        #region IBaseService<MyNote> 成员


        private static List<MyNote> GetModelsFromDataSet(DataSet ds)
        {
            List<MyNote> ls = new List<MyNote>();
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                MyNote model = new MyNote();
                model.NoteId = Convert.ToInt32(row[0]);
                model.NoteTitle = Convert.ToString(row[1]);
                model.NoteContent = Convert.ToString(row[2]);
                model.CreateTime = Convert.ToString(row[3]);
                model.CreateUser = Convert.ToString(row[4]);
                ls.Add(model);
            }
            return ls;
        }

        public int AddModel(MyNote model)
        {
            string sql = string.Format("insert into MyNote values('{0}','{1}','{2}','{3}')", model.NoteTitle,model.NoteContent,model.CreateTime,model.CreateUser);
            return DBOperate.UpdateModel(sql);
        }

        public int DeleteModelById(int id)
        {
            string where = " MyNoteid=" + id;
            return DeleteModelByWhere(where);
        }

        public int DeleteModelByWhere(string where)
        {
            string sql = string.Format("delete MyNote");
            if (!string.IsNullOrEmpty(where))
            {
                sql = sql + " where " + where;
            }
            return DBOperate.UpdateModel(sql);
        }

        public int UpdateModel(MyNote model)
        {
            string something = string.Format(" NoteTitle='{0}',NoteContent='{1}',CreateTime='{2}',CreateUser='{3}' ", model.NoteTitle, model.NoteContent, model.CreateTime, model.CreateUser);
            string where = string.Format(" NoteId={0} ", model.NoteId);
            return UpdateSomethingByWhere(something, where);
        }

        public int UpdateSomethingByWhere(string something, string where)
        {
            string sql = "update MyNote set " + something;
            if (!string.IsNullOrEmpty(where))
            {
                sql = sql + " where " + where;
            }
            return DBOperate.UpdateModel(sql);
        }

        public List<MyNote> GetAllModels()
        {
            DataSet ds = DBOperate.GetModels("MyNote", "");
            return GetModelsFromDataSet(ds);
        }

        public MyNote GetModelById(int id)
        {
            DataSet ds = DBOperate.GetModels("MyNote", "NoteId=" + id);
            return GetModelsFromDataSet(ds)[0];
        }

        public List<MyNote> GetModelByForeignKey(int ForeignKeyID)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public List<MyNote> GetModels(string strWhere)
        {
            DataSet ds = DBOperate.GetModels("MyNote", strWhere);
            return GetModelsFromDataSet(ds);
        }

        public List<MyNote> GetModels(int pageIndex, int pageSize, string orderColumnsName, string strWhere)
        {
            DataSet ds = DBOperate.GetModels("MyNote", pageIndex, pageSize, orderColumnsName, strWhere);
            return GetModelsFromDataSet(ds);
        }

        public List<MyNote> GetModels(int pageIndex, int pageSize, string orderColumnsName)
        {
            return GetModels(pageIndex, pageSize, orderColumnsName, "");
        }

        public List<MyNote> GetModels(int pageIndex, string orderColumnsName)
        {
            return GetModels(pageIndex, 10, orderColumnsName, "");
        }

        public List<MyNote> GetModels(int pageIndex, int pageSize)
        {
            return GetModels(pageIndex, pageSize, "NoteId", "");
        }

        public List<MyNote> GetModels(int pageIndex)
        {
            return GetModels(pageIndex, 10, "NoteId", "");
        }

        #endregion
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -