Пример #1
0
        public int SaveCourierTenant(int TenantID, CourierConfigurationBO cbo)
        {
            int rtnValue = 0;

            try
            {
                using (SqlConnection sqlCon = new SqlConnection(Constant.DBConnectionString))
                {
                    //SqlCommand sqlCmd = new SqlCommand("insert into stblCourierTenant (CourierID,TenantID) values (@CourierID,@TenantID);", sqlCon);
                    SqlCommand sqlCmd = new SqlCommand("sspSaveCourierTenant", sqlCon);
                    {
                        sqlCmd.CommandType = CommandType.StoredProcedure;

                        sqlCmd.Parameters.Add(new SqlParameter("@TenantID", TenantID));
                        sqlCmd.Parameters.Add(new SqlParameter("@CourierID", cbo.CourierID));
                        sqlCmd.Parameters.Add(new SqlParameter("@CourierTenantID", cbo.CourierTenantID));

                        sqlCon.Open();

                        SqlDataReader reader = sqlCmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                rtnValue = (reader[0] == DBNull.Value ? 0 : Convert.ToInt32(reader[0]));
                            }
                        }
                        reader.Close();
                        reader = null;
                        sqlCon.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                _ErrMsg = ex.Message;
                throw;
            }
            return(rtnValue);
        }
Пример #2
0
        public CourierConfigurationBO GetCourierTenant(int TenantID, int CourierID)
        {
            CourierConfigurationBO displaycourierBO = new CourierConfigurationBO();

            try
            {
                using (SqlConnection sqlCon = new SqlConnection(Constant.DBConnectionString))
                {
                    SqlCommand sqlCmd = new SqlCommand("select * from stblCourierTenant where TenantID=@TenantID and CourierID=@CourierID", sqlCon);
                    {
                        sqlCmd.Parameters.Add(new SqlParameter("@TenantID", TenantID));
                        sqlCmd.Parameters.Add(new SqlParameter("@CourierID", CourierID));
                        sqlCmd.CommandType = CommandType.Text;
                        sqlCmd.Connection  = sqlCon;
                        sqlCon.Open();

                        SqlDataReader reader = sqlCmd.ExecuteReader();

                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                displaycourierBO.CourierID       = reader["CourierID"] == DBNull.Value ? 0 : Convert.ToInt32(reader["CourierID"]);
                                displaycourierBO.CourierTenantID = reader["CourierTenantID"] == DBNull.Value ? 0 : Convert.ToInt32(reader["CourierTenantID"]);
                                displaycourierBO.TenantID        = reader["TenantID"] == DBNull.Value ? 0 : Convert.ToInt32(reader["TenantID"]);
                            }
                        }
                        reader.Close();
                        sqlCon.Close();
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(displaycourierBO);
        }