コード例 #1
0
        protected void searchClaims()
        {
            string criteria,
                   find,
                   myClaims,
                   claimStatusId;

            DateTime?startDate = null,
                    endDate    = null;

            if (!string.IsNullOrEmpty(dpStart.Value))
            {
                startDate = DateTime.Parse(dpStart.Value);
            }

            if (!string.IsNullOrEmpty(dpEnd.Value))
            {
                endDate = DateTime.Parse(dpEnd.Value);
            }

            if (txtSearchClaim.Text == string.Empty)
            {
                find = " ";
            }
            else
            {
                find = txtSearchClaim.Text;
            }

            criteria      = "Client";//ddlCriteria.SelectedValue;
            myClaims      = ddlMyClaims.SelectedValue;
            claimStatusId = ddlStatus.SelectedValue;

            SqlConnection  sqlConnection1 = new SqlConnection(ClaimSqldataSource.ConnectionString);
            SqlDataAdapter da             = new SqlDataAdapter();
            SqlCommand     cmd            = new SqlCommand();
            DataTable      dt             = new DataTable();

            try
            {
                cmd.CommandText = "[claim].[sp_search_claims]";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = sqlConnection1;

                cmd.Parameters.AddWithValue("@find", find);
                cmd.Parameters.AddWithValue("@criteria", criteria);
                cmd.Parameters.AddWithValue("@user", User.Identity.Name);
                cmd.Parameters.AddWithValue("@myClaims", myClaims);
                cmd.Parameters.AddWithValue("@claimStatusId", claimStatusId);

                cmd.Parameters.Add("@startDate", SqlDbType.DateTime).Value = startDate;
                cmd.Parameters.Add("@endDate", SqlDbType.DateTime).Value   = endDate;

                da.SelectCommand = cmd;

                da.Fill(dt);

                //if (dt != null && dt.Rows.Count > 0)
                //{
                ClaimListView.DataSourceID = string.Empty;
                ClaimListView.DataSource   = dt;
                ClaimListView.DataBind();
                //}
            }
            catch (Exception exp)
            {
                ErrorLabel.Text    = "Error a ejecutar busqueda.. : " + exp.Message;
                ErrorLabel.Visible = true;
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //Verifico si es una busqueda por Formulario
                try
                {
                    if (Request.QueryString["PolicyNumber"] != null)
                    {
                        claimID = Request.QueryString["PolicyNumber"].ToString();
                    }

                    if (claimID != null)
                    {
                        txtSearchClaim.Text        = claimID;
                        ClaimListView.DataSource   = null;
                        ClaimListView.DataSourceID = "ClaimSqldataSource";
                        ClaimListView.DataBind();
                    }
                }
                catch (Exception ex)
                {
                    claimID = null;
                }

                try
                {
                    if (Request.QueryString["criteria"] != null)
                    {
                        criteria = Request.QueryString["criteria"].ToString();
                        switch (criteria)
                        {
                        case "PolicyNumber":
                            txtSearchClaim.Attributes["placeholder"] = "Buscar por Nro. Póliza";
                            //criteriaBtn.InnerText = "Nro. Póliza";
                            break;

                        case "Client":
                            txtSearchClaim.Attributes["placeholder"] = "Buscar por Cliente";
                            //criteriaBtn.InnerText = "Cliente";
                            break;

                        case "ClientDocumentNumber":
                            txtSearchClaim.Attributes["placeholder"] = "Buscar por Nro. Documento";
                            //criteriaBtn.InnerText = "Nro. Documento";
                            break;

                        case "ClaimNumber":
                            txtSearchClaim.Attributes["placeholder"] = "Buscar por Nro. Siniestro";
                            //criteriaBtn.InnerText = "Nro. Siniestro";
                            break;

                        default:
                            txtSearchClaim.Attributes["placeholder"] = "Buscar por Nro. Pòliza";
                            //criteriaBtn.InnerText = "Nro. Póliza";
                            criteria = "PolicyNumber";
                            break;
                        }
                    }
                }
                catch (Exception exp)
                {
                    txtSearchClaim.Attributes["placeholder"] = "Buscar por Nro. Póliza";
                    //criteriaBtn.InnerText = "Nro. Póliza";
                    criteria = "PolicyNumber";
                }
            }
        }