LSPEnquiryRecievedList RFQDate RFQDate NVARCHAR 1
LSPEnquiryRecievedList Origin Origin NVARCHAR 1
LSPEnquiryRecievedList Destination Destination NVARCHAR 1
LSPEnquiryRecievedList CargoType CargoType INT 1
LSPEnquiryRecievedList Mode Mode VARCHAR 1
LSPEnquiryRecievedList Date s.CreatedDate VARCHAR 1
LSPEnquiryRecievedList Pickup s.DepartureDate VARCHAR 1
LSPEnquiryRecievedList Drop s.ExpectedShipmentDate VARCHAR 1
table
compare Data uisng dictionaey
Dictionary<string, string> My_dict =new Dictionary<string, string>();
My_dict.Add("RFQDate", ddlDateType);
My_dict.Add("Origin", pickupFrom);
My_dict.Add("Destination", deliverTo);
My_dict.Add("CargoType", cargoType);
My_dict.Add("Mode", convertArrayToStringUsingStreamAPI(selectedMode));
My_dict.Add("Date", "s.CreatedDate");
My_dict.Add("Pickup", "s.DepartureDate");
My_dict.Add("Drop", "s.ExpectedShipmentDate");
My_dict.Add("PageName", "LSPEnquiryRecievedList");
string Query = NLP.Utilities.GetFilterData(My_dict , fromDate , todate);
public static string GetFilterData(Dictionary<string, string> My_dict, string fromDate , string toDate )
{
StringBuilder strQuery = new StringBuilder();
using (SqlConnection con = new SqlConnection(Utilities.GetConnection()))
{
SqlCommand cmd = new SqlCommand("GetFilterFields", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PageName", My_dict["PageName"]);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
try
{
if (dt.Rows.Count > 0)
{
//List<SearchFiler> objFl = new List<SearchFiler>();
//objFl = ConvertDataTable<SearchFiler>(dt);
List<SearchFiler> _lstFilter = new List<SearchFiler>();
int i = 0;
foreach (KeyValuePair<string, string> entry in My_dict)
{
if (entry.Value != "")
{
string str = "";
while ( i < dt.Rows.Count)
{
if (Equals(dt.Rows[i]["SearchField"], entry.Key))
{
str = dt.Rows[i]["ColumnName"].ToString();
break;
}
i = i + 1;
}
//if (entry.Key == "RFQDate" && entry.Value == "Date")
//{
//}
strQuery.Append(" And " + str + "=" + entry.Value);
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
return strQuery.ToString();
}
<html>
<body>
</body>
LSPEnquiryRecievedList Origin Origin NVARCHAR 1
LSPEnquiryRecievedList Destination Destination NVARCHAR 1
LSPEnquiryRecievedList CargoType CargoType INT 1
LSPEnquiryRecievedList Mode Mode VARCHAR 1
LSPEnquiryRecievedList Date s.CreatedDate VARCHAR 1
LSPEnquiryRecievedList Pickup s.DepartureDate VARCHAR 1
LSPEnquiryRecievedList Drop s.ExpectedShipmentDate VARCHAR 1
table
compare Data uisng dictionaey
Dictionary<string, string> My_dict =new Dictionary<string, string>();
My_dict.Add("RFQDate", ddlDateType);
My_dict.Add("Origin", pickupFrom);
My_dict.Add("Destination", deliverTo);
My_dict.Add("CargoType", cargoType);
My_dict.Add("Mode", convertArrayToStringUsingStreamAPI(selectedMode));
My_dict.Add("Date", "s.CreatedDate");
My_dict.Add("Pickup", "s.DepartureDate");
My_dict.Add("Drop", "s.ExpectedShipmentDate");
My_dict.Add("PageName", "LSPEnquiryRecievedList");
string Query = NLP.Utilities.GetFilterData(My_dict , fromDate , todate);
public static string GetFilterData(Dictionary<string, string> My_dict, string fromDate , string toDate )
{
StringBuilder strQuery = new StringBuilder();
using (SqlConnection con = new SqlConnection(Utilities.GetConnection()))
{
SqlCommand cmd = new SqlCommand("GetFilterFields", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PageName", My_dict["PageName"]);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
try
{
if (dt.Rows.Count > 0)
{
//List<SearchFiler> objFl = new List<SearchFiler>();
//objFl = ConvertDataTable<SearchFiler>(dt);
List<SearchFiler> _lstFilter = new List<SearchFiler>();
int i = 0;
foreach (KeyValuePair<string, string> entry in My_dict)
{
if (entry.Value != "")
{
string str = "";
while ( i < dt.Rows.Count)
{
if (Equals(dt.Rows[i]["SearchField"], entry.Key))
{
str = dt.Rows[i]["ColumnName"].ToString();
break;
}
i = i + 1;
}
//if (entry.Key == "RFQDate" && entry.Value == "Date")
//{
//}
strQuery.Append(" And " + str + "=" + entry.Value);
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
return strQuery.ToString();
}
<html>
<body>
</body>