Exemplo n.º 1
0
        public ActionResult Insert(TestMasterInfo entity, bool isPartialView = false, string fun = null)
        {
            if (!string.IsNullOrEmpty(fun) && fun == "Cancel")
            {
                return(Content(""));
            }
            var biz = new TestBiz.Master();

            if (biz.Load(null, null, entity.NO) != null)
            {
                ModelState.AddModelError("NO", "編號已存在");
            }

            if (ModelState.IsValid)//如果必要有值的話就執行 不然就拋回去
            {
                if (biz.Insert(entity) > 0)
                {
                    //return Read(new TestMasterInfo.Conditions { ID = entity.ID, NO = entity.NO });
                    string js = string.Format("$('#dumyID').val('{0}');$('#dumyList').submit();$('#dumyRead').submit();", entity.ID);
                    return(JavaScript(js));
                }
            }
            if (isPartialView)
            {
                return(PartialView("~/Views/Shared/Test/_Create.cshtml", entity));
            }
            else
            {
                return(View(entity));
            }
        }
Exemplo n.º 2
0
        protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = false;
            var cv  = (CustomValidator)source;
            var ctl = fvMaster.FindControl(cv.ControlToValidate);

            if (ctl != null)
            {
                var c = (TextBox)ctl;
                if (!string.IsNullOrEmpty(c.Text))
                {
                    var biz = new TestBiz.Master();
                    var e   = biz.Load(null, null, c.Text.Trim());
                    if (e == null)
                    {
                        args.IsValid = true;
                    }
                    else
                    {
                        cv.ErrorMessage = "編號重複";
                    }
                }
                else
                {
                    cv.ErrorMessage = "請輸入";
                }
            }
        }
Exemplo n.º 3
0
        protected void bindMasterDetail(int?SID, string ID)
        {
            TestBiz.Master biz = new TestBiz.Master();
            TestMasterInfo e   = biz.Load(SID, ID, null); //單條件查詢(因查詢到後,點選取,只會load一筆出來顯示在Detail)

            dvMaster.DataSource = (e == null ? new List <TestMasterInfo> {
            } :new List <TestMasterInfo> {
                e
            });
            dvMaster.DataBind();
        }
Exemplo n.º 4
0
        protected void bindMasterForm(int?SID, string ID)
        {
            TestBiz.Master biz = new TestBiz.Master();
            TestMasterInfo e   = biz.Load(SID, ID, null);

            fvMaster.DataSource = e == null ? new List <TestMasterInfo>() : new List <TestMasterInfo> {
                e
            };
            fvMaster.DataBind();
            upFormView.Update();
        }
Exemplo n.º 5
0
        protected void bindMaster(string name)
        {
            TestBiz.Master biz         = new TestBiz.Master();
            var            _pagination = pagination;
            DataTable      dt          = biz.Load(ref _pagination, Name: name);

            pagination          = _pagination;
            gvMaster.DataSource = dt; //先存他的SOURCE
            gvMaster.DataBind();      //在BIND
            Pager.pagination = pagination;
            upGridView.Update();
        }
Exemplo n.º 6
0
        protected void bindMaster(string name)
        {
            TestBiz.Master biz         = new TestBiz.Master();
            var            _pagination = pagination;
            DataTable      dt          = biz.Load(pagination: ref _pagination, Name: name);//多條件查詢

            pagination          = _pagination;
            gvMaster.DataSource = dt;
            gvMaster.DataBind();

            Pager.pagination = pagination;
            Pager.Bind       = true;
        }
Exemplo n.º 7
0
        public ActionResult Do(string mode, int?sid = null, string id = null)
        {
            switch (mode)
            {
            case "Insert":
                return(Create(true));

            case "Edit":
                var biz = new TestBiz.Master();
                return(Edit(biz.Load(SID: sid, ID: id, null)));

            case "Delete":
                return(Delete(id));
            }
            return(JavaScript(""));
        }
Exemplo n.º 8
0
        protected void bindMasterDetails(int?SID, string ID)
        {
            TestBiz.Master biz = new TestBiz.Master();
            TestMasterInfo e   = biz.Load(SID, ID, null);

            //防呆 e == null ? new List<TestMasterInfo>()

            dvMaster.DataSource = e == null ? new List <TestMasterInfo>(): new List <TestMasterInfo> {
                e
            };
            dvMaster.DataBind();


            //gvMaster.DataSource = dt;
            //gvMaster.DataBind();
        }
Exemplo n.º 9
0
        // POST api/<controller>
        public dynamic Post(string id, [FromBody] dynamic value)
        {
            bool result = false;

            if (id == "load")
            {
                ModelRequest    model      = JsonConvert.DeserializeObject <ModelRequest>(JsonConvert.SerializeObject(value));
                var             biz        = new TestBiz.Master();
                PageInationInfo pagination = model.pagination;

                ModelResponse resultLoad = new ModelResponse {
                    conditions = model.conditions
                };
                resultLoad.data = biz.Load(ref pagination, model.conditions).AsEnumerable()
                                  .Select(i => new TestMasterInfo
                {
                    SID        = i.Field <int>("SID"),
                    ID         = i.Field <string>("ID"),
                    NO         = i.Field <string>("NO"),
                    Name       = i.Field <string>("Name"),
                    Address    = i.Field <string>("Address"),
                    Phone      = i.Field <string>("Phone"),
                    Age        = i.Field <decimal?>("Age"),
                    Birthday   = i.Field <DateTime?>("Birthday"),
                    CreateTime = i.Field <DateTime>("CreateTime"),
                    UpdaueTime = i.Field <DateTime>("UpdaueTime")
                })
                                  .ToList();
                resultLoad.pagination = new ModelResponse.PaginationInfo {
                    Index = pagination.Index, Size = pagination.Size, Total = pagination.Total
                };
                return(resultLoad);
            }
            if (id == "create")
            {
                TestMasterInfo model = JsonConvert.DeserializeObject <TestMasterInfo>(JsonConvert.SerializeObject(value));
                if (ModelState.IsValid)
                {
                    var biz = new TestBiz.Master();
                    return(biz.Insert(model));
                }
                return("資料驗證錯誤");
            }
            return(result);
        }
Exemplo n.º 10
0
        protected void bindMasterForm(int?SID, string ID)
        {
            //var Control = fvMaster.FindControl("ddlAddress");
            //if (Control != null)
            //{
            //    var ddl = ((DropDownList)Control);
            //    ddl.DataSource = Address();
            //    ddl.DataBind();
            //}

            TestBiz.Master biz = new TestBiz.Master();
            TestMasterInfo e   = biz.Load(SID, ID, null);

            fvMaster.DataSource = e == null ? new List <TestMasterInfo>() : new List <TestMasterInfo> {
                e
            };
            fvMaster.DataBind();
        }
Exemplo n.º 11
0
        // GET api/<controller>/5
        public TestMasterInfo Get(string id)
        {
            var biz = new TestBiz.Master();

            return(biz.Load(SID: null, ID: id, NO: null));
        }