public ActionResult search_list() { Db_Connection dbconn = new Db_Connection(); Utility util = new Utility(); try { dbconn.openConnection(); string strSQL = ""; strSQL = @"SELECT ID,GID,RFID,MODEL,FIREARMTYPE,CALIBER,CONDITION,DEFPIC,STATUS FROM VFIREARMS"; SqlCommand cmd = new SqlCommand(strSQL, dbconn.DbConn); SqlDataReader dr = cmd.ExecuteReader(); List <mdlFirearm> record = new List <mdlFirearm>(); if (dr.HasRows) { while (dr.Read()) { mdlFirearm list = new mdlFirearm(); list.ID = dr["ID"].ToString(); list.GID = dr["GID"].ToString(); list.RFID = dr["RFID"].ToString(); list.MODEL = dr["MODEL"].ToString(); list.FIREARMTYPE = dr["FIREARMTYPE"].ToString(); list.CALIBER = dr["CALIBER"].ToString(); list.STATUS = dr["STATUS"].ToString(); list.CONDITION = dr["CONDITION"].ToString(); list.DEFPIC = "/Content/firearms/NoImage.png"; if (!string.IsNullOrEmpty(dr["DEFPIC"].ToString())) { list.DEFPIC = "/" + dr["DEFPIC"].ToString(); } record.Add(list); } } dr.Dispose(); cmd.Dispose(); dbconn.closeConnection(); return(PartialView(record)); } finally { dbconn.closeConnection(); } }
public ActionResult picture_list(string id, string gid) { Db_Connection dbconn = new Db_Connection(); Utility util = new Utility(); try { dbconn.openConnection(); string strSQL = ""; strSQL = @"SELECT ID,F_ID,F_GID,PATH,FILENAME,DEFPIC FROM FIREARMS_PICTURES WHERE F_ID=@ID AND F_GID=@GID ORDER BY ID"; 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(); List <mdlFirearm> record = new List <mdlFirearm>(); if (dr.HasRows) { while (dr.Read()) { mdlFirearm list = new mdlFirearm(); list.IMG_ID = dr["ID"].ToString(); list.ID = dr["F_ID"].ToString(); list.GID = dr["F_GID"].ToString(); list.DEFPIC = dr["DEFPIC"].ToString(); list.PATH = "/" + dr["PATH"].ToString(); list.FILENAME = dr["FILENAME"].ToString(); record.Add(list); } } dr.Dispose(); cmd.Dispose(); dbconn.closeConnection(); return(PartialView(record)); } finally { dbconn.closeConnection(); } }
public ActionResult details(string id) { Db_Connection dbconn = new Db_Connection(); try { dbconn.openConnection(); string strSQL = @"SELECT NAME,IDNO,ID,GID,RFID,FIREARMTYPE,CALIBER,MODEL,SERIALNO,BARCODE,MANUFACTURER,CONDITION,FINISH, CAPACITY,LENGTH,ADDINFO,STORAGE,RACK,SUPPLIER,FINISH,CAPACITY,LENGTH,ADDINFO FROM VFIREARMS WHERE ID=@ID"; SqlCommand cmd = new SqlCommand(strSQL, dbconn.DbConn); cmd.Parameters.Add("ID", SqlDbType.VarChar).Value = id; SqlDataReader dr = cmd.ExecuteReader(); mdlFirearm record = new mdlFirearm(); record.ID = id; if (dr.HasRows) { dr.Read(); record.RFID = dr["RFID"].ToString(); record.GID = dr["GID"].ToString(); record.FIREARMTYPE = dr["FIREARMTYPE"].ToString(); record.CALIBER = dr["CALIBER"].ToString(); record.MODEL = dr["MODEL"].ToString(); record.SERIALNO = dr["SERIALNO"].ToString(); record.BARCODE = dr["BARCODE"].ToString(); record.MANUFACTURER = dr["MANUFACTURER"].ToString(); record.CONDITION = dr["CONDITION"].ToString(); record.FINISH = dr["FINISH"].ToString(); record.CAPACITY = dr["CAPACITY"].ToString(); record.LENGTH = dr["LENGTH"].ToString(); record.ADDINFO = dr["ADDINFO"].ToString(); record.STORAGE = dr["STORAGE"].ToString(); record.RACK = dr["RACK"].ToString(); record.FINISH = dr["FINISH"].ToString(); record.CAPACITY = dr["CAPACITY"].ToString(); record.LENGTH = dr["LENGTH"].ToString(); record.ADDINFO = dr["ADDINFO"].ToString(); record.SUPPLIER = dr["SUPPLIER"].ToString(); if (string.IsNullOrEmpty(dr["IDNO"].ToString())) { record.NAME = "Unassign Weapon"; } else { record.NAME = dr["IDNO"].ToString() + " - " + dr["NAME"].ToString(); } } return(PartialView(record)); } finally { dbconn.closeConnection(); } }
public ActionResult edit(string id, string gid) { if (Session["message"] == null) { Session["message"] = ""; } Populate DropDown = new Populate(); Db_Connection dbconn = new Db_Connection(); List <SelectListItem> firearmtype_combo = new List <SelectListItem>(); List <SelectListItem> storage_combo = new List <SelectListItem>(); List <SelectListItem> manufacturer_combo = new List <SelectListItem>(); List <SelectListItem> supplier_combo = new List <SelectListItem>(); List <SelectListItem> condition_combo = new List <SelectListItem>(); firearmtype_combo = DropDown.getFirearmType(); manufacturer_combo = DropDown.getManufacturer(); supplier_combo = DropDown.getSupplier(); condition_combo = DropDown.getCondition(); storage_combo = DropDown.getStorage(); try { dbconn.openConnection(); string strSQL = @"SELECT ID,GID,RFID,FIREARMTYPE,CALIBER,MODEL,SERIALNO,BARCODE,MANUFACTURER,CONDITION,FINISH, CAPACITY,LENGTH,ADDINFO,STORAGE,RACK,SUPPLIER,FINISH,CAPACITY,LENGTH,ADDINFO FROM FIREARMS 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(); mdlFirearm record = new mdlFirearm(); record.ID = id; record.GID = gid; if (dr.HasRows) { dr.Read(); record.RFID = dr["RFID"].ToString(); record.FIREARMTYPE = dr["FIREARMTYPE"].ToString(); record.CALIBER = dr["CALIBER"].ToString(); record.MODEL = dr["MODEL"].ToString(); record.SERIALNO = dr["SERIALNO"].ToString(); record.BARCODE = dr["BARCODE"].ToString(); record.MANUFACTURER = dr["MANUFACTURER"].ToString(); record.CONDITION = dr["CONDITION"].ToString(); record.FINISH = dr["FINISH"].ToString(); record.CAPACITY = dr["CAPACITY"].ToString(); record.LENGTH = dr["LENGTH"].ToString(); record.ADDINFO = dr["ADDINFO"].ToString(); record.STORAGE = dr["STORAGE"].ToString(); record.RACK = dr["RACK"].ToString(); record.FINISH = dr["FINISH"].ToString(); record.CAPACITY = dr["CAPACITY"].ToString(); record.LENGTH = dr["LENGTH"].ToString(); record.ADDINFO = dr["ADDINFO"].ToString(); record.SUPPLIER = dr["SUPPLIER"].ToString(); } foreach (SelectListItem item in firearmtype_combo) { if (item.Value == record.FIREARMTYPE) { item.Selected = true; } } foreach (SelectListItem item in manufacturer_combo) { if (item.Value == record.MANUFACTURER) { item.Selected = true; } } foreach (SelectListItem item in supplier_combo) { if (item.Value == record.SUPPLIER) { item.Selected = true; } } foreach (SelectListItem item in condition_combo) { if (item.Value == record.CONDITION) { item.Selected = true; } } foreach (SelectListItem item in storage_combo) { if (item.Value == record.STORAGE) { item.Selected = true; } } ViewData["firearmtype"] = firearmtype_combo; ViewData["manufacturer"] = manufacturer_combo; ViewData["supplier"] = supplier_combo; ViewData["storage"] = storage_combo; ViewData["condition"] = condition_combo; return(View(record)); } finally { dbconn.closeConnection(); } }
public ActionResult checkFirearms_list(string batchno, string status, string firearmtype) { Db_Connection dbconn = new Db_Connection(); Utility util = new Utility(); try { dbconn.openConnection(); string strSQL = ""; string strWHERE = ""; strSQL = @"SELECT F_ID,NAME,FIREARMTYPE,BATCHNO,DEFPIC,STATUS FROM VASSIGN_FIREARMS "; if (batchno != "") { strWHERE = strWHERE + "UPPER(BATCHNO)=UPPER(@BATCHNO) AND "; } if (status != "") { strWHERE = strWHERE + "STATUS=@STATUS AND "; } if (firearmtype != "") { strWHERE = strWHERE + "FIREARMTYPEID=@FIREARMTYPE AND "; } if (strWHERE != "") { strSQL = strSQL + " WHERE " + strWHERE; strSQL = strSQL.Substring(0, strSQL.Length - 4); } SqlCommand cmd = new SqlCommand(strSQL, dbconn.DbConn); if (batchno != "") { cmd.Parameters.Add("BATCHNO", SqlDbType.VarChar).Value = batchno; } if (status != "") { cmd.Parameters.Add("STATUS", SqlDbType.VarChar).Value = status; } if (firearmtype != "") { cmd.Parameters.Add("FIREARMTYPE", SqlDbType.VarChar).Value = firearmtype; } SqlDataReader dr = cmd.ExecuteReader(); List <mdlFirearm> record = new List <mdlFirearm>(); if (dr.HasRows) { while (dr.Read()) { mdlFirearm list = new mdlFirearm(); list.NAME = dr["BATCHNO"].ToString() + " - " + dr["NAME"].ToString(); list.FIREARMTYPE = dr["FIREARMTYPE"].ToString(); list.STATUS = dr["STATUS"].ToString(); list.ID = dr["F_ID"].ToString(); list.DEFPIC = "/Content/firearms/NoImage.png"; if (!string.IsNullOrEmpty(dr["DEFPIC"].ToString())) { list.DEFPIC = "/" + dr["DEFPIC"].ToString(); } record.Add(list); } } dr.Dispose(); cmd.Dispose(); dbconn.closeConnection(); return(PartialView(record)); } finally { dbconn.closeConnection(); } }