Exemplo n.º 1
0
        public ActionResult edit(string id, string gid)
        {
            Populate DropDown = new Populate();
            List <SelectListItem> location_combo = new List <SelectListItem>();

            location_combo = DropDown.getLocation();

            Db_Connection dbconn = new Db_Connection();

            try
            {
                dbconn.openConnection();



                string     strSQL = @"SELECT DOOR,LOCATION,DESCRIPTION FROM VDOOR WHERE ID=@ID AND GID=@GID";
                SqlCommand cmd    = new SqlCommand(strSQL, dbconn.DbConn);

                cmd.Parameters.Add("ID", SqlDbType.VarChar).Value  = id;
                cmd.Parameters.Add("GID", SqlDbType.VarChar).Value = gid;
                SqlDataReader dr     = cmd.ExecuteReader();
                mdlDoor       record = new mdlDoor();
                record.ID  = id;
                record.GID = gid;
                if (dr.HasRows)
                {
                    dr.Read();
                    record.ID          = id;
                    record.GID         = gid;
                    record.DOOR        = dr["DOOR"].ToString();
                    record.LOCATION    = dr["LOCATION"].ToString();
                    record.DESCRIPTION = dr["DESCRIPTION"].ToString();
                }

                foreach (SelectListItem item in location_combo)
                {
                    if (item.Text.ToUpper() == record.LOCATION.ToUpper())
                    {
                        item.Selected = true;
                    }
                }


                ViewData["location"] = location_combo;


                return(PartialView(record));
            }
            finally
            {
                dbconn.closeConnection();
            }
        }
Exemplo n.º 2
0
        public JsonResult getDoorLocation(string id)
        {
            Db_Connection dbconn = new Db_Connection();
            Utility       util   = new Utility();
            Function      func   = new Function();

            try
            {
                dbconn.openConnection();
                string strSQL = "";


                strSQL = @"SELECT ID,DOOR FROM DOOR WHERE LOCATION=@LOCATION ORDER BY DOOR ASC";


                List <mdlDoor> model_list = new List <mdlDoor>();
                SqlCommand     cmd        = new SqlCommand(strSQL, dbconn.DbConn);
                cmd = new SqlCommand(strSQL, dbconn.DbConn);
                cmd.Parameters.Add("LOCATION", SqlDbType.VarChar).Value = id;
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        mdlDoor list = new mdlDoor();
                        list.ID   = dr["ID"].ToString();
                        list.DOOR = dr["DOOR"].ToString();
                        model_list.Add(list);
                    }
                }
                dr.Dispose();
                cmd.Dispose();
                dbconn.closeConnection();



                return(Json(model_list.ToList()));
            }
            finally
            {
                dbconn.closeConnection();
            }
        }
Exemplo n.º 3
0
        //
        // GET: /en/Reader/
        public ActionResult Index()
        {
            Db_Connection dbconn = new Db_Connection();
            Utility       util   = new Utility();

            try
            {
                dbconn.openConnection();
                string strSQL = "";
                strSQL = @"SELECT ID,GID,DOOR,LOCATION,DESCRIPTION
                         FROM VDOOR ORDER BY DOOR ASC";


                SqlCommand     cmd    = new SqlCommand(strSQL, dbconn.DbConn);
                SqlDataReader  dr     = cmd.ExecuteReader();
                List <mdlDoor> record = new List <mdlDoor>();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        mdlDoor list = new mdlDoor();
                        list.ID          = dr["ID"].ToString();
                        list.GID         = dr["GID"].ToString();
                        list.DOOR        = dr["DOOR"].ToString();
                        list.DESCRIPTION = dr["DESCRIPTION"].ToString();
                        list.LOCATION    = dr["LOCATION"].ToString();
                        record.Add(list);
                    }
                }
                dr.Dispose();
                cmd.Dispose();
                dbconn.closeConnection();
                return(View(record));
            }
            finally
            {
                dbconn.closeConnection();
            }
        }