コード例 #1
0
        public List <Customer> GetAllCustomer(CustomerAdvanceSearch customerAdvanceSearch)
        {
            List <Customer> customerList = null;

            try
            {
                using (SqlConnection con = _databaseFactory.GetDBConnection())
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }
                        cmd.Connection  = con;
                        cmd.CommandText = "[PSA].[GetAllCustomer]";
                        if (string.IsNullOrEmpty(customerAdvanceSearch.SearchTerm))
                        {
                            cmd.Parameters.AddWithValue("@SearchTerm", DBNull.Value);
                        }
                        else
                        {
                            cmd.Parameters.Add("@SearchTerm", SqlDbType.NVarChar, -1).Value = customerAdvanceSearch.SearchTerm;
                        }
                        cmd.Parameters.Add("@RowStart", SqlDbType.Int).Value = customerAdvanceSearch.DataTablePaging.Start;
                        if (customerAdvanceSearch.DataTablePaging.Length == -1)
                        {
                            cmd.Parameters.AddWithValue("@Length", DBNull.Value);
                        }
                        else
                        {
                            cmd.Parameters.Add("@Length", SqlDbType.Int).Value = customerAdvanceSearch.DataTablePaging.Length;
                        }
                        //cmd.Parameters.Add("@OrderDir", SqlDbType.NVarChar, 5).Value = model.order[0].dir;
                        //cmd.Parameters.Add("@OrderColumn", SqlDbType.NVarChar, -1).Value = model.order[0].column;
                        cmd.Parameters.Add("@FromDate", SqlDbType.DateTime).Value = customerAdvanceSearch.FromDate;
                        cmd.Parameters.Add("@Todate", SqlDbType.DateTime).Value   = customerAdvanceSearch.ToDate;
                        cmd.CommandType = CommandType.StoredProcedure;
                        using (SqlDataReader sdr = cmd.ExecuteReader())
                        {
                            if ((sdr != null) && (sdr.HasRows))
                            {
                                customerList = new List <Customer>();
                                while (sdr.Read())
                                {
                                    Customer customer = new Customer();
                                    {
                                        customer.ID                 = (sdr["ID"].ToString() != "" ? Guid.Parse(sdr["ID"].ToString()) : customer.ID);
                                        customer.CompanyName        = (sdr["CompanyName"].ToString() != "" ? sdr["CompanyName"].ToString() : customer.CompanyName);
                                        customer.ContactPerson      = (sdr["ContactPerson"].ToString() != "" ? sdr["ContactPerson"].ToString() : customer.ContactPerson);
                                        customer.ContactEmail       = (sdr["ContactEmail"].ToString() != "" ? sdr["ContactEmail"].ToString() : customer.ContactEmail);
                                        customer.ContactTitle       = (sdr["ContactTitle"].ToString() != "" ? sdr["ContactTitle"].ToString() : customer.ContactTitle);
                                        customer.Website            = (sdr["Website"].ToString() != "" ? sdr["Website"].ToString() : customer.Website);
                                        customer.LandLine           = (sdr["LandLine"].ToString() != "" ? sdr["LandLine"].ToString() : customer.LandLine);
                                        customer.Mobile             = (sdr["Mobile"].ToString() != "" ? sdr["Mobile"].ToString() : customer.Mobile);
                                        customer.Fax                = (sdr["Fax"].ToString() != "" ? sdr["Fax"].ToString() : customer.Fax);
                                        customer.OtherPhoneNos      = (sdr["OtherPhoneNos"].ToString() != "" ? sdr["OtherPhoneNos"].ToString() : customer.OtherPhoneNos);
                                        customer.BillingAddress     = (sdr["BillingAddress"].ToString() != "" ? sdr["BillingAddress"].ToString() : customer.BillingAddress);
                                        customer.ShippingAddressCus = (sdr["ShippingAddress"].ToString() != "" ? sdr["ShippingAddress"].ToString() : customer.ShippingAddressCus);
                                        customer.PaymentTermCode    = (sdr["PaymentTermCode"].ToString() != "" ? sdr["PaymentTermCode"].ToString() : customer.PaymentTermCode);
                                        customer.TaxRegNo           = (sdr["TaxRegNo"].ToString() != "" ? sdr["TaxRegNo"].ToString() : customer.TaxRegNo);
                                        customer.PANNO              = (sdr["PANNO"].ToString() != "" ? sdr["PANNO"].ToString() : customer.PANNO);
                                        //customer.OutStanding = (sdr["OutStanding"].ToString() != "" ? decimal.Parse(sdr["OutStanding"].ToString()) : customer.OutStanding);
                                        customer.GeneralNotes                   = (sdr["GeneralNotes"].ToString() != "" ? sdr["GeneralNotes"].ToString() : customer.GeneralNotes);
                                        customer.CountryCode                    = (sdr["CountryCode"].ToString() != "" ? int.Parse(sdr["CountryCode"].ToString()) : customer.CountryCode);
                                        customer.StateCode                      = (sdr["StateCode"].ToString() != "" ? int.Parse(sdr["StateCode"].ToString()) : customer.StateCode);
                                        customer.DistrictCode                   = (sdr["DistrictCode"].ToString() != "" ? int.Parse(sdr["DistrictCode"].ToString()) : customer.DistrictCode);
                                        customer.AreaCode                       = (sdr["AreadCode"].ToString() != "" ? int.Parse(sdr["AreadCode"].ToString()) : customer.AreaCode);
                                        customer.PSASysCommon                   = new PSASysCommon();
                                        customer.PSASysCommon.CreatedBy         = (sdr["CreatedBy"].ToString() != "" ? sdr["CreatedBy"].ToString() : customer.PSASysCommon.CreatedBy);
                                        customer.PSASysCommon.CreatedDateString = (sdr["CreatedDate"].ToString() != "" ? DateTime.Parse(sdr["CreatedDate"].ToString()).ToString(_settings.DateFormat) : customer.PSASysCommon.CreatedDateString);
                                        customer.PSASysCommon.CreatedDate       = (sdr["CreatedDate"].ToString() != "" ? DateTime.Parse(sdr["CreatedDate"].ToString()) : customer.PSASysCommon.CreatedDate);
                                        customer.PSASysCommon.UpdatedBy         = (sdr["UpdatedBy"].ToString() != "" ? sdr["UpdatedBy"].ToString() : customer.PSASysCommon.UpdatedBy);
                                        customer.PSASysCommon.UpdatedDate       = (sdr["UpdatedDate"].ToString() != "" ? DateTime.Parse(sdr["UpdatedDate"].ToString()) : customer.PSASysCommon.UpdatedDate);
                                        customer.PSASysCommon.UpdatedDateString = (sdr["UpdatedDate"].ToString() != "" ? DateTime.Parse(sdr["UpdatedDate"].ToString()).ToString(_settings.DateFormat) : customer.PSASysCommon.UpdatedDateString);
                                        customer.FilteredCount                  = (sdr["FilteredCount"].ToString() != "" ? int.Parse(sdr["FilteredCount"].ToString()) : customer.FilteredCount);
                                        customer.TotalCount                     = (sdr["TotalCount"].ToString() != "" ? int.Parse(sdr["TotalCount"].ToString()) : customer.FilteredCount);
                                        customer.AadharNo                       = (sdr["AadharNo"].ToString() != "" ? sdr["AadharNo"].ToString() : customer.AadharNo);
                                    }
                                    customerList.Add(customer);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(customerList);
        }
コード例 #2
0
 public List <Customer> GetAllCustomer(CustomerAdvanceSearch customerAdvanceSearch)
 {
     return(_customerRepository.GetAllCustomer(customerAdvanceSearch));
 }