示例#1
0
        public ActionResult edit(string id, string gid)
        {
            Populate      DropDown = new Populate();
            Db_Connection dbconn   = new Db_Connection();

            try
            {
                dbconn.openConnection();



                string     strSQL = @"SELECT FIREARMTYPE FROM FIREARMTYPE 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();
                mdlFirearmType record = new mdlFirearmType();
                record.ID  = id;
                record.GID = gid;
                if (dr.HasRows)
                {
                    dr.Read();
                    record.ID          = id;
                    record.GID         = gid;
                    record.FIREARMTYPE = dr["FIREARMTYPE"].ToString();
                }


                return(PartialView(record));
            }
            finally
            {
                dbconn.closeConnection();
            }
        }
示例#2
0
        //
        // GET: /en/Firearmtype/
        public ActionResult Index()
        {
            Db_Connection dbconn = new Db_Connection();
            Utility       util   = new Utility();

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


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