Пример #1
0
        /// <summary>
        /// 单个查询
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Node GetModel(int id)
        {
            BranchRecord model = new BranchRecord();

            model.GetModel(id);
            Node node = new Node();

            node.id     = model.id.ToString();
            node.NSRMC  = model.NSRMC;
            node.NSRSBH = model.NSRSBH;
            node.JYDZ   = model.JYDZ;
            node.ZGSWJG = model.ZGSWJG;
            node.SFNSZT = model.SFNSZT ? 1 : 0;
            node.KYSJ   = model.KYSJ.ToString("yyyy-MM-dd");
            if (model.ZXSJ != null)
            {
                node.ZXSJ = Convert.ToDateTime(model.ZXSJ).ToString("yyyy-MM-dd");
            }
            else
            {
                node.ZXSJ = "";
            }
            node.SJJGMC     = model.SJJGMC;
            node.SJJGSFNSZT = model.SJJGSFNSZT ? 1 : 0;
            node.CREATEID   = model.CREATEID;
            node.CREATETIME = model.CREATETIME.ToString("yyyy-MM-dd HH:mm:ss");
            return(node);
        }
Пример #2
0
        /// <summary>
        /// 批量导入
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public bool BatchAdd(IList <Node> list)
        {
            //将IList<Node>转成DataTable
            DataTable dt = new DataTable("BranchRecord");

            dt.Columns.Add("id");
            dt.Columns.Add("NSRMC");
            dt.Columns.Add("NSRSBH");
            dt.Columns.Add("JYDZ");
            dt.Columns.Add("ZGSWJG");
            dt.Columns.Add("SFNSZT", typeof(bool));
            dt.Columns.Add("KYSJ", typeof(DateTime));
            dt.Columns.Add("ZXSJ", typeof(DateTime));
            dt.Columns.Add("SJJGMC");
            dt.Columns.Add("SJJGSFNSZT", typeof(bool));
            dt.Columns.Add("ISDELETE", typeof(bool));
            dt.Columns.Add("CREATEID", typeof(int));
            dt.Columns.Add("CREATETIME", typeof(DateTime));
            dt.Columns.Add("EDITID", typeof(int));
            dt.Columns.Add("EDITTIME", typeof(DateTime));
            dt.Columns.Add("DELETEID", typeof(int));
            dt.Columns.Add("DELETETIME", typeof(DateTime));
            for (int i = 0; i < list.Count; i++)
            {
                string NSRMC  = list[i].NSRMC;
                string NSRSBH = list[i].NSRSBH;
                if (this.Count(NSRMC, string.Empty) != 0)
                {
                    throw new ArgumentException(string.Format("纳税人名称:{0},已存在", NSRMC));
                }
                if (this.Count("", NSRSBH) != 0)
                {
                    throw new ArgumentException(string.Format("纳税人识别号:{0},已存在", NSRSBH));
                }
                DataRow row = dt.NewRow();
                row[1] = list[i].NSRMC;
                row[2] = list[i].NSRSBH;
                row[3] = list[i].JYDZ;
                row[4] = list[i].ZGSWJG;
                row[5] = list[i].SFNSZT == 1 ? true : false;
                row[6] = list[i].KYSJ;
                DateTime Temp_ZXSJ = new DateTime();
                if (DateTime.TryParse(list[i].ZXSJ, out Temp_ZXSJ))
                {
                    row[7] = list[i].ZXSJ;
                }
                row[8]  = list[i].SJJGMC;
                row[9]  = list[i].SJJGSFNSZT;
                row[10] = false;
                row[11] = list[i].CREATEID;
                row[12] = list[i].CREATETIME;
                dt.Rows.Add(row);
            }
            BranchRecord branch = new BranchRecord();

            return(branch.BatchAdd(dt));
        }
Пример #3
0
        /// <summary>
        /// 查询列表
        /// </summary>
        /// <returns></returns>
        public Grid GetList(BranchListQueryParm parm)
        {
            BranchRecord  model   = new BranchRecord();
            StringBuilder builder = new StringBuilder();

            if (parm != null)
            {
                #region 拼接SQL筛选条件
                if (!string.IsNullOrEmpty(parm.NSRMC) && parm.NSRMC.Trim().Length > 0)
                {
                    builder.Append(string.Format(" AND NSRMC like '%{0}%' ", parm.NSRMC));
                }
                if (!string.IsNullOrEmpty(parm.NSRSBH) && parm.NSRSBH.Trim().Length > 0)
                {
                    builder.Append(string.Format(" AND NSRSBH like '%{0}%' ", parm.NSRSBH));
                }
                if (parm.SFNSZT == 0 || parm.SFNSZT == 1)
                {
                    builder.Append(string.Format(" AND SFNSZT = {0} ", parm.SFNSZT));
                }
                #endregion
            }
            Grid      grid  = new Grid();
            DataTable table = model.GetList(builder.ToString());
            foreach (DataRow row in table.Rows)
            {
                Node node = new Node();
                node.id     = row["id"].ToString();
                node.NSRMC  = row["NSRMC"].ToString();
                node.NSRSBH = row["NSRSBH"].ToString();
                node.JYDZ   = row["JYDZ"].ToString();
                node.ZGSWJG = row["ZGSWJG"].ToString();
                node.SFNSZT = ConvertHelper.ToBoolean(row["SFNSZT"]) ? 1 : 0;
                node.KYSJ   = Convert.ToDateTime(row["KYSJ"]).ToString("yyyy-MM-dd");
                if (row["ZXSJ"] != DBNull.Value)
                {
                    node.ZXSJ = Convert.ToDateTime(row["ZXSJ"]).ToString("yyyy-MM-dd");
                }
                else
                {
                    node.ZXSJ = "";
                }
                node.SJJGMC     = row["SJJGMC"].ToString();
                node.SJJGSFNSZT = ConvertHelper.ToBoolean(row["SJJGSFNSZT"]) ? 1 : 0;
                grid.Rows.Add(node);
            }
            grid = GetTreeMap(grid);
            //按显示的数据导出Excel

            return(grid);
        }
Пример #4
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public int Edit(Node node)
        {
            BranchRecord branch = new BranchRecord();

            branch.id     = ConvertHelper.ToInt(node.id);
            branch.NSRMC  = node.NSRMC;
            branch.NSRSBH = node.NSRSBH;
            branch.JYDZ   = node.JYDZ;
            branch.ZGSWJG = node.ZGSWJG;
            branch.SFNSZT = node.SFNSZT == 1 ? true : false;
            branch.KYSJ   = Convert.ToDateTime(node.KYSJ);
            if (string.IsNullOrEmpty(node.ZXSJ))
            {
                branch.ZXSJ = null;
            }
            else
            {
                branch.ZXSJ = Convert.ToDateTime(node.ZXSJ);
            }
            branch.SJJGMC     = node.SJJGMC;
            branch.SJJGSFNSZT = node.SJJGSFNSZT == 1 ? true : false;
            branch.CREATEID   = node.CREATEID;
            branch.CREATETIME = Convert.ToDateTime(node.CREATETIME);
            branch.EDITID     = node.EDITID;
            branch.EDITTIME   = DateTime.Now;
            //验证上级机构是否存在
            if (node.SJJGMC.Length > 0 && Count(node.SJJGMC, string.Empty) == 0)
            {
                throw new ArgumentException("上级机构名称: " + branch.SJJGMC + ", 不存在,请先录入该机构");
            }
            //检查纳税人名称是否不存在
            if (this.Count(branch.id, branch.NSRMC, string.Empty) != 0)
            {
                throw new ArgumentException("纳税人名称:" + branch.NSRMC + ",已存在");
            }
            if (this.Count(branch.id, string.Empty, branch.NSRSBH) != 0)
            {
                throw new ArgumentException("纳税人识别号:" + branch.NSRSBH + ",已存在");
            }
            bool flag = branch.Update();

            if (flag == true)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Пример #5
0
        /// <summary>
        /// 纳税人名称与纳税人识别号是否唯一,除了某个ID之外,编辑时会用到
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Count(int id, string NSRMC, string NSRSBH)
        {
            BranchRecord branch = new BranchRecord();

            if (NSRMC.Length == 0 && NSRSBH.Length > 0)
            {
                return(branch.CountNSRSBH(NSRSBH, id));
            }
            else if (NSRMC.Length > 0 && NSRSBH.Length == 0)
            {
                return(branch.CountNSRMC(NSRMC, id));
            }
            else
            {
                throw new Exception("纳税人名称与识别号不能为空,也不能同时有值");
            }
        }
Пример #6
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public int Add(Node node)
        {
            BranchRecord branch = new BranchRecord();

            branch.NSRMC  = node.NSRMC;
            branch.NSRSBH = node.NSRSBH;
            branch.JYDZ   = node.JYDZ;
            branch.ZGSWJG = node.ZGSWJG;
            branch.SFNSZT = node.SFNSZT == 1 ? true : false;
            branch.KYSJ   = Convert.ToDateTime(node.KYSJ);
            if (string.IsNullOrEmpty(node.ZXSJ))
            {
                branch.ZXSJ = null;
            }
            else
            {
                branch.ZXSJ = Convert.ToDateTime(node.ZXSJ);
            }
            branch.SJJGMC     = node.SJJGMC;
            branch.SJJGSFNSZT = node.SJJGSFNSZT == 1 ? true : false;
            branch.CREATEID   = node.CREATEID;
            branch.CREATETIME = Convert.ToDateTime(node.CREATETIME);
            //验证上级机构是否存在
            if (node.SJJGMC.Length > 0 && Count(node.SJJGMC, string.Empty) == 0)
            {
                throw new ArgumentException("上级机构名称: " + branch.SJJGMC + ", 不存在,请先录入该机构");
            }
            //检查纳税人名称是否不存在
            if (this.Count(node.NSRMC, string.Empty) != 0)
            {
                throw new ArgumentException("纳税人名称: " + branch.NSRMC + ", 已存在");
            }
            if (this.Count("", node.NSRSBH) != 0)
            {
                throw new ArgumentException("纳税人识别号: " + branch.NSRSBH + ", 已存在");
            }
            int num = branch.Add();

            return(num);
        }
Пример #7
0
        /// <summary>
        /// 获取总数
        /// </summary>
        /// <returns></returns>
        public int Count()
        {
            BranchRecord branch = new BranchRecord();

            return(branch.Count());
        }
Пример #8
0
        /// <summary>
        /// 判断上级机构名称是否存在
        /// </summary>
        /// <param name="SJJGMC"></param>
        /// <returns></returns>
        public int CountSJJGMC(string SJJGMC)
        {
            BranchRecord branch = new BranchRecord();

            return(branch.CountNSRMC(SJJGMC));
        }
Пример #9
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool Delete(int id, int userId)
        {
            BranchRecord branch = new BranchRecord();

            return(branch.DeleteAll(id, userId));
        }
Пример #10
0
        /// <summary>
        /// 遍历所有数据
        /// </summary>
        /// <returns></returns>
        public DataTable GetExcelExportDataTable()
        {
            BranchRecord model = new BranchRecord();

            return(model.GetExcelExportDataTable(""));
        }