Ejemplo n.º 1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (cmbDistrictName.SelectedValue == null)
            {
                DISTRICT district = new DISTRICT();
                district.DISTRICT_NAME = cmbDistrictName.Text;
                data.Insert <DISTRICT>(district);
            }
            if (cmbTalukName.SelectedValue == null)
            {
                TALUK taluk = new TALUK();
                taluk.TALUK_NAME  = cmbTalukName.Text;
                taluk.DISTRICT_ID = selectedDistrict = cmbDistrictName.SelectedValue == null?data.GetAll <DISTRICT>().Max(s => s.DISTRICT_ID) : Convert.ToInt32(cmbDistrictName.SelectedValue);

                data.Insert <TALUK>(taluk);
            }
            if (null != txtVillageName.Text && txtVillageName.Text != string.Empty)
            {
                VILLAGE village = new VILLAGE();
                village.VILLAGE_NAME = txtVillageName.Text;
                village.TALUK_ID     = selectedTaluk = cmbTalukName.SelectedValue == null?data.GetAll <TALUK>().Max(s => s.TALUK_ID) : Convert.ToInt32(cmbTalukName.SelectedValue);

                data.Insert(village);
                MessageBox.Show("New Village Added Succesfully.");
            }

            txtVillageName.Text = string.Empty;

            BindGrid();
            cmbDistrictName.ItemsSource   = data.GetAll <DISTRICT>().Select(s => new { Id = s.DISTRICT_ID, Name = s.DISTRICT_NAME });
            cmbDistrictName.SelectedValue = cmbDistrictName.SelectedValue == null ? selectedDistrict : Convert.ToInt32(cmbDistrictName.SelectedValue);;
            cmbTalukName.ItemsSource      = data.GetAll <TALUK>(s => s.DISTRICT_ID == Convert.ToInt32(cmbDistrictName.SelectedValue)).Select(s => new { Id = s.TALUK_ID, Name = s.TALUK_NAME });
            cmbTalukName.SelectedValue    = cmbTalukName.SelectedValue == null ? selectedTaluk : Convert.ToInt32(cmbTalukName.SelectedValue);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            DISTRICT dISTRICT = db.DISTRICT.Find(id);

            db.DISTRICT.Remove(dISTRICT);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteConfirmed(short id)
        {
            DISTRICT district = db.DISTRICTs.Find(id);

            db.DISTRICTs.Remove(district);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
        public MdlDistrictandTehsils EditDistrict(int id)
        {
            DISTRICT item = _dbFirms.DISTRICTs.Where(x => x.DistrictID == id).SingleOrDefault();
            MdlDistrictandTehsils model = new MdlDistrictandTehsils();

            model.DistrictID   = item.DistrictID;
            model.DistrictName = item.DistrictName;
            return(model);
        }
Ejemplo n.º 5
0
        public DISTRICT DistrictAdd(string loginKey, ref ErrorInfo err, DISTRICT inEnt)
        {
            using (DBEntities db = new DBEntities())
            {
                YL_DISTRICT reEnt = Fun.ClassToCopy <ProInterface.Models.DISTRICT, YL_DISTRICT>(inEnt);
                #region 计算ID_PATH和Level_ID
                if (reEnt.PARENT_ID == null)
                {
                    reEnt.LEVEL_ID = 1;
                    reEnt.ID_PATH  = ".";
                }
                else
                {
                    var parent = db.YL_DISTRICT.Single(x => x.ID == reEnt.PARENT_ID);
                    if (parent == null)
                    {
                        reEnt.LEVEL_ID = 1;
                        reEnt.ID_PATH  = ".";
                    }
                    else
                    {
                        reEnt.ID_PATH  = parent.ID_PATH + reEnt.PARENT_ID + ".";
                        reEnt.LEVEL_ID = parent.LEVEL_ID + 1;
                    }
                }
                #endregion
                reEnt.ID = Fun.GetSeqID <YL_DISTRICT>();
                #region 计算REGION

                GlobalUser gu = Global.GetUser(loginKey);
                if (gu == null)
                {
                    reEnt.REGION = reEnt.ID.ToString();
                }
                else
                {
                    reEnt.REGION = gu.Region;
                }
                #endregion
                reEnt.CODE   = (string.IsNullOrEmpty(inEnt.CODE)) ? reEnt.ID.ToString() : inEnt.CODE;
                reEnt.IN_USE = 1;
                reEnt        = db.YL_DISTRICT.Add(reEnt);
                try
                {
                    db.SaveChanges();
                    UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Add);
                    return(Fun.ClassToCopy <YL_DISTRICT, DISTRICT>(reEnt));
                }
                catch (Exception e)
                {
                    err.IsError = true;
                    err.Message = e.Message;
                    err.Excep   = e;
                    return(null);
                }
            }
        }
Ejemplo n.º 6
0
        //
        // GET: /District/Details/5

        public ActionResult Details(short id = 0)
        {
            DISTRICT district = db.DISTRICTs.Find(id);

            if (district == null)
            {
                return(HttpNotFound());
            }
            return(View(district));
        }
Ejemplo n.º 7
0
        protected override EntityBase CreateAndBuildEntity(DataHelper.Framework.SafeDataReader dr)
        {
            DISTRICT theEntity = new DISTRICT();

            theEntity.PK_ID = !dr.IsDBNull(0) ? dr.GetValue(0).ToString() : string.Empty;

            theEntity.DISTRICT_NAME = !dr.IsDBNull(1) ? dr.GetValue(1).ToString() : string.Empty;

            return(theEntity);
        }
 public ActionResult Edit([Bind(Include = "DISTRICT_NAME")] DISTRICT dISTRICT)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dISTRICT).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dISTRICT));
 }
Ejemplo n.º 9
0
        public void CreateDistrict(string DistrictName)
        {
            var t = new DISTRICT
            {
                DistrictName = DistrictName
            };

            _dbFirms.DISTRICTs.Add(t);
            _dbFirms.SaveChanges();
        }
Ejemplo n.º 10
0
        public ActionResult Create([Bind(Include = "DISTRICT_NAME")] DISTRICT dISTRICT)
        {
            if (ModelState.IsValid)
            {
                db.DISTRICT.Add(dISTRICT);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dISTRICT));
        }
Ejemplo n.º 11
0
 public ActionResult Edit(DISTRICT district)
 {
     if (ModelState.IsValid)
     {
         db.Entry(district).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.COUNTRYSLNO = new SelectList(db.COUNTRies, "COUNTRYSLNO", "COUNTRYCODE", district.COUNTRYSLNO);
     return(View(district));
 }
Ejemplo n.º 12
0
        //
        // GET: /District/Edit/5

        public ActionResult Edit(short id = 0)
        {
            DISTRICT district = db.DISTRICTs.Find(id);

            if (district == null)
            {
                return(HttpNotFound());
            }
            ViewBag.COUNTRYSLNO = new SelectList(db.COUNTRies, "COUNTRYSLNO", "COUNTRYCODE", district.COUNTRYSLNO);
            return(View(district));
        }
Ejemplo n.º 13
0
        public ActionResult Create(DISTRICT district)
        {
            if (ModelState.IsValid)
            {
                db.DISTRICTs.Add(district);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.COUNTRYSLNO = new SelectList(db.COUNTRies, "COUNTRYSLNO", "COUNTRYCODE", district.COUNTRYSLNO);
            return(View(district));
        }
Ejemplo n.º 14
0
 public void UpdateDistrict(string DistrictName, int DistrictID)
 {
     try
     {
         DISTRICT item = _dbFirms.DISTRICTs.Where(x => x.DistrictID == DistrictID).SingleOrDefault();
         item.DistrictName = DistrictName;
         _dbFirms.SaveChanges();
     }
     catch
     {
     }
 }
Ejemplo n.º 15
0
        public bool DeleteDistrict(DISTRICT district)
        {
            var isDeleted = sportsSideService.DeleteDistrict(district);

            if (isDeleted)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 16
0
 public bool DeleteDistrict(DISTRICT district)
 {
     try
     {
         db.Entry(district).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Ejemplo n.º 17
0
 public bool PostDistrict(DISTRICT district)
 {
     try
     {
         db.DISTRICT.Add(district);
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Ejemplo n.º 18
0
        public bool PutDistrict(DISTRICT district)
        {
            var isUpdated = sportsSideService.PutDistrict(district);

            if (isUpdated)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 19
0
        // GET: Districts/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DISTRICT dISTRICT = db.DISTRICT.Find(id);

            if (dISTRICT == null)
            {
                return(HttpNotFound());
            }
            return(View(dISTRICT));
        }
Ejemplo n.º 20
0
        protected override IDbDataParameter[] CreateSelectParameters(EntityBase anEntity)
        {
            DISTRICT theEntity = (DISTRICT)anEntity;
            List <IDbDataParameter> cmdParams = new List <IDbDataParameter>();

            if (!string.IsNullOrEmpty(theEntity.PK_ID))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_PK_ID", theEntity.PK_ID));
            }

            if (!string.IsNullOrEmpty(theEntity.DISTRICT_NAME))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("VAR_DISTRICT_NAME", theEntity.DISTRICT_NAME));
            }

            cmdParams.Add(DataAccessFactory.CreateDataParameter("Result", ""));

            return(cmdParams.ToArray());
        }
Ejemplo n.º 21
0
 public bool DistrictSave(string loginKey, ref ErrorInfo err, DISTRICT inEnt, IList <string> allPar = null)
 {
     if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
     {
         return(false);
     }
     using (DBEntities db = new DBEntities())
     {
         var ent = db.fa_district.SingleOrDefault(a => a.ID == inEnt.ID);
         if (ent == null)
         {
             ent = Mapper.Map <fa_district>(inEnt);
             db.fa_district.Add(ent);
         }
         else
         {
             ent = Fun.ClassToCopy <DISTRICT, fa_district>(inEnt, ent, allPar);
         }
         return(Fun.DBEntitiesCommit(db, ref err));
     }
 }
Ejemplo n.º 22
0
        public bool DistrictEdit(string loginKey, ref ErrorInfo err, DISTRICT inEnt, IList <string> allPar)
        {
            if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
            {
                return(false);
            }
            using (DBEntities db = new DBEntities())
            {
                try
                {
                    var reEnt = db.YL_DISTRICT.SingleOrDefault(a => a.ID == inEnt.ID);
                    if (reEnt.PARENT_ID != inEnt.PARENT_ID)
                    {
                        var parentOld = db.YL_DISTRICT.SingleOrDefault(x => x.ID == reEnt.PARENT_ID);
                        var pathOld   = (parentOld == null) ? "." : parentOld.ID_PATH + parentOld.ID + ".";
                        var parentNew = db.YL_DISTRICT.SingleOrDefault(x => x.ID == inEnt.PARENT_ID);
                        var pathNew   = (parentNew == null) ? "." : parentNew.ID_PATH + parentNew.ID + ".";
                        if (parentOld == null)
                        {
                            parentOld = new YL_DISTRICT();
                        }
                        if (parentNew == null)
                        {
                            parentNew = new YL_DISTRICT();
                        }
                        int levelChange = parentNew.LEVEL_ID - parentOld.LEVEL_ID;

                        reEnt.LEVEL_ID = parentNew.LEVEL_ID + 1;
                        reEnt.ID_PATH  = pathNew;
                        DistrictSetLevelId(reEnt.ID, reEnt.LEVEL_ID, reEnt.ID_PATH, db);
                        //var t = db.YL_DISTRICT.Where(x => x.ID_PATH.IndexOf(pathOld) == 0).Update(x => new YL_DISTRICT { ID_PATH = x.ID_PATH.Replace(pathOld, pathNew), LEVEL_ID = x.LEVEL_ID + levelChange });
                    }
                    else
                    {
                        var parentNew = db.YL_DISTRICT.SingleOrDefault(x => x.ID == inEnt.PARENT_ID);
                        if (parentNew == null)
                        {
                            reEnt.LEVEL_ID = 1;
                            reEnt.ID_PATH  = ".";
                        }
                        else
                        {
                            reEnt.LEVEL_ID = parentNew.LEVEL_ID + 1;
                            reEnt.ID_PATH  = parentNew.ID_PATH + parentNew.ID + ".";
                        }
                    }
                    reEnt = Fun.ClassToCopy <ProInterface.Models.DISTRICT, YL_DISTRICT>(inEnt, reEnt, allPar);

                    db.SaveChanges();
                    UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Edit);
                    return(true);
                }
                catch (Exception e)
                {
                    err.IsError = true;
                    err.Message = e.Message;
                    err.Excep   = e;
                    return(false);
                }
            }
        }