Example #1
0
        public ActionResult Create(ChufangAddViewModel model)
        {
            try
            {
                ChufangDto dto = new ChufangDto();
                dto.ChufangChuzhi     = model.ChufangChuzhi;
                dto.ChufangZhenduan   = model.ChufangZhenduan;
                dto.ChufangYongyao    = model.ChufangYongyao;
                dto.ChufangCustomerId = model.ChufangCustomerId;
                dto.ChufangTime       = System.DateTime.Now;
                if (string.IsNullOrEmpty(model.ChufangImg))
                {
                    dto.ChufangImg = "";
                }
                else
                {
                    dto.ChufangImg = model.ChufangImg;
                }

                dto.ChufangDoctor = int.Parse(System.Web.HttpContext.Current.Request.Cookies["UserId"].Value);
                string  JsonString = JsonHelper.JsonSerializerBySingleData(dto);
                Message msg        = CMSService.Insert("Chufang", JsonString);
                return(RedirectTo("/Chufang/Index/" + dto.ChufangCustomerId, msg.MessageInfo));
            }
            catch
            {
                Message msg = new Message();
                msg.MessageInfo = "上传图片好像出错了";

                return(RedirectTo("/Chufang/Create/" + model.ChufangCustomerId, msg.MessageInfo));
            }
        }
Example #2
0
        public SqlParameter[] JsonStringToSqlParameter(string jsonString)
        {
            SqlParameter[] arParames = new SqlParameter[7];
            ChufangDto     dto       = JsonHelper.JsonDeserializeBySingleData <ChufangDto>(jsonString);

            arParames[0]       = new SqlParameter("@ChufangId", SqlDbType.Int);
            arParames[0].Value = dto.ChufangId;

            arParames[1]       = new SqlParameter("@ChufangCustomerId", SqlDbType.Int);
            arParames[1].Value = dto.ChufangCustomerId;

            arParames[2]       = new SqlParameter("@ChufangZhenduan", SqlDbType.Text);
            arParames[2].Value = dto.ChufangZhenduan;

            arParames[3]       = new SqlParameter("@ChufangChuzhi", SqlDbType.Text);
            arParames[3].Value = dto.ChufangChuzhi;

            arParames[4]       = new SqlParameter("@ChufangYongyao", SqlDbType.Text);
            arParames[4].Value = dto.ChufangYongyao;

            arParames[5]       = new SqlParameter("@ChufangTime", SqlDbType.DateTime);
            arParames[5].Value = dto.ChufangTime;

            arParames[6]       = new SqlParameter("@ChufangImg", SqlDbType.VarChar, 500);
            arParames[6].Value = dto.ChufangImg;

            arParames[7]       = new SqlParameter("@ChufangDoctor", SqlDbType.Int);
            arParames[7].Value = dto.ChufangDoctor;

            return(arParames);
        }
Example #3
0
        //
        // GET: /Chufang/
        public ActionResult Index(int?p, int id)
        {
            Pager pager = new Pager();

            pager.table      = "CMSChufang";
            pager.strwhere   = "ChufangCustomerId=" + id;
            pager.PageSize   = 10;
            pager.PageNo     = p ?? 1;
            pager.FieldKey   = "ChufangId";
            pager.FiledOrder = "ChufangId Desc";
            pager            = CMSService.SelectAll("Chufang", pager);

            List <ChufangDto> list = new List <ChufangDto>();

            foreach (DataRow dr in pager.EntityDataTable.Rows)
            {
                ChufangDto dto = ChufangMapping.getDTO(dr);
                list.Add(dto);
            }
            pager.Entity = list.AsQueryable();

            ViewBag.PageNo       = p ?? 1;
            ViewBag.PageCount    = pager.PageCount;
            ViewBag.RecordCount  = pager.Amount;
            ViewBag.Message      = pager.Amount;
            ViewBag.CustomerId   = id;
            ViewBag.CustomerName = MyService.CustomerIdToName("CustomerId=" + id);
            return(View(pager.Entity));
        }
Example #4
0
        public static ChufangDto getDTO(DataRow dr)
        {
            ChufangDto dto = new ChufangDto();

            dto.ChufangId = int.Parse(dr["ChufangId"].ToString());

            dto.ChufangCustomerId = int.Parse(dr["ChufangCustomerId"].ToString());
            dto.ChufangImg        = dr["ChufangImg"].ToString();
            dto.ChufangZhenduan   = dr["ChufangZhenduan"].ToString();
            dto.ChufangChuzhi     = dr["ChufangChuzhi"].ToString();
            dto.ChufangYongyao    = dr["ChufangYongyao"].ToString();
            dto.ChufangTime       = DateTime.Parse(dr["ChufangTime"].ToString());
            dto.ChufangDoctor     = int.Parse(dr["ChufangDoctor"].ToString());



            return(dto);
        }