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

📄 eraaaaaa.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 DepartInfoService:IDepartInfoService
    {
        #region IBaseService<DepartInfo> 成员


        private static List<DepartInfo> GetModelsFromDataSet(DataSet ds)
        {
            List<DepartInfo> ls = new List<DepartInfo>();
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                DepartInfo model = new DepartInfo();
                model.DepartId = Convert.ToInt32(row[0]);
                model.DepartName = Convert.ToString(row[1]);
                model.PrincipalUser = Convert.ToString(row[2]);
                model.ConnectTelNo = Convert.ToDecimal(row[3]);
                model.ConnectMobileTelNo = Convert.ToDecimal(row[4]);
                model.Faxes = Convert.ToDecimal(row[5]);
                model.BranchId = Convert.ToInt32(row[6]);
                  
                ls.Add(model);
            }
            return ls;
        }

        public int AddModel(DepartInfo model)
        {
            string sql = string.Format("insert into DepartInfo values('{0}','{1}','{2}','{3}','{4}','{5}')", model.DepartName, model.PrincipalUser,
                model.ConnectTelNo,
                model.ConnectMobileTelNo,
                model.Faxes,
                model.BranchId);
            return DBOperate.UpdateModel(sql);
        }

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

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

        public int UpdateModel(DepartInfo model)
        {
            string something = string.Format(" DepartName='{0}',PrincipalUser='{1}',ConnectTelNo='{2}',ConnectMobileTelNo='{3}',Faxes='{4}', BranchId='{5}'", model.DepartName, model.PrincipalUser,
                model.ConnectTelNo,
                model.ConnectMobileTelNo,
                model.Faxes,
                model.BranchId);
            string where = string.Format(" DepartId={0} ", model.DepartId);
            return UpdateSomethingByWhere(something, where);
        }

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

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

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

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

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

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

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

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

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

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

        #endregion
    }
}

⌨️ 快捷键说明

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