示例#1
0
        public int AddDairyLoanDetails(DairyLoanModel model)
        {
            int Id = 0;

            try
            {
                using (SqlConnection conn = new SqlConnection(ContexDetails.Connectiondetails()))
                {
                    conn.Open();
                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = "sp_AddDairyLoanDetails";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@LoanAmount", model.LoanAmount);
                        cmd.Parameters.AddWithValue("@LoanTenure", model.LoanTenure);
                        cmd.Parameters.AddWithValue("@RateOfInterest", model.RateOfInterest);
                        cmd.Parameters.AddWithValue("@CreatedBy", model.CreatedBy);
                        cmd.Parameters.Add("@Result", SqlDbType.Int).Direction = ParameterDirection.Output;
                        int i = cmd.ExecuteNonQuery();
                        Id = Convert.ToInt32(cmd.Parameters["@Result"].Value);
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Id);
        }
示例#2
0
        public IList <DairyLoanModel> GetDairyLoanList(int UserId)
        {
            IList <DairyLoanModel> listitems = new List <DairyLoanModel>();

            try
            {
                using (SqlConnection conn = new SqlConnection(ContexDetails.Connectiondetails()))
                {
                    conn.Open();
                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = "sp_GetDairyLoanRequested";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@UserId", UserId);
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                DairyLoanModel model = new DairyLoanModel();
                                model.LoanAmount     = Convert.ToString(reader["LoanAmount"]);
                                model.LoanTenure     = Convert.ToString(reader["LoanTenure"]);
                                model.RateOfInterest = Convert.ToString(reader["RateOfInterest"]);
                                model.CreatedDate    = Convert.ToDateTime(reader["CreatedDate"]);
                                listitems.Add(model);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(listitems);
        }