Ejemplo n.º 1
0
 public IEnumerable <ClientType> GetAllClientType()
 {
     return(_iCommonGateway.GetAllClientType());
 }
Ejemplo n.º 2
0
 public ViewClient GetClientDeailsById(int clientId)
 {
     try
     {
         ViewClient client = new ViewClient();
         CommandObj.Parameters.Clear();
         CommandObj.CommandText = "UDSP_GetClientDetailsById";
         CommandObj.CommandType = CommandType.StoredProcedure;
         CommandObj.Parameters.AddWithValue("@ClientId", clientId);
         ConnectionObj.Open();
         SqlDataReader reader = CommandObj.ExecuteReader();
         if (reader.Read())
         {
             client.ClientId       = Convert.ToInt32(reader["ClientId"]);
             client.ClientName     = reader["Name"].ToString();
             client.CommercialName = reader["CommercialName"].ToString();
             client.Address        = reader["Address"].ToString();
             client.Phone          = reader["Phone"].ToString();
             client.AlternatePhone = DBNull.Value.Equals(reader["AltPhone"])?null: reader["AltPhone"].ToString();
             client.Email          = DBNull.Value.Equals(reader["Email"]) ? null : reader["Email"].ToString();
             client.Gender         = reader["Gender"].ToString();
             client.Fax            = DBNull.Value.Equals(reader["Fax"]) ? null : reader["Fax"].ToString();
             client.Website        = DBNull.Value.Equals(reader["Website"]) ? null : reader["Website"].ToString();
             client.PostOfficeId   = DBNull.Value.Equals(reader["PostOfficeId"]) ?(int?)null: Convert.ToInt32(reader["PostOfficeId"]);
             client.UserId         = Convert.ToInt32(reader["UserId"]);
             client.Division       = new Division
             {
                 //DivisionId = Convert.ToInt32(reader["DivisionId"]),
                 DivisionName = reader["DivisionName"].ToString()
             };
             client.District = new District
             {
                 //DistrictId = Convert.ToInt32(reader["DistrictId"]),
                 DistrictName = reader["DistrictName"].ToString(),
                 // DivisionId = Convert.ToInt32(reader["DivisionId"])
             };
             client.Upazilla = new Upazilla
             {
                 // UpazillaId = Convert.ToInt32(reader["UpazillaId"]),
                 UpazillaName = reader["UpazillaName"].ToString(),
                 // DistrictId = Convert.ToInt32(reader["DistrictId"])
             };
             client.PostOffice = new PostOffice
             {
                 //PostOfficeId = Convert.ToInt32(reader["PostOfficeId"]),
                 PostOfficeName = reader["PostOfficeName"].ToString(),
                 Code           = reader["PostCode"].ToString(),
             };
             client.ClientType = new ClientType
             {
                 ClientTypeId   = Convert.ToInt32(reader["ClientTypeId"]),
                 ClientTypeName = reader["ClientTypeName"].ToString()
             };
             client.ClientTypeId         = Convert.ToInt32(reader["ClientTypeId"]);
             client.ClientTypeName       = reader["ClientTypeName"].ToString();
             client.SubSubSubAccountCode = reader["SubSubSubAccountCode"].ToString();
             client.EntryDate            = Convert.ToDateTime(reader["EntryDate"]);
             client.ClientImage          = DBNull.Value.Equals(reader["ClientImage"])? null: reader["ClientImage"].ToString();
             client.ClientSignature      = DBNull.Value.Equals(reader["ClientSignature"]) ? null : reader["ClientSignature"].ToString();
             client.NationalIdNo         = DBNull.Value.Equals(reader["NationalIdNo"]) ? null : reader["NationalIdNo"].ToString();
             client.Active = reader["Active"].ToString();
             //client.BranchName = reader["ClientBranch"].ToString();
             client.CreditLimit  = Convert.ToDecimal(reader["CreditLimit"]);
             client.MaxCreditDay = Convert.ToInt32(reader["MaxCreditDay"]);
             client.ClientType   = _iCommonGateway.GetAllClientType().ToList()
                                   .Find(n => n.ClientTypeId == Convert.ToInt32(reader["ClientTypeId"]));
             client.Outstanding = DBNull.Value.Equals(reader["Outstanding"])? (decimal?)null: Convert.ToDecimal(reader["Outstanding"]);
         }
         reader.Close();
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
         client.ClientAttachments = GetClientAttachmentsByClientId(clientId).ToList();
         return(client);
     }
     catch (SqlException sqlException)
     {
         throw new Exception("Unable to collect Client Information due to Sql Exception", sqlException);
     }
     catch (Exception exception)
     {
         throw new Exception("Unable to collect Client Information", exception);
     }
     finally
     {
         ConnectionObj.Close();
         CommandObj.Dispose();
         CommandObj.Parameters.Clear();
     }
 }