public ActionResult Create(FormCollection frm)
        {
            A_Location saveLoc = new A_Location();

            saveLoc.LocationName = frm["LocationName"];
            saveLoc.LocationCode = frm["LocationCode"].ToUpper();
            saveLoc.DepartmentId = Convert.ToInt32(frm["DepartmentId"]);
            saveLoc.EnteredDate  = DateTime.Now;
            saveLoc.EnteredBy    = Convert.ToInt32(Session["UserId"]);

            db.AddLocation(saveLoc);
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(FormCollection frm, int?id)
        {
            A_Location updateLoc = new A_Location();

            updateLoc.LocationName = frm["LocationName"];
            updateLoc.LocationCode = frm["LocationCode"].ToUpper();
            updateLoc.DepartmentId = Convert.ToInt32(frm["DepartmentId"]);

            updateLoc.LastUpdatedDate = DateTime.Now;
            updateLoc.LastUpdatedBy   = Convert.ToInt32(Session["UserId"]);

            db.UpdateLocation(updateLoc, (int)id);
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public int AddLocation(A_Location saveLoc)
        {
            string sql = "insert into A_Location(LocationName,LocationCode,DepartmentId,EnteredBy,EnteredDate,LastUpdatedBy,LastUpdatedDate," +
                         "IsDeleted,DeletedBy,DeletedDate)" +
                         " values(@LocationName,@LocationCode,@DepartmentId,@EnteredBy,@EnteredDate,0,null," +
                         "0,0,null)";

            using (var db = DbHelper.GetDBConnection())
            {
                int id = db.Query <int>(sql, saveLoc).SingleOrDefault();
                db.Close();
                return(id);
            }
        }
Beispiel #4
0
        public bool UpdateLocation(A_Location updateLoc, int Id)
        {
            string sql = " Update A_Location set LocationName=@LocationName, LocationCode=@LocationCode, DepartmentId=@DepartmentId," +
                         "LastUpdatedDate=@LastUpdatedDate, LastUpdatedBy=@LastUpdatedBy where IsDeleted=0 and LocationId= " + Id;

            using (var db = DbHelper.GetDBConnection())
            {
                var lst = db.Execute(sql, updateLoc);
                db.Close();
                if (lst > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }