예제 #1
0
        public void bntCreate_Click(Object sender, EventArgs e)
        {
            var id       = Page.Request.Params["id"];
            var trackId  = Convert.ToInt32(ddlTrack.SelectedValue);
            var district = new Districts
            {
                Name          = tbName.Text,
                DeliveryTerms = Convert.ToInt32(tbDeliveryTerms.Text),
                Monday        = cbMonday.Checked ? 1 : 0,
                Tuesday       = cbTuesday.Checked ? 1 : 0,
                Wednesday     = cbWednesday.Checked ? 1 : 0,
                Thursday      = cbThursday.Checked ? 1 : 0,
                Friday        = cbFriday.Checked ? 1 : 0,
                Saturday      = cbSaturday.Checked ? 1 : 0,
                Sunday        = cbSunday.Checked ? 1 : 0,
                ID            = Convert.ToInt32(id),
                TrackID       = trackId
            };

            district.Update();
            var dm = new DataManager();

            dm.QueryWithoutReturnData(null, "UPDATE city SET TrackID = " + trackId + " WHERE DistrictID = " + district.ID);
            //загружаем backend в оперативную память
            var districts = new DAL.DataBaseObjects.Districts();

            Application["Districts"] = districts.GetAllItemsToList();
            Page.Response.Redirect("~/ManagerUI/Menu/Souls/DistrictsView.aspx");
        }
예제 #2
0
        public ActionResult Edit(DistrictEditModel model)
        {
            if (ModelState.IsValid)
            {
                short sysMessageId     = 0;
                byte  sysMessageTypeId = 0;
                model.SystemStatus = SystemStatus.Error;
                var district = new Districts
                {
                    CountryId    = model.CountryId,
                    ProvinceId   = model.ProvinceId,
                    DistrictId   = model.DistrictId,
                    DistrictName = model.DistrictName,
                    DistrictDesc = model.DistrictDesc,
                    DisplayOrder = model.DisplayOrder,
                    CrUserId     = model.CrUserId,
                    CrDateTime   = model.CrDateTime
                };
                sysMessageTypeId = model.CountryId > 0 ? district.Update(0, _userId, ref sysMessageId) : district.Insert(0, _userId, ref sysMessageId);

                if (sysMessageId > 0)
                {
                    var sysMessage = new SystemMessages().Get(sysMessageId);
                    if (sysMessageTypeId == CmsConstants.SystemMessageIdSuccess)
                    {
                        model.SystemStatus = SystemStatus.Success;
                    }
                    ModelState.AddModelError("SystemMessages", sysMessage.SystemMessageDesc);
                }
                else
                {
                    ModelState.AddModelError("SystemMessages", "Bạn vui lòng thử lại sau.");
                }
            }
            return(View(model));
        }