コード例 #1
0
ファイル: Branch.cs プロジェクト: zanderphh/IvyBack_GuiZhou
        void IBLL.IBranch.Add(Model.bi_t_branch_info item)
        {
            item.update_time = System.DateTime.Now;
            string sql = "select * from bi_t_branch_info where branch_no='" + item.branch_no + "'";

            if (item.branch_no.Length == 4)
            {
                string       par_code = item.branch_no.Substring(0, 2);
                IBLL.IBranch ins      = this;
                item.branch_no = ins.MaxCode(par_code);
            }
            else if (item.branch_no.Length == 2)
            {
                string       par_code = item.branch_no.Substring(0, 2);
                IBLL.IBranch ins      = this;
                item.branch_no = ins.MaxCode("");
            }
            DB.IDB db = new DB.DBByAutoClose(Appsetting.conn);
            var    tb = db.ExecuteToTable(sql, null);

            if (tb.Rows.Count != 0)
            {
                throw new Exception("已存在机构号" + item.branch_no);
            }
            db.Insert(item);
        }