Example #1
0
        public int PostCourierMaster(CourierDetailsVm model1, ContactPersonVm model2)
        {
            try
            {
                string connection = Constants.Connection;
                int    i          = 0;
                using (SqlConnection sqlConn = new SqlConnection(connection))
                {
                    if (sqlConn.State == 0)
                    {
                        sqlConn.Open();
                    }
                    using (SqlCommand sqlComm = new SqlCommand("USP_INS_COURIER_CONTACT", sqlConn))
                    {
                        sqlComm.CommandType = System.Data.CommandType.StoredProcedure;

                        sqlComm.Parameters.AddWithValue("@Type", 0);
                        sqlComm.Parameters.AddWithValue("@CompanyName", model1.companyName);
                        sqlComm.Parameters.AddWithValue("@ContactPerson", model1.contactPerson);
                        sqlComm.Parameters.AddWithValue("@Email", model1.email);
                        sqlComm.Parameters.AddWithValue("@Website", model1.website);
                        sqlComm.Parameters.AddWithValue("@Phone", model1.phone);
                        sqlComm.Parameters.AddWithValue("@Remarks", model1.Remarks);
                        sqlComm.Parameters.AddWithValue("@Status", model1.status);
                        sqlComm.Parameters.AddWithValue("@Created_by", model1.createdBy);
                        sqlComm.Parameters.AddWithValue("@PersonName", model2.personName);
                        sqlComm.Parameters.AddWithValue("@Phone1", model2.phone1);
                        sqlComm.Parameters.AddWithValue("@Phone2", model2.phone2);
                        sqlComm.Parameters.AddWithValue("@Stat", model2.status);
                        sqlComm.Parameters.AddWithValue("@CourierName", model1.companyName);
                        sqlComm.Parameters.AddWithValue("@CreatedBy", model2.created_By);


                        i = sqlComm.ExecuteNonQuery();


                        sqlConn.Close();
                        return(i);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public List <CourierDetailsVm> GetCourierDetailsList()
        {
            string connection = Constants.Connection;

            using (SqlConnection sqlConn = new SqlConnection(connection))
            {
                sqlConn.Open();
                List <CourierDetailsVm> dt = new List <CourierDetailsVm>();
                using (SqlCommand sqlComm = new SqlCommand("USP_LIST_COURIER_COMPANY", sqlConn))
                {
                    sqlComm.CommandType = System.Data.CommandType.StoredProcedure;

                    using (SqlDataReader sdr = sqlComm.ExecuteReader())
                    {
                        while (sdr.Read())
                        {
                            try
                            {
                                CourierDetailsVm dtc = new CourierDetailsVm();

                                dtc.company_Id  = (int)sdr["company_Id"];
                                dtc.companyName = sdr["companyName"].ToString();



                                dt.Add(dtc);
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }
                        sdr.Close();
                    }
                }
                return(dt);
            }
        }