Beispiel #1
0
        /// <summary>
        /// 组合项目
        /// </summary>
        /// <returns></returns>
        public ActionResult Zhxm(int page = 1, string sfqy = "", string sxrs = "", string mc = "")
        {
            int       count = 0;
            Hashtable ht    = new Hashtable();

            ht.Add("yybh", GLYadmin.YYID);
            if (!string.IsNullOrEmpty(sfqy))
            {
                ht.Add("sfqy", sfqy);
            }
            if (!string.IsNullOrEmpty(sxrs))
            {
                ht.Add("sxrs", sxrs);
            }
            if (!string.IsNullOrEmpty(mc))
            {
                ht.Add("mc", mc);
            }
            var list        = new Service.XtzhxmService().GetZhxmList(ht, page, PageSize, ref count);
            int recordCount = count;                                                                 //总记录数

            ViewBag.Pager = PagingNewHelper.ShowFPageForBootstrapAdmin(page, PageSize, recordCount); //生成分页条
            XtJgbModel jgModel = new Service.XtjgbService().GetJg(GLYadmin.YYID);

            ViewBag.Zdbz = jgModel.zdbz;
            if (Request.IsAjaxRequest())
            {
                return(PartialView("ZhxmPart", list));
            }

            return(View(list));
        }
        /// <summary>
        /// 保存加项包
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int SaveJxb(QyJxbJbxxModel model)
        {
            int i = 0;

            using (IDbConnection conn = new DapperConnection().DbConnection)
            {
                List <QyJxbTcModel> litc = new List <QyJxbTcModel>();
                foreach (string a in model.tcbhs.Split(','))
                {
                    XttcbModel item = new XttcbService().GetTc(model.yybh, a);
                    litc.Add(new QyJxbTcModel()
                    {
                        yybh = model.yybh, tcbh = item.tcbh, tcmc = item.tcmc
                    });
                }
                List <QyJxbZhxmModel> lizhxm = new List <QyJxbZhxmModel>();
                foreach (string a in model.zhxmbhs.Split(','))
                {
                    XtZhxmbModel item = new XtzhxmService().GetZhxm(model.yybh, a);
                    lizhxm.Add(new QyJxbZhxmModel()
                    {
                        yybh = model.yybh, jg = item.zhxmjg, zhxmbh = item.zhxmbh, zhxmmc = item.zhxmmc
                    });
                }

                IDbTransaction transaction = conn.BeginTransaction();
                if (model.id == 0)
                {
                    string sql = "insert into qy_jxbjbxx(yybh,qybh,qymc,jxbmc,lrjs,syrq,sfqy,jg,xb,jsj,createtime,updatetime) values(@yybh,@qybh,@qymc,@jxbmc,@lrjs,@syrq,@sfqy,@jg,@xb,@jsj,getdate(),getdate());SELECT SCOPE_IDENTITY()";
                    string id  = conn.ExecuteScalar(sql, model, transaction).ToString();
                    model.id = int.Parse(id);
                }
                else
                {
                    string sql = "delete from qy_jxbzhxm where jxbid=@id;delete from qy_jxbtc where jxbid=@id; update qy_jxbjbxx set jxbmc=@jxbmc,lrjs=@lrjs,syrq=@syrq,sfqy=@sfqy,jg=@jg,xb=@xb,jsj=@jsj,updatetime=getdate() where id=@id";
                    conn.Execute(sql, model, transaction).ToString();
                }

                string sqlZhxm = "insert into qy_jxbzhxm(jxbid,yybh,zhxmbh,zhxmmc,jg)values(" + model.id + ",@yybh,@zhxmbh,@zhxmmc,@jg)";
                conn.Execute(sqlZhxm, lizhxm, transaction);
                string sqlTc = "insert into qy_jxbtc(jxbid,yybh,tcbh,tcmc)values(" + model.id + ",@yybh,@tcbh,@tcmc)";
                conn.Execute(sqlTc, litc, transaction);

                transaction.Commit();
                i = 1;
            }
            return(model.id);
        }