/// <summary> /// This Method will be used to Post data into tbl_zipcode table /// </summary> /// <param name="objzipCode">Name</param> /// <returns>1 for success and -1 for fail</returns> public string InsertzipCode(PropzipCode objzipCode, string userName) { if (userName != null && userName != "") { //proc_zipCode is the stored procedure name which will be used to Insert data into the table SqlCommand cmd = new SqlCommand("proc_zipCode", objCon.Con); cmd.CommandType = CommandType.StoredProcedure; if (objCon.Con.State == ConnectionState.Open) { } else { objCon.Con.Open(); } cmd.Parameters.AddWithValue("@zipcode", objzipCode.ZipCode); cmd.Parameters.AddWithValue("@CityId", objzipCode.CityId); cmd.Parameters.AddWithValue("@StateId", objzipCode.StateID); cmd.Parameters.AddWithValue("@Action", "Add"); return(cmd.ExecuteNonQuery().ToString()); } else { return("Not Valid"); } }
/// <summary> /// This Method is used to Delete data into tbl_zipcode table /// </summary> /// <param name="objzipCode">ID and Action</param> /// <returns>1 for success and -1 for fail</returns> public string DeletezipCode(PropzipCode objzipCode, string userName) { if (userName != null && userName != "") { SqlCommand cmd = new SqlCommand("proc_zipCode", objCon.Con); cmd.CommandType = CommandType.StoredProcedure; objCon.Con.Open(); try { cmd.Parameters.AddWithValue("@ID", objzipCode.ID); cmd.Parameters.AddWithValue("@status", objzipCode.flag); cmd.Parameters.AddWithValue("@Action", "Delete"); return(cmd.ExecuteNonQuery().ToString()); } catch (Exception showError) { throw showError; } finally { cmd.Dispose(); objCon.Con.Close(); objCon.Con.Dispose(); } } else { return("Not Valid"); } }
/// <summary> /// This Method is used to Select data from tbl_zipcode table /// </summary> /// <param name="objzipCode">Action</param> /// <returns>1 for success and -1 for fail</returns> public string SelectzipCode(PropzipCode objzipCode, string userName) { if (userName != null && userName != "") { SqlCommand cmd = new SqlCommand("proc_zipCode", objCon.Con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", "Select"); cmd.Parameters.AddWithValue("@status", objzipCode.flag); cmd.Parameters.AddWithValue("@StateId", objzipCode.StateID); SqlDataAdapter adpt = new SqlDataAdapter(); DataSet ds = new DataSet(); if (objCon.Con.State == ConnectionState.Open) { } else { objCon.Con.Open(); } cmd.Connection = objCon.Con; adpt.SelectCommand = cmd; adpt.Fill(ds, "zipcodes"); objCon.Con.Close(); return(ds.GetXml()); } else { return("Not Valid"); } }
public static List <PropzipCode> CitiesInfo1(string CityName) { List <PropzipCode> empObj = new List <PropzipCode>(); string cs = ConfigurationManager.ConnectionStrings["con"].ToString(); try { using (SqlConnection con = new SqlConnection(cs)) { using (SqlCommand com = new SqlCommand()) { com.CommandText = string.Format("select ID, cityID +' '+ StateID as 'States' from tbl_zipcode where cityID like '{0}%'", CityName); com.Connection = con; con.Open(); SqlDataReader sdr = com.ExecuteReader(); PropzipCode emp = null; while (sdr.Read()) { emp = new PropzipCode(); emp.ID = Convert.ToInt32(sdr["ID"]); emp.Name = Convert.ToString(sdr["States"]); empObj.Add(emp); } } } } catch (Exception ex) { Console.WriteLine("Error {0}", ex.Message); } return(empObj); }
public string GetLatandLongValues(string zipcode) { string str = string.Empty; PropzipCode objProperty = new PropzipCode(); objProperty.ZipCode = zipcode; BllZipCodeRegistration objzipCode = new BllZipCodeRegistration(); str = objzipCode.SelectLatitute(objProperty); return(str); }
public string SelectLatitute(PropzipCode objProperty) { DllZipcodeRegis objDal = new DllZipcodeRegis(); try { return(objDal.SelectzipCode(objProperty)); } catch (Exception info) { throw info; } finally { objDal = null; } }
public string RecordInsert(PropzipCode objProperty, string UserName) { DllZipcodeRegis objDal = new DllZipcodeRegis(); try { return(objDal.InsertzipCode(objProperty, UserName)); } catch (Exception info) { throw info; } finally { objDal = null; } }
/// <summary> /// This Method is used to Get Latitute and longitute value from tbl_zipcode table /// </summary> /// <param name="objzipCode">zipcode</param> /// <returns>latitute and longitute</returns> public string SelectzipCode(PropzipCode objzipCode) { SqlCommand cmd = new SqlCommand("proc_zipCode", objCon.Con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", "SelectLatLongValue"); cmd.Parameters.AddWithValue("@zipcode", objzipCode.ZipCode); SqlDataAdapter adpt = new SqlDataAdapter(); DataSet ds = new DataSet(); if (objCon.Con.State == ConnectionState.Open) { } else { objCon.Con.Open(); } cmd.Connection = objCon.Con; adpt.SelectCommand = cmd; adpt.Fill(ds, "LatituteLong"); objCon.Con.Close(); return(ds.GetXml()); }