Exemple #1
0
        public IHttpActionResult ViewQuotationByPage(int max, int page, string sort_col, string sort_dir, string search = null, int VendorId = 0)
        {
            Paged_ACRF_QuotationDetailsModel objList = new Paged_ACRF_QuotationDetailsModel();

            try
            {
                objList = objQuotationVM.ListQuotationByPagination(max, page, search, VendorId, sort_col, sort_dir);
            }
            catch (Exception ex)
            {
                ErrorHandlerClass.LogError(ex);
            }
            return(Ok(new { results = objList }));
        }
Exemple #2
0
        public Paged_ACRF_QuotationDetailsModel ListQuotationByPagination(int max, int page, string search, int VendorId, string sort_col, string sort_dir)
        {
            Paged_ACRF_QuotationDetailsModel objPaged = new Paged_ACRF_QuotationDetailsModel();
            List <ACRF_QuotationModel>       objList  = new List <ACRF_QuotationModel>();

            try
            {
                if (search == null)
                {
                    search = "";
                }
                int startIndex = max * (page - 1);

                string sqlstr = "ACRF_GetQuotationByPage";

                var connection = gConnection.Connection();
                connection.Open();
                SqlCommand cmd = new SqlCommand(sqlstr, connection);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@startRowIndex", startIndex);
                cmd.Parameters.AddWithValue("@pageSize", max);
                cmd.Parameters.AddWithValue("@VendorId", VendorId);
                cmd.Parameters.AddWithValue("@search", search);
                cmd.Parameters.AddWithValue("@sort_col", sort_col);
                cmd.Parameters.AddWithValue("@sort_dir", sort_dir);
                SqlDataReader sdr = cmd.ExecuteReader();

                while (sdr.Read())
                {
                    ACRF_QuotationModel tempobj = new ACRF_QuotationModel();
                    tempobj.QuotationId     = Convert.ToInt32(sdr["QuotationId"].ToString());
                    tempobj.VendorId        = Convert.ToInt32(sdr["VendorId"].ToString());
                    tempobj.FromMail        = sdr["FromMail"].ToString();
                    tempobj.ClientMail      = sdr["ClientMail"].ToString();
                    tempobj.CC              = sdr["CC"].ToString();
                    tempobj.BCC             = sdr["BCC"].ToString();
                    tempobj.MailSubject     = sdr["MailSubject"].ToString();
                    tempobj.QuotationStatus = sdr["QuotationStatus"].ToString();

                    tempobj.CreatedBy = sdr["CreatedBy"].ToString();
                    tempobj.CreatedOn = Convert.ToDateTime(sdr["CreatedOn"].ToString());

                    objList.Add(tempobj);
                }
                sdr.Close();
                objPaged.ACRF_QuotationDetailsModelList = objList;


                sqlstr = "select count(*) as cnt from ACRF_Quotation where VendorId = @VendorId and ClientMail like  @search ";
                cmd.Parameters.Clear();
                cmd.CommandText = sqlstr;
                cmd.Connection  = connection;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.AddWithValue("@search", '%' + search + '%');
                cmd.Parameters.AddWithValue("@VendorId", VendorId);
                sdr = cmd.ExecuteReader();
                while (sdr.Read())
                {
                    objPaged.PageCount = Convert.ToInt32(sdr["cnt"].ToString());
                }

                connection.Close();
            }
            catch (Exception ex)
            {
                ErrorHandlerClass.LogError(ex);
            }
            return(objPaged);
        }