Skip to main content

dictionary search

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>

Popular posts from this blog

Add barcode on pdf

using System; using System.IO; using System.Drawing; using ZXing; using iTextSharp.text; using iTextSharp.text.pdf; using System.Drawing; using System.Web.UI.WebControls; namespace PDFBarcode {     public partial class WebForm1 : System.Web.UI.Page     {         byte[] byteImage;         protected void Page_Load(object sender, EventArgs e)         {         }         protected void btnDownload_Click(object sender, EventArgs e)         {                       Random r = new Random();             string fileName = r.Next().ToString();             string filenameext = fileName + ".pdf";             GenerateBarcode(fileName);             string Sourcepath = Server.MapPath("~/SavedF...

Dynamic Menu in asp.net using Listview

 1.    public DataTable LoadMenu()         {             MenuBal MenuBal = new MenuBal();             DataSet ds = this.GetData(0);             PopulateMenu(ds);             return ds.Tables[2];         }     private DataSet GetData(int parentMenuId)         {             MenuBal objmenu = new MenuBal();             string Mode = "";             if (Session["Mode"] != null)             {                 Mode = Session["Mode"].ToString();             }             DataSet ds = objmenu.GetData(parentMenuId, Convert.ToInt32(SessionHelper.CurrentUserId), Mode, SessionHelper...