code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
using System; using System.Collections.Generic; using System.Linq; using System.Text; using QuanLiSoTietKiem.ValueObject; namespace QuanLiSoTietKiem { class IsLogin { public static UserInfo _User; public static bool _IsLogin; public static string _Time; } }
0lll-qlstk
trunk/QuanLiSoTietKiem/IsLogin.cs
C#
oos
313
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; using QuanLiSoTietKiem; using QuanLiSoTietKiem.Controller; namespace QuanLiSoTietKiem { public partial class frmLogin : Form { public frmLogin() { InitializeComponent(); Database.OpenConnectDB(); } LoginCtr _LoginCtr = new LoginCtr(); private void frmLogin_Load(object sender, EventArgs e) { } private void btnThoat_Click(object sender, EventArgs e) { Close(); } private void btnDangNhap_Click(object sender, EventArgs e) { if (txtUser.Text == "" || txtPass.Text == "") { MessageBox.Show("Nhập Đầy Đủ Thông Tin."); } else { int result = _LoginCtr.CheckLogin(txtUser, txtPass); if (result == 1) { IsLogin._IsLogin = true; Close(); } else { MessageBox.Show("Nhập Sai Tên Người Dùng Hoặc Mật Khẩu."); } } } } }
0lll-qlstk
trunk/QuanLiSoTietKiem/frmLogin.cs
C#
oos
1,431
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Text.RegularExpressions; using QuanLiSoTietKiem.ValueObject; using QuanLiSoTietKiem.Controller; namespace QuanLiSoTietKiem { public partial class frmSoTietKiem : Form { public frmSoTietKiem(SoTietKiemInfo _SoTietKiemInfo=null) { InitializeComponent(); //Check Update or Add New if (_SoTietKiemInfo != null) { //Status Update SOTIETKIEM txtMaSo.Text = _SoTietKiemInfo.MaSTK; txtMaSo.Enabled = false; txtKhachHang.Text = _SoTietKiemInfo.TenKH; //Set Type Ex: 1E+14 -> 100000000000000 txtSoTienGui.Text = _SoTietKiemInfo.SoTienGuiBD.ToString("N0", System.Globalization.CultureInfo.InvariantCulture); txtDiaChi.Text = _SoTietKiemInfo.DiaChi; txtCmnd.Text = _SoTietKiemInfo.SoCMND; cbDongSo.Checked = _SoTietKiemInfo.DongSo; dtNgayMoSo.Value = _SoTietKiemInfo.NgayMoSo; cmbLoaiTietKiem.Text = _SoTietKiemInfo.LoaiTietKiem; btnThem.Text = "Cập Nhật"; btnNhapLai.Text = "Xóa"; lblSoDu.Visible = true; txtSoDu.Visible = true; txtSoDu.Text = _SoTietKiemInfo.SoDu.ToString("N0", System.Globalization.CultureInfo.InvariantCulture); } else { //Status Add New SOTIETKIEM //Get ID for New SOTIETKIEM txtMaSo.Text = _SoTietKiemCtr.GetNewID(); txtMaSo.Enabled = false; cmbLoaiTietKiem.Enabled = true; } } //Controller SoTietKiemCtr _SoTietKiemCtr = new SoTietKiemCtr(); private void frmSoTietKiem_Load(object sender, EventArgs e) { _SoTietKiemCtr.ShowLoaiTietKiem(cmbLoaiTietKiem); } //when Form Close private void frmSoTietKiem_FormClosed(object sender, FormClosedEventArgs e) { Form frm = Application.OpenForms["frmMain"]; frm.Show(); } //Thoát private void btnThoat_Click(object sender, EventArgs e) { Close(); } //Button Xóa and Nhập Lại private void btnNhapLai_Click(object sender, EventArgs e) { switch (btnNhapLai.Text) { case "Nhập Lại": txtCmnd.Text = ""; txtDiaChi.Text = ""; txtKhachHang.Text = ""; txtSoTienGui.Text = ""; break; case "Xóa": _SoTietKiemCtr.DelSTK(txtMaSo); Close(); break; } } //Thêm private void btnThem_Click(object sender, EventArgs e) { if (btnThem.Text == "Thêm") { if (txtKhachHang.Text == "" || txtCmnd.Text == "" || txtDiaChi.Text == "" || txtSoTienGui.Text == "") { //Check Empty All TextBox MessageBox.Show("Nhập Đầy Đủ Thông Tin."); } else { //Check txtSoTienGui IsNumber float num; if (!float.TryParse(txtSoTienGui.Text, out num)) { MessageBox.Show("Kiểm Tra Số Tiền Gửi."); } else { //Check Min txtSoTienGui In Database string Min = Function.GetSetting("SoTienGuiToiThieu"); if (num < float.Parse(Min)) { MessageBox.Show("Số Tiền Gửi Tối Thiểu Là: " + Min); } else { //Add Info into Database SoTietKiemInfo STK = new SoTietKiemInfo(); STK.TenKH = txtKhachHang.Text; STK.DiaChi = txtDiaChi.Text; STK.DongSo = cbDongSo.Checked; Function.cb_Item LoaiTK = new Function.cb_Item(); LoaiTK = (Function.cb_Item)cmbLoaiTietKiem.SelectedItem; STK.MaLoaiTietKiem = (int)LoaiTK._Id; STK.MaSTK = txtMaSo.Text; STK.SoCMND = txtCmnd.Text; STK.NgayMoSo = DateTime.Parse(dtNgayMoSo.Text); STK.LaiSuat = Function.GetLaiSuat(Int32.Parse(LoaiTK._Id.ToString())); STK.SoTienGuiBD = float.Parse(txtSoTienGui.Text); _SoTietKiemCtr.CreateSTK(STK); Close(); } } } } else if(btnThem.Text=="Cập Nhật") { if (txtKhachHang.Text == "" || txtDiaChi.Text == "" || txtCmnd.Text == "") { MessageBox.Show("Điền Đầy Đủ Thông Tin."); } else { SoTietKiemInfo STK = new SoTietKiemInfo(); STK.TenKH = txtKhachHang.Text; STK.MaSTK = txtMaSo.Text; STK.DiaChi = txtDiaChi.Text; STK.SoCMND = txtCmnd.Text; STK.DongSo = cbDongSo.Checked; _SoTietKiemCtr.UpdateSTK(STK); Close(); } } } //Only Allow Input Numbers private void txtSoTienGui_TextChanged(object sender, EventArgs e) { //Only Allow Numbers txtSoTienGui.Text = Regex.Replace(txtSoTienGui.Text, "[^.0-9]", ""); txtSoTienGui.SelectionStart = txtSoTienGui.TextLength; } //Only Allow Input Numbers private void txtCmnd_TextChanged(object sender, EventArgs e) { txtCmnd.Text = Regex.Replace(txtCmnd.Text, "[^0-9]", ""); txtCmnd.SelectionStart = txtCmnd.TextLength; } } }
0lll-qlstk
trunk/QuanLiSoTietKiem/frmSoTietKiem.cs
C#
oos
6,668
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using System.Configuration; using System.Data; using System.Windows.Forms; namespace QuanLiSoTietKiem { class Database { #region Khai Bao Bien //Default Str_SqlConnect = CNString in App.config private static string Str_SqlConnect = ConfigurationManager.ConnectionStrings["CNString"].ConnectionString; private static SqlConnection SqlConnect; private static SqlCommand Sqlcmd; #endregion #region Hàm Khởi Tạo public Database() { } public Database(string Sql_String) { Str_SqlConnect = Sql_String; } #endregion #region Function //Open Connect public static bool OpenConnectDB() { try { if (SqlConnect == null) SqlConnect = new SqlConnection(Str_SqlConnect); if (SqlConnect.State == ConnectionState.Closed) SqlConnect.Open(); return true; } catch { SqlConnect.Close(); return false; } } //Close Connect public static void CloseConnectDB() { SqlConnect.Close(); } //Execute Query with parameters public static int ExNonQuery(string Sql, SqlParameter[] parameters = null) { int result = 0; try { Sqlcmd = new SqlCommand(Sql, SqlConnect); if (parameters != null) { foreach (SqlParameter param in parameters) { Sqlcmd.Parameters.Add(param); } } result = Sqlcmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show("Error Execure Non Query : " + ex); } return result; } //Get Reader public static SqlDataReader GetReader(string Sql, SqlParameter[] parameters = null) { SqlDataReader result = null; try { Sqlcmd = new SqlCommand(Sql, SqlConnect); if (parameters != null) { foreach (SqlParameter param in parameters) { Sqlcmd.Parameters.Add(param); } } result = Sqlcmd.ExecuteReader(); } catch (Exception ex) { MessageBox.Show("Error Get Reader: " + ex); } return result; } #endregion } }
0lll-qlstk
trunk/QuanLiSoTietKiem/Database.cs
C#
oos
2,994
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace QuanLiSoTietKiem.ValueObject { public class SoTietKiemInfo { private string _MaSTK; private string _TenKH; private string _DiaChi; private string _SoCMND; private float _SoTienGuiBD; private float _SoDu; private string _LoaiTietKiem; private int _MaLoaiTietKiem; private DateTime _NgayMoSo; private float _LaiSuat; private bool _DongSo; public string MaSTK { set { _MaSTK = value; } get { return _MaSTK; } } public string TenKH { set { _TenKH = value; } get { return _TenKH; } } public string DiaChi { set { _DiaChi = value; } get { return _DiaChi; } } public string SoCMND { set { _SoCMND = value; } get { return _SoCMND; } } public float SoTienGuiBD { set { _SoTienGuiBD = value; } get { return _SoTienGuiBD; } } public float SoDu { set { _SoDu = value; } get { return _SoDu; } } public string LoaiTietKiem { set { _LoaiTietKiem = value; } get { return _LoaiTietKiem; } } public DateTime NgayMoSo { set { _NgayMoSo = value; } get { return _NgayMoSo; } } public float LaiSuat { set { _LaiSuat = value; } get { return _LaiSuat;} } public bool DongSo { set { _DongSo = value; } get { return _DongSo; } } public int MaLoaiTietKiem { set { _MaLoaiTietKiem = value; } get { return _MaLoaiTietKiem; } } } }
0lll-qlstk
trunk/QuanLiSoTietKiem/ValueObject/SoTietKiemInfo.cs
C#
oos
2,059
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace QuanLiSoTietKiem.ValueObject { class Phieu { private string _MaPhieu; private string _MSTietKiem; private string _TenKH; private int _SoTien; private DateTime _NgayGui; public string MaGuiTien { set { _MaPhieu = value; } get { return _MaPhieu; } } public string MSTietKiem { set { _MSTietKiem = value; } get { return _MSTietKiem; } } public string TenKH { set { _TenKH = value; } get { return _TenKH; } } public int SoTien { set { _SoTien = value; } get { return _SoTien; } } public DateTime NgayGui { set { _NgayGui = value; } get { return _NgayGui; } } } }
0lll-qlstk
trunk/QuanLiSoTietKiem/ValueObject/Phieu.cs
C#
oos
1,002
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace QuanLiSoTietKiem.ValueObject { public class UserInfo { private string _User; private string _Pass; private int _GroupID; public string User { get { return _User; } set { this._User = value; } } public string Pass { get { return _Pass; } set { this._Pass = value; } } public int GroupID { get { return _GroupID; } set { this._GroupID = value; } } } }
0lll-qlstk
trunk/QuanLiSoTietKiem/ValueObject/UserInfo.cs
C#
oos
665
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("QuanLiSoTietKiem")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("QuanLiSoTietKiem")] [assembly: AssemblyCopyright("Copyright © 2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("41399ad8-ddb1-4546-a11c-335d8f58d2b6")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
0lll-qlstk
trunk/QuanLiSoTietKiem/Properties/AssemblyInfo.cs
C#
oos
1,444
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Text.RegularExpressions; using QuanLiSoTietKiem.Controller; using QuanLiSoTietKiem.ValueObject; namespace QuanLiSoTietKiem { public partial class frmPhieuGuiTien : Form { //Conntroller PhieuGuiTienCtr _PhieuGuiTienCtr = new PhieuGuiTienCtr(); //int _LoaiTietKiem; public frmPhieuGuiTien()//string MaSTK, int LoaiTietKiem) { InitializeComponent(); //_LoaiTietKiem = LoaiTietKiem; } private void frmPhieuGuiTien_FormClosed(object sender, FormClosedEventArgs e) { Form frm = Application.OpenForms["frmMain"]; frm.Show(); } private void frmPhieuGuiTien_Load(object sender, EventArgs e) { /* if (_PhieuGuiTienCtr.CheckDeposit(_LoaiTietKiem) == 0) { MessageBox.Show("Không Thể Gửi Thêm Tiền Cho Loại Tiết Kiệm Này."); Close(); }*/ _PhieuGuiTienCtr.GetMaSTK(cmbMaSo); cmbMaSo.SelectedIndex = 0; txtMaPGT.Text = _PhieuGuiTienCtr.CreateMaGT(); } private void btnThoat_Click(object sender, EventArgs e) { Close(); } private void cmbMaSo_SelectedIndexChanged(object sender, EventArgs e) { Function.cb_Item item = (Function.cb_Item)cmbMaSo.SelectedItem; txtKhachHang.Text = item._Id.ToString(); } private void txtSoTienGui_TextChanged(object sender, EventArgs e) { //Only Allow Numbers txtSoTienGui.Text = Regex.Replace(txtSoTienGui.Text, "[^.0-9]", ""); txtSoTienGui.SelectionStart = txtSoTienGui.TextLength; } //Lap Phieu private void btnLapPhieu_Click(object sender, EventArgs e) { if (_PhieuGuiTienCtr.CheckDeposit(Function.GetLoaiTietKiem(cmbMaSo.Text)) == 0) { MessageBox.Show("Không Thể Gửi Tiền Cho Loại Tài Khoản Này."); } else { if (txtSoTienGui.Text == "") { MessageBox.Show("Nhập Số Tiền Cần Gửi."); } else { Phieu _PhieuGuiTienInfo = new Phieu(); _PhieuGuiTienInfo.MaGuiTien = txtMaPGT.Text; _PhieuGuiTienInfo.MSTietKiem = cmbMaSo.Text; _PhieuGuiTienInfo.NgayGui = DateTime.Parse(dtNgayGui.Text); _PhieuGuiTienInfo.SoTien = Int32.Parse(txtSoTienGui.Text); _PhieuGuiTienInfo.TenKH = txtKhachHang.Text; int result = _PhieuGuiTienCtr.AddPGT(_PhieuGuiTienInfo); if (result == 0) { MessageBox.Show("Lỗi Lập Phiếu Gửi Tiền."); } else { MessageBox.Show("Đã Lập Phiếu Gửi Tiền."); Close(); } } } } } }
0lll-qlstk
trunk/QuanLiSoTietKiem/frmPhieuGuiTien.cs
C#
oos
3,441
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; namespace QuanLiSoTietKiem { class Function { //Item for CommoBox public class cb_Item { public object _Id; public string _Name; public object Id { set { _Id = value; } get { return _Id; } } public string Name { set { _Name = value; } get { return _Name; } } } //GetSetting public static string GetSetting(string Name) { string result; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@Name", Name); SqlDataReader dt = Database.GetReader("SELECT _values FROM _Setting WHERE _name=@Name", param); if (dt.HasRows) { dt.Read(); result = dt[0].ToString(); dt.Close(); } else { result = null; } return result; } //Get LaiSuat public static float GetLaiSuat(int MaKyHan) { float result; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@MaKyHan", MaKyHan); SqlDataReader dt = Database.GetReader("select LaiSuat from LOAITIETKIEM where MaLoaiTietKiem=@MaKyHan", param); if (dt.HasRows) { dt.Read(); result = float.Parse(dt[0].ToString()); dt.Close(); } else { result = 0; } return result; } //Get LoaiTietKiem public static int GetLoaiTietKiem(string MaSTK) { int result; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@MaSTK", MaSTK); SqlDataReader dt = Database.GetReader("select LoaiTietKiem from SOTIETKIEM where MSTietKiem=@MaSTK", param); if (dt.HasRows) { dt.Read(); result = Int32.Parse(dt[0].ToString()); dt.Close(); } else { result = -1; } return result; } //Get Name TietKiem from MaLoaiTietKiem public static string GetNameTietKiem(int MaLTK) { string result=null; return result; } } }
0lll-qlstk
trunk/QuanLiSoTietKiem/Function.cs
C#
oos
2,750
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using QuanLiSoTietKiem; using QuanLiSoTietKiem.Controller; using QuanLiSoTietKiem.ValueObject; namespace QuanLiSoTietKiem { public partial class frmMain : Form { public frmMain() { InitializeComponent(); Database.OpenConnectDB(); } //Main Controller MainCtr _MainCtr = new MainCtr(); //About private void menuAbout_Click(object sender, EventArgs e) { } private void frmMain_Load(object sender, EventArgs e) { Database DB = new Database(); //this.Text += " - WelCome " + IsLogin._User.User + " ! Bạn Đăng Nhập Lúc: " + IsLogin._Time; _MainCtr.GetSTK(dtgvSTK); // timerLaiSuat.Enabled = true; } //Quản Lý Tài Khoản Login private void menuTaiKhoan_Click(object sender, EventArgs e) { Form frm = Application.OpenForms["frmUsers"]; if (frm == null) frm = new frmUsers(); //this.Hide(); frm.ShowDialog(); } //Lập Phiếu Rút Tiền private void toolStripButtonLPRT_Click(object sender, EventArgs e) { Form frmPhieuRutTien = Application.OpenForms["frmPhieuRutTien"]; if (frmPhieuRutTien == null) frmPhieuRutTien = new frmPhieuRutTien(); //this.Hide(); frmPhieuRutTien.ShowDialog(); } //Lập Phiếu Gửi Tiền private void toolStripButtonLPGT_Click(object sender, EventArgs e) { /*foreach (DataGridViewRow row in dtgvSTK.SelectedRows) { Form frmPhieuGuiTien = Application.OpenForms["frmPhieuGuiTien"]; if (frmPhieuGuiTien == null) frmPhieuGuiTien = new frmPhieuGuiTien(row.Cells[0].Value.ToString(), 3); this.Hide(); if (!frmPhieuGuiTien.Visible) { frmPhieuGuiTien.Show(); } }*/ Form frmPhieuGuiTien = Application.OpenForms["frmPhieuGuiTien"]; if (frmPhieuGuiTien == null) frmPhieuGuiTien = new frmPhieuGuiTien(); frmPhieuGuiTien.FormClosed += new FormClosedEventHandler(frmChild_FormClosed); //Hide Form Main //this.Hide(); if (!frmPhieuGuiTien.Visible) { frmPhieuGuiTien.ShowDialog(); } } //Mở Sổ Tiết Kiệm private void toolStripButtonMoSTK_Click(object sender, EventArgs e) { Form frmSoTietKiem = Application.OpenForms["frmSoTietKiem"]; if (frmSoTietKiem == null) frmSoTietKiem = new frmSoTietKiem(); frmSoTietKiem.FormClosed += new FormClosedEventHandler(frmChild_FormClosed); //this.Hide(); frmSoTietKiem.ShowDialog(); } //Reload DataGridView SOTIETKIEM when Form Child Close -> frmSoTietKiem_FormClosed private void frmChild_FormClosed(object sender, FormClosedEventArgs e) { _MainCtr.GetSTK(dtgvSTK); } //Double Click On Row In DataGridView private void dtgvSTK_DoubleClick(object sender, EventArgs e) { foreach (DataGridViewRow row in dtgvSTK.SelectedRows) { Form frmSoTietKiem = Application.OpenForms["frmSoTietKiem"]; if (frmSoTietKiem == null) { SoTietKiemInfo _SoTietKiem = new SoTietKiemInfo(); _SoTietKiem.MaSTK = row.Cells[0].Value.ToString(); _SoTietKiem.TenKH = row.Cells[1].Value.ToString(); _SoTietKiem.DiaChi = row.Cells[3].Value.ToString(); _SoTietKiem.SoTienGuiBD = float.Parse(row.Cells[5].Value.ToString()); _SoTietKiem.SoDu = float.Parse(row.Cells[6].Value.ToString()); _SoTietKiem.NgayMoSo = DateTime.Parse(row.Cells[4].Value.ToString()); _SoTietKiem.LoaiTietKiem = row.Cells[8].Value.ToString(); _SoTietKiem.SoCMND = row.Cells[2].Value.ToString(); _SoTietKiem.DongSo = (bool)row.Cells[9].Value; frmSoTietKiem = new frmSoTietKiem(_SoTietKiem); } frmSoTietKiem.FormClosed += new FormClosedEventHandler(frmChild_FormClosed); this.Hide(); frmSoTietKiem.Show(); } } //Sửa private void toolStripButtonSua_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dtgvSTK.SelectedRows) { Form frmSoTietKiem = Application.OpenForms["frmSoTietKiem"]; if (frmSoTietKiem == null) { SoTietKiemInfo _SoTietKiem = new SoTietKiemInfo(); _SoTietKiem.MaSTK =row.Cells[0].Value.ToString(); _SoTietKiem.TenKH= row.Cells[1].Value.ToString(); _SoTietKiem.DiaChi= row.Cells[3].Value.ToString(); _SoTietKiem.SoTienGuiBD= float.Parse(row.Cells[5].Value.ToString()); _SoTietKiem.SoDu = float.Parse(row.Cells[6].Value.ToString()); _SoTietKiem.NgayMoSo = DateTime.Parse(row.Cells[4].Value.ToString()); _SoTietKiem.LoaiTietKiem= row.Cells[8].Value.ToString(); _SoTietKiem.SoCMND= row.Cells[2].Value.ToString(); _SoTietKiem.DongSo = (bool)row.Cells[9].Value; frmSoTietKiem = new frmSoTietKiem(_SoTietKiem); } frmSoTietKiem.FormClosed += new FormClosedEventHandler(frmChild_FormClosed); //this.Hide(); frmSoTietKiem.ShowDialog(); } } //Form Closed private void frmMain_FormClosed(object sender, FormClosedEventArgs e) { Database.CloseConnectDB(); } //Xóa SOTIETKIEM private void toolStripButtonXoa_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dtgvSTK.SelectedRows) { _MainCtr.DelSTK(row.Cells[0].Value.ToString()); _MainCtr.GetSTK(dtgvSTK); } } private void frmMain_FormClosing(object sender, FormClosingEventArgs e) { } private void timerLaiSuat_Tick(object sender, EventArgs e) { } private void menuPhanQuyen_Click(object sender, EventArgs e) { } private void memuThietLapQuyDinh_Click(object sender, EventArgs e) { } private void menuMoSTK_Click(object sender, EventArgs e) { } } }
0lll-qlstk
trunk/QuanLiSoTietKiem/frmMain.cs
C#
oos
7,395
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using QuanLiSoTietKiem.Controller; using QuanLiSoTietKiem.ValueObject; namespace QuanLiSoTietKiem { public partial class frmPhieuRutTien : Form { //Conntroller PhieuRutTienCtr _PhieuRutTienCtr = new PhieuRutTienCtr(); public frmPhieuRutTien() { InitializeComponent(); } private void frmPhieuRutTien_Load(object sender, EventArgs e) { _PhieuRutTienCtr.ShowLoaiTietKiem(cmbLoaiTietKiem); _PhieuRutTienCtr.GetMaSTK(cmbMaSo); cmbMaSo.SelectedIndex = 0; txtMaPRT.Text = _PhieuRutTienCtr.CreateMaRT(); } private void btnThoat_Click(object sender, EventArgs e) { Close(); } private void frmPhieuRutTien_FormClosed(object sender, FormClosedEventArgs e) { Form frm = Application.OpenForms["frmMain"]; frm.Show(); } private void cmbMaSo_SelectedIndexChanged(object sender, EventArgs e) { Function.cb_Item item = (Function.cb_Item)cmbMaSo.SelectedItem; txtKhachHang.Text = item._Id.ToString(); SoTietKiemInfo STK = _PhieuRutTienCtr.GetSTK(cmbMaSo.Text); cmbLoaiTietKiem.SelectedIndex = STK.MaLoaiTietKiem-1; //MessageBox.Show(STK.MaLoaiTietKiem.ToString()); } private void btnLapPhieu_Click(object sender, EventArgs e) { TimeSpan day = DateTime.Now - _PhieuRutTienCtr.GetDate(cmbMaSo.Text); if (day.Days<15) { MessageBox.Show("Tài Khoản Chưa Đủ Ngày Để Rút."); } else { } } } }
0lll-qlstk
trunk/QuanLiSoTietKiem/frmPhieuRutTien.cs
C#
oos
2,023
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using QuanLiSoTietKiem.Controller; namespace QuanLiSoTietKiem { public partial class frmUsers : Form { public frmUsers() { InitializeComponent(); Database.OpenConnectDB(); } UserCtr _UserCtr = new UserCtr(); //Clear public void Cleartxt() { txtUserName.Text = ""; txtPass.Text = ""; } private void frmUsers_Load(object sender, EventArgs e) { _UserCtr.GetUserInfo(lstvUsers); _UserCtr.GetGroup(cmbGroupID); } private void btnThem_Click(object sender, EventArgs e) { lblID.Text = "0"; Cleartxt(); } private void btnLuu_Click(object sender, EventArgs e) { int result; if (lblID.Text == "0") { result = _UserCtr.AddUser(txtUserName, txtPass, cmbGroupID); //MessageBox.Show(result.ToString()); if (result == -1) { MessageBox.Show("Điền Đầy Đủ Thông Tin."); } else if (result == 1) { MessageBox.Show("Thêm Thành Công."); Cleartxt(); _UserCtr.GetUserInfo(lstvUsers); } else { MessageBox.Show("Lỗi."); } } else { result = _UserCtr.UpdateUser(lblID, txtUserName, txtPass, cmbGroupID); if (result == 1) { _UserCtr.GetUserInfo(lstvUsers); MessageBox.Show("Đã Sửa Thành Công."); } else { MessageBox.Show("Lỗi Sửa"); } } } private void lstvUsers_Click(object sender, EventArgs e) { foreach (ListViewItem item in lstvUsers.SelectedItems) { if (item.Selected) { lblID.Text = item.SubItems[0].Text; txtUserName.Text = item.SubItems[1].Text; txtPass.Text = item.SubItems[2].Text; cmbGroupID.Text = item.SubItems[3].Text; } } } private void btnThoat_Click(object sender, EventArgs e) { this.Close(); } private void frmUsers_FormClosed(object sender, FormClosedEventArgs e) { Form frm = Application.OpenForms["frmMain"]; frm.Show(); } private void btnXoa_Click(object sender, EventArgs e) { int result = _UserCtr.DelUser(lblID); if (result == 1) { Cleartxt(); _UserCtr.GetUserInfo(lstvUsers); MessageBox.Show("Đã Xóa."); } else { MessageBox.Show("Lỗi Xóa User."); } } private void lstvUsers_SelectedIndexChanged(object sender, EventArgs e) { foreach (ListViewItem item in lstvUsers.SelectedItems) { if (item.Selected) { lblID.Text = item.SubItems[0].Text; txtUserName.Text = item.SubItems[1].Text; txtPass.Text = item.SubItems[2].Text; cmbGroupID.Text = item.SubItems[3].Text; } } } } }
0lll-qlstk
trunk/QuanLiSoTietKiem/frmUsers.cs
C#
oos
3,913
using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace QuanLiSoTietKiem { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new frmLogin()); //if (IsLogin._IsLogin == true) Application.Run(new frmMain()); } } }
0lll-qlstk
trunk/QuanLiSoTietKiem/Program.cs
C#
oos
607
using System.Collections.Generic; namespace footwear { public class PosterAdsBus { private readonly PosterAdsDao _posterAdsDao = new PosterAdsDao(); public List<PosterAds> GetListAds() { return _posterAdsDao.GetListAds(); } public bool AddPosterAds(string title, string description, string imageSource) { return _posterAdsDao.AddPosterAds(title, description, imageSource); } public PosterAds GetAdsById(string id) { return _posterAdsDao.GetAdsById(id); } public bool UpdateAdsById(string id, string title, string description, string imagelink) { return _posterAdsDao.UpdateAdsById(id, title, description, imagelink); } } }
10-2012-savi-golden
trunk/golden-footwear/BUS/PosterAdsBus.cs
C#
asf20
822
using System.Collections.Generic; namespace footwear { public class CompanyInfoBus { private readonly CompanyInfoDao _companyInfoDao = new CompanyInfoDao(); public List<CompanyInfo> GetCompanyInfo() { return _companyInfoDao.GetCompanyInfo(); } public bool AddCompanyInfo(string companyName, string companyPhoneNumber, string companyAddress) { return _companyInfoDao.AddCompanyInfo(companyName, companyPhoneNumber, companyAddress); } } }
10-2012-savi-golden
trunk/golden-footwear/BUS/CompanyInfoBus.cs
C#
asf20
560
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace footwear { public class UserBus { } }
10-2012-savi-golden
trunk/golden-footwear/BUS/UserBus.cs
C#
asf20
158
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace footwear { public class CategoryBus { private readonly CategoryDao _categoryDao = new CategoryDao(); public List<Category> GetListCategory() { return _categoryDao.GetListCategory(); } public List<Category> GetListCategoryShowIndex() { return _categoryDao.GetListShowIndexCategory(); } public string GetType(int id) { return _categoryDao.GetType(id); } public Category GetCategoryById(string id) { return _categoryDao.GetCategoryById(id); } public bool UpdateCategoryById(string id, string type, string showIndex) { return _categoryDao.UpdateCategoryById(id, type, showIndex); } public bool AddCategoryById(string type, string showIndex) { return _categoryDao.AddCategoryById(type, showIndex); } } }
10-2012-savi-golden
trunk/golden-footwear/BUS/CategoryBus.cs
C#
asf20
1,088
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace footwear { public class ShoeInfoBus { private readonly ShoeInfoDao _shoeInfoDao = new ShoeInfoDao(); public List<ShoeInfo> GetListShoesShowIndexByCategory(string categoryType) { return _shoeInfoDao.GetListShoesShowIndexByCategory(categoryType); } public List<ShoeInfo> GetAllShoeItem() { return _shoeInfoDao.GetAllShoeItem(); } public List<ShoeInfo> GetListShoesByCategory(string categoryType) { return _shoeInfoDao.GetListShoesByCategory(categoryType); } public ShoeInfo GetSpecificShoe(string code) { return _shoeInfoDao.GetSpecificShoe(code); } public bool DeleteProductByCode(string code) { return _shoeInfoDao.DeleteProductByCode(code); } public bool AddProduct(string code, string name, string price, string imageSource, string showIndex, string typeId, string size, string color, string description, string leftImage, string rightImage, string frontImage, string backImage, string topImage) { return _shoeInfoDao.AddProduct(code, name, price, imageSource, showIndex, typeId, size, color, description, leftImage, rightImage, frontImage, backImage, topImage); } public bool UpdateProductByCode(string code, string name, string price, string imageSource, string showIndex, string typeId, string size, string color, string description, string leftImage, string rightImage, string frontImage, string backImage, string topImage) { return _shoeInfoDao.UpdateProductByCode(code, name, price, imageSource, showIndex, typeId, size, color, description, leftImage, rightImage, frontImage, backImage, topImage); } } }
10-2012-savi-golden
trunk/golden-footwear/BUS/ShoeInfoBus.cs
C#
asf20
2,023
using System.Configuration; using MySql.Data.MySqlClient; namespace footwear { public class DbConnect { public static MySqlConnection Connection; private readonly string _server; private readonly string _database; private readonly string _uid; private readonly string _password; public DbConnect() { _server = "localhost"; _database = "shoesdatabase"; if (ConfigurationSettings.AppSettings != null) _uid = ConfigurationSettings.AppSettings["usernameDB"]; if (ConfigurationSettings.AppSettings != null) _password = ConfigurationSettings.AppSettings["passwordDB"]; string connectionString = "SERVER=" + _server + ";" + "DATABASE=" + _database + ";" + "UID=" + _uid + ";" + "PASSWORD=" + _password + ";"; Connection = new MySqlConnection(connectionString); } public static bool OpenConnection() { try { Connection.Open(); return true; } catch (MySqlException) { return false; } } public static bool CloseConnection() { try { Connection.Close(); return true; } catch (MySqlException) { return false; } } } }
10-2012-savi-golden
trunk/golden-footwear/Utility/DbConnect.cs
C#
asf20
1,534
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Manage.aspx.cs" Inherits="footwear.Manage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <% if (Session["Check"] == null) { Session["Check"] = "FAIL"; } if (Session["Check"].ToString() == "OK") {%> <a href="ManagePoster.aspx">Quản lý poster</a> <a href="ManageCategory.aspx">Quản lý danh mục</a> <a href="ManageProduct.aspx">Quản lý sản phẩm</a> <%} else {%> Bạn chưa đăng nhập vào chức năng quản lý. Vui lòng click tại <a href="LoginPage.aspx">đây</a>. <%} %> </div> </form> </body> </html>
10-2012-savi-golden
trunk/golden-footwear/Manage.aspx
ASP.NET
asf20
975
<%@ Application Codebehind="Global.asax.cs" Inherits="golden_footwear.Global" Language="C#" %>
10-2012-savi-golden
trunk/golden-footwear/Global.asax
ASP.NET
asf20
99
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LoginPage.aspx.cs" Inherits="footwear.LoginPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> Username: <asp:TextBox ID="txtUsername" runat="server"></asp:TextBox> <br /> Password: <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="OK" /> </div> </form> </body> </html>
10-2012-savi-golden
trunk/golden-footwear/LoginPage.aspx
ASP.NET
asf20
744
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace footwear { public class UserDao { } }
10-2012-savi-golden
trunk/golden-footwear/DAO/UserDao.cs
C#
asf20
158
using System; using System.Collections.Generic; using System.Data; using MySql.Data.MySqlClient; namespace footwear { public class ShoeInfoDao { public List<ShoeInfo> GetAllShoeItem() { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); var list = new List<ShoeInfo>(); try { var myCommand = new MySqlCommand("GetListShoes;", DbConnect.Connection) { CommandType = CommandType.StoredProcedure }; MySqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { var shoe = new ShoeInfo { Code = reader["Code"].ToString(), Name = reader["Name"].ToString(), NameEng = reader["NameEng"].ToString(), Price = reader["Price"].ToString(), ImageSource = reader["Image"].ToString() }; list.Add(shoe); } DbConnect.CloseConnection(); } catch (MySqlException) { DbConnect.CloseConnection(); } return list; } public ShoeInfo GetSpecificShoe(string code) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); var shoeInfo = new ShoeInfo(); try { var myCommand = new MySqlCommand("GetSpecificShoe;", DbConnect.Connection) { CommandType = CommandType.StoredProcedure }; myCommand.Parameters.AddWithValue("?code", code); myCommand.Parameters["?code"].Direction = ParameterDirection.Input; MySqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { shoeInfo.Code = code; shoeInfo.ImageSource = reader["Image"].ToString(); shoeInfo.Name = reader["Name"].ToString(); shoeInfo.Price = reader["Price"].ToString(); shoeInfo.ShowIndex = Convert.ToInt32(reader["ShowIndex"].ToString()); shoeInfo.ShoeSubInfo.Type = reader["Type"].ToString(); shoeInfo.ShoeSubInfo.Size = reader["Size"].ToString(); shoeInfo.ShoeSubInfo.Color = reader["Color"].ToString(); shoeInfo.ShoeSubInfo.Description = reader["Description"].ToString(); shoeInfo.ShoeSubInfo.LeftImageSource = reader["Left_image"].ToString(); shoeInfo.ShoeSubInfo.RightImageSource = reader["Right_image"].ToString(); shoeInfo.ShoeSubInfo.FrontImageSource = reader["Front_image"].ToString(); shoeInfo.ShoeSubInfo.BackImageSource = reader["Back_image"].ToString(); shoeInfo.ShoeSubInfo.TopImageSource = reader["Top_image"].ToString(); } DbConnect.CloseConnection(); return shoeInfo; } catch (MySqlException) { DbConnect.CloseConnection(); return shoeInfo; } } public List<ShoeInfo> GetListShoesByCategory(string categoryType) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); var list = new List<ShoeInfo>(); try { string query = "SELECT shoes_detail.Code, shoes_detail.Name, shoes_detail.Price, shoes_detail.Image, shoes_detail.ShowIndex, category.Type "; query += "FROM shoes_detail, category "; query += "WHERE category.Id = shoes_detail.TypeId;"; var myCommand = new MySqlCommand(query, DbConnect.Connection); MySqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { if (reader["Type"].ToString() == categoryType) { var shoe = new ShoeInfo { Code = reader["Code"].ToString(), Name = reader["Name"].ToString(), Price = reader["Price"].ToString(), ShowIndex = Convert.ToInt32(reader["ShowIndex"].ToString()), ImageSource = reader["Image"].ToString() }; list.Add(shoe); } } DbConnect.CloseConnection(); } catch (MySqlException) { DbConnect.CloseConnection(); } return list; } public List<ShoeInfo> GetListShoesShowIndexByCategory(string categoryType) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); var list = new List<ShoeInfo>(); try { string query = "SELECT shoes_detail.Code, shoes_detail.Name, shoes_detail.Price, shoes_detail.Image, shoes_detail.ShowIndex, category.Type "; query += "FROM shoes_detail, category "; query += "WHERE category.Id = shoes_detail.TypeId;"; var myCommand = new MySqlCommand(query, DbConnect.Connection); MySqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { if (Convert.ToInt32(reader["ShowIndex"].ToString()) == 1 && reader["Type"].ToString() == categoryType) { var shoe = new ShoeInfo { Code = reader["Code"].ToString(), Name = reader["Name"].ToString(), Price = reader["Price"].ToString(), ShowIndex = Convert.ToInt32(reader["ShowIndex"].ToString()), ImageSource = reader["Image"].ToString() }; list.Add(shoe); } } DbConnect.CloseConnection(); } catch (MySqlException) { DbConnect.CloseConnection(); } return list; } public bool DeleteProductByCode(string code) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); try { string query = "DELETE FROM shoes_image WHERE ShoeCode=?code; DELETE FROM shoes_detail WHERE Code=?code;"; var myCommand = new MySqlCommand(query, DbConnect.Connection); myCommand.Parameters.AddWithValue("code", code); try { myCommand.ExecuteNonQuery(); DbConnect.CloseConnection(); return true; } catch { DbConnect.CloseConnection(); return false; } } catch (MySqlException) { return false; } } public bool AddProduct(string code, string name, string price, string imageSource, string showIndex, string typeId, string size, string color, string description, string leftImage, string rightImage, string frontImage, string backImage, string topImage) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); try { string query = "INSERT INTO shoes_detail (Code, Name, Size, Price, Color, Image, Description, TypeId, ShowIndex) "; query += "VALUES (?code, ?name, ?size, ?price, ?color, ?image, ?description, ?typeId, ?showIndex); "; query += "INSERT INTO shoes_image (ShoeCode, Left_Image, Right_Image, Front_Image, Back_Image, Top_Image) "; query += "VALUES (?code, ?leftImage, ?rightImage, ?frontImage, ?backImage, ?topImage); "; var myCommand = new MySqlCommand(query, DbConnect.Connection); myCommand.Parameters.AddWithValue("code", code); myCommand.Parameters.AddWithValue("name", name); myCommand.Parameters.AddWithValue("size", size); myCommand.Parameters.AddWithValue("price", price); myCommand.Parameters.AddWithValue("color", color); myCommand.Parameters.AddWithValue("image", imageSource); myCommand.Parameters.AddWithValue("description", description); myCommand.Parameters.AddWithValue("typeId", typeId); myCommand.Parameters.AddWithValue("showIndex", showIndex); myCommand.Parameters.AddWithValue("leftImage", leftImage); myCommand.Parameters.AddWithValue("rightImage", rightImage); myCommand.Parameters.AddWithValue("frontImage", frontImage); myCommand.Parameters.AddWithValue("backImage", backImage); myCommand.Parameters.AddWithValue("topImage", topImage); try { myCommand.ExecuteNonQuery(); DbConnect.CloseConnection(); return true; } catch { DbConnect.CloseConnection(); return false; } } catch (MySqlException) { return false; } } public bool UpdateProductByCode(string code, string name, string price, string imageSource, string showIndex, string typeId, string size, string color, string description, string leftImage, string rightImage, string frontImage, string backImage, string topImage) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); try { string query = "UPDATE shoes_detail SET Name=?name, Size=?size, Price=?price, Color=?color, Image=?image, Description=?description, TypeId=?typeId, ShowIndex=?showIndex WHERE Code=?code; "; query += "UPDATE shoes_image SET Left_image=?leftImage, Right_image=?rightImage, Front_image=?frontImage, Back_image=?backImage, Top_image=?topImage WHERE ShoeCode=?code;"; var myCommand = new MySqlCommand(query, DbConnect.Connection); myCommand.Parameters.AddWithValue("code", code); myCommand.Parameters.AddWithValue("name", name); myCommand.Parameters.AddWithValue("size", size); myCommand.Parameters.AddWithValue("price", price); myCommand.Parameters.AddWithValue("color", color); myCommand.Parameters.AddWithValue("image", imageSource); myCommand.Parameters.AddWithValue("description", description); myCommand.Parameters.AddWithValue("typeId", typeId); myCommand.Parameters.AddWithValue("showIndex", showIndex); myCommand.Parameters.AddWithValue("leftImage", leftImage); myCommand.Parameters.AddWithValue("rightImage", rightImage); myCommand.Parameters.AddWithValue("frontImage", frontImage); myCommand.Parameters.AddWithValue("backImage", backImage); myCommand.Parameters.AddWithValue("topImage", topImage); try { myCommand.ExecuteNonQuery(); DbConnect.CloseConnection(); return true; } catch { DbConnect.CloseConnection(); return false; } } catch (MySqlException) { return false; } } } }
10-2012-savi-golden
trunk/golden-footwear/DAO/ShoeInfoDao.cs
C#
asf20
13,024
using System.Collections.Generic; using System.Data; using MySql.Data.MySqlClient; namespace footwear { public class PosterAdsDao { public List<PosterAds> GetListAds() { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); var list = new List<PosterAds>(); try { var myCommand = new MySqlCommand("GetListAds;", DbConnect.Connection) { CommandType = CommandType.StoredProcedure }; MySqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { var posterAds = new PosterAds { Id = reader["Id"].ToString(), Title = reader["Title"].ToString(), TitleEng = reader["TitleEng"].ToString(), DescriptionEng = reader["DescriptionEng"].ToString(), Description = reader["Description"].ToString(), ImageSource = reader["Image"].ToString() }; list.Add(posterAds); } DbConnect.CloseConnection(); } catch (MySqlException) { DbConnect.CloseConnection(); } return list; } public PosterAds GetAdsById(string id) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); var item = new PosterAds(); try { string query = "SELECT Id, Title, Description, TitleEng, DescriptionEng, Image FROM poster_ads WHERE Id=?ItemId"; var myCommand = new MySqlCommand(query, DbConnect.Connection); myCommand.Parameters.AddWithValue("ItemId", id); MySqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { item.Id = reader["Id"].ToString(); item.Title = reader["Title"].ToString(); item.Description = reader["Description"].ToString(); item.TitleEng = reader["TitleEng"].ToString(); item.DescriptionEng = reader["DescriptionEng"].ToString(); item.ImageSource = reader["Image"].ToString(); } DbConnect.CloseConnection(); } catch (MySqlException) { DbConnect.CloseConnection(); } return item; } public bool UpdateAdsById(string id, string title, string description, string imagelink) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); try { string query = "UPDATE poster_ads SET Title=?title, Description=?description, Image=?imagelink WHERE Id=?id"; var myCommand = new MySqlCommand(query, DbConnect.Connection); myCommand.Parameters.AddWithValue("id", id); myCommand.Parameters.AddWithValue("title", title); myCommand.Parameters.AddWithValue("description", description); myCommand.Parameters.AddWithValue("imagelink", imagelink); try { myCommand.ExecuteNonQuery(); DbConnect.CloseConnection(); return true; } catch { DbConnect.CloseConnection(); return false; } } catch (MySqlException) { return false; } } public bool AddPosterAds(string title, string description, string imageSource) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); try { var myCommand = new MySqlCommand("AddPosterAds;", DbConnect.Connection) { CommandType = CommandType.StoredProcedure }; myCommand.Parameters.AddWithValue("?title", title); myCommand.Parameters["?title"].Direction = ParameterDirection.Input; myCommand.Parameters.AddWithValue("?description", description); myCommand.Parameters["?description"].Direction = ParameterDirection.Input; myCommand.Parameters.AddWithValue("?imageSource", imageSource); myCommand.Parameters["?imageSource"].Direction = ParameterDirection.Input; myCommand.ExecuteNonQuery(); DbConnect.CloseConnection(); return true; } catch (MySqlException) { DbConnect.CloseConnection(); return false; } } } }
10-2012-savi-golden
trunk/golden-footwear/DAO/PosterAdsDao.cs
C#
asf20
5,448
using System.Collections.Generic; using System.Data; using MySql.Data.MySqlClient; namespace footwear { public class CompanyInfoDao { public List<CompanyInfo> GetCompanyInfo() { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); var list = new List<CompanyInfo>(); try { var myCommand = new MySqlCommand("GetCompanyInfo;", DbConnect.Connection) {CommandType = CommandType.StoredProcedure}; MySqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { var companyInfo = new CompanyInfo { Name = reader["Name"].ToString(), NameEng = reader["NameEng"].ToString(), Address = reader["Address"].ToString(), AddressEng = reader["AddressEng"].ToString(), PhoneNumber = reader["PhoneNumber"].ToString() }; list.Add(companyInfo); } DbConnect.CloseConnection(); } catch (MySqlException) { DbConnect.CloseConnection(); } return list; } public bool AddCompanyInfo(string companyName, string companyPhoneNumber, string companyAddress) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); try { var myCommand = new MySqlCommand("AddCompanyInfo;", DbConnect.Connection) { CommandType = CommandType.StoredProcedure }; myCommand.Parameters.AddWithValue("?name", companyName); myCommand.Parameters["?name"].Direction = ParameterDirection.Input; myCommand.Parameters.AddWithValue("?phoneNumber", companyPhoneNumber); myCommand.Parameters["?phoneNumber"].Direction = ParameterDirection.Input; myCommand.Parameters.AddWithValue("?address", companyAddress); myCommand.Parameters["?address"].Direction = ParameterDirection.Input; myCommand.ExecuteNonQuery(); DbConnect.CloseConnection(); return true; } catch (MySqlException) { DbConnect.CloseConnection(); return false; } } } }
10-2012-savi-golden
trunk/golden-footwear/DAO/CompanyInfoDao.cs
C#
asf20
2,867
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using MySql.Data.MySqlClient; namespace footwear { public class CategoryDao { public List<Category> GetListCategory() { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); var list = new List<Category>(); try { var myCommand = new MySqlCommand("GetListCategory;", DbConnect.Connection) { CommandType = CommandType.StoredProcedure }; MySqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { var category = new Category() { Id = Convert.ToInt32(reader["Id"].ToString()), Type = reader["Type"].ToString(), TypeEng = reader["TypeEng"].ToString(), ShowIndex = Convert.ToInt32(reader["ShowIndex"].ToString()) }; list.Add(category); } DbConnect.CloseConnection(); } catch (MySqlException) { DbConnect.CloseConnection(); } return list; } public Category GetCategoryById(string id) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); var item = new Category(); try { string query = "SELECT Id, Type, TypeEg, ShowIndex FROM category WHERE Id=?ItemId"; var myCommand = new MySqlCommand(query, DbConnect.Connection); myCommand.Parameters.AddWithValue("ItemId", id); MySqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { item.Id = Convert.ToInt32(reader["Id"].ToString()); item.Type = reader["Type"].ToString(); item.TypeEng = reader["TypeEng"].ToString(); item.ShowIndex = Convert.ToInt32(reader["ShowIndex"].ToString()); } DbConnect.CloseConnection(); } catch (MySqlException) { DbConnect.CloseConnection(); } return item; } public List<Category> GetListShowIndexCategory() { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); var list = new List<Category>(); try { var myCommand = new MySqlCommand("GetListCategory;", DbConnect.Connection) { CommandType = CommandType.StoredProcedure }; MySqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { if (Convert.ToInt32(reader["ShowIndex"].ToString()) == 1) { var category = new Category { Id = Convert.ToInt32(reader["Id"].ToString()), Type = reader["Type"].ToString(), TypeEng = reader["TypeEng"].ToString(), ShowIndex = Convert.ToInt32(reader["ShowIndex"].ToString()) }; list.Add(category); } } DbConnect.CloseConnection(); } catch (MySqlException) { DbConnect.CloseConnection(); } return list; } public string GetType(int id) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); var type = ""; var typeEng = ""; try { var myCommand = new MySqlCommand("GetListCategory;", DbConnect.Connection) { CommandType = CommandType.StoredProcedure }; MySqlDataReader reader = myCommand.ExecuteReader(); while (reader.Read()) { if (Convert.ToInt32(reader["Id"].ToString()) == id) { type = reader["Type"].ToString(); typeEng = reader["TypeEng"].ToString(); } } DbConnect.CloseConnection(); } catch (MySqlException) { DbConnect.CloseConnection(); } return type + "|" + typeEng; } public bool UpdateCategoryById(string id, string type, string showIndex) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); try { string query = "UPDATE category SET Type=?type, ShowIndex=?showIndex WHERE Id=?id"; var myCommand = new MySqlCommand(query, DbConnect.Connection); myCommand.Parameters.AddWithValue("id", id); myCommand.Parameters.AddWithValue("type", type); //myCommand.Parameters.AddWithValue("typeEng", typeEng); myCommand.Parameters.AddWithValue("showIndex", showIndex); try { myCommand.ExecuteNonQuery(); DbConnect.CloseConnection(); return true; } catch { DbConnect.CloseConnection(); return false; } } catch (MySqlException) { return false; } } public bool AddCategoryById(string type, string showIndex) { try { DbConnect.CloseConnection(); } catch { } DbConnect.OpenConnection(); try { string query = "INSERT INTO category (Type, ShowIndex) VALUES (?type, ?showIndex)"; var myCommand = new MySqlCommand(query, DbConnect.Connection); myCommand.Parameters.AddWithValue("type", type); myCommand.Parameters.AddWithValue("showIndex", showIndex); try { myCommand.ExecuteNonQuery(); DbConnect.CloseConnection(); return true; } catch { DbConnect.CloseConnection(); return false; } } catch (MySqlException) { return false; } } } }
10-2012-savi-golden
trunk/golden-footwear/DAO/CategoryDao.cs
C#
asf20
7,296
/* DEFAULTS ----------------------------------------------------------*/ body { background: #b6b7bc; font-size: .80em; font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif; margin: 0px; padding: 0px; color: #696969; } a:link, a:visited { color: #034af3; } a:hover { color: #1d60ff; text-decoration: none; } a:active { color: #034af3; } p { margin-bottom: 10px; line-height: 1.6em; } /* HEADINGS ----------------------------------------------------------*/ h1, h2, h3, h4, h5, h6 { font-size: 1.5em; color: #666666; font-variant: small-caps; text-transform: none; font-weight: 200; margin-bottom: 0px; } h1 { font-size: 1.6em; padding-bottom: 0px; margin-bottom: 0px; } h2 { font-size: 1.5em; font-weight: 600; } h3 { font-size: 1.2em; } h4 { font-size: 1.1em; } h5, h6 { font-size: 1em; } /* this rule styles <h1> and <h2> tags that are the first child of the left and right table columns */ .rightColumn > h1, .rightColumn > h2, .leftColumn > h1, .leftColumn > h2 { margin-top: 0px; } /* PRIMARY LAYOUT ELEMENTS ----------------------------------------------------------*/ .page { width: 960px; background-color: #fff; margin: 20px auto 0px auto; border: 1px solid #496077; } .header { position: relative; margin: 0px; padding: 0px; background: #4b6c9e; width: 100%; } .header h1 { font-weight: 700; margin: 0px; padding: 0px 0px 0px 20px; color: #f9f9f9; border: none; line-height: 2em; font-size: 2em; } .main { padding: 0px 12px; margin: 12px 8px 8px 8px; min-height: 420px; } .leftCol { padding: 6px 0px; margin: 12px 8px 8px 8px; width: 200px; min-height: 200px; } .footer { color: #4e5766; padding: 8px 0px 0px 0px; margin: 0px auto; text-align: center; line-height: normal; } /* TAB MENU ----------------------------------------------------------*/ div.hideSkiplink { background-color:#3a4f63; width:100%; } div.menu { padding: 4px 0px 4px 8px; } div.menu ul { list-style: none; margin: 0px; padding: 0px; width: auto; } div.menu ul li a, div.menu ul li a:visited { background-color: #465c71; border: 1px #4e667d solid; color: #dde4ec; display: block; line-height: 1.35em; padding: 4px 20px; text-decoration: none; white-space: nowrap; } div.menu ul li a:hover { background-color: #bfcbd6; color: #465c71; text-decoration: none; } div.menu ul li a:active { background-color: #465c71; color: #cfdbe6; text-decoration: none; } /* FORM ELEMENTS ----------------------------------------------------------*/ fieldset { margin: 1em 0px; padding: 1em; border: 1px solid #ccc; } fieldset p { margin: 2px 12px 10px 10px; } fieldset.login label, fieldset.register label, fieldset.changePassword label { display: block; } fieldset label.inline { display: inline; } legend { font-size: 1.1em; font-weight: 600; padding: 2px 4px 8px 4px; } input.textEntry { width: 320px; border: 1px solid #ccc; } input.passwordEntry { width: 320px; border: 1px solid #ccc; } div.accountInfo { width: 42%; } /* MISC ----------------------------------------------------------*/ .clear { clear: both; } .title { display: block; float: left; text-align: left; width: auto; } .loginDisplay { font-size: 1.1em; display: block; text-align: right; padding: 10px; color: White; } .loginDisplay a:link { color: white; } .loginDisplay a:visited { color: white; } .loginDisplay a:hover { color: white; } .failureNotification { font-size: 1.2em; color: Red; } .bold { font-weight: bold; } .submitButton { text-align: right; padding-right: 10px; }
10-2012-savi-golden
trunk/golden-footwear/Styles/Site.css
CSS
asf20
4,258
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace footwear { public class Category { public int Id { get; set; } public string Type { get; set; } public string TypeEng { get; set; } public int ShowIndex { get; set; } public Category() { Id = 0; Type = ""; TypeEng = ""; ShowIndex = 0; } } }
10-2012-savi-golden
trunk/golden-footwear/DTO/Category.cs
C#
asf20
478
namespace footwear { public class PosterAds { public string Id { get; set; } public string Title { get; set; } public string Description { get; set; } public string TitleEng { get; set; } public string DescriptionEng { get; set; } public string ImageSource { get; set; } public PosterAds() { Id = "0"; Title = ""; Description = ""; TitleEng = ""; DescriptionEng = ""; ImageSource = ""; } } }
10-2012-savi-golden
trunk/golden-footwear/DTO/PosterAds.cs
C#
asf20
572
namespace footwear { public class ShoeInfo { public string Code { get; set; } public string Name { get; set; } public string NameEng { get; set; } public string Price { get; set; } public string ImageSource { get; set; } public int ShowIndex { get; set; } public ShoeSubInfo ShoeSubInfo { get; set; } public ShoeInfo() { Code = ""; Name = ""; NameEng = ""; Price = ""; ImageSource = ""; ShowIndex = 0; ShoeSubInfo = new ShoeSubInfo(); } } }
10-2012-savi-golden
trunk/golden-footwear/DTO/ShoeInfo.cs
C#
asf20
643
namespace footwear { public class ShoeSubInfo { public string Type { get; set; } public string TypeEng { get; set; } public string Size { get; set; } public string Color { get; set; } public string Description { get; set; } public string DescriptionEng { get; set; } public string LeftImageSource { get; set; } public string RightImageSource { get; set; } public string FrontImageSource { get; set; } public string BackImageSource { get; set; } public string TopImageSource { get; set; } public ShoeSubInfo() { Type = ""; TypeEng = ""; Size = ""; Color = ""; Description = ""; DescriptionEng = ""; LeftImageSource = ""; RightImageSource = ""; FrontImageSource = ""; BackImageSource = ""; TopImageSource = ""; } } }
10-2012-savi-golden
trunk/golden-footwear/DTO/ShoeSubInfo.cs
C#
asf20
1,005
namespace footwear { public class CompanyInfo { public string Name { get; set; } public string NameEng { get; set; } public string PhoneNumber { get; set; } public string Address { get; set; } public string AddressEng { get; set; } public CompanyInfo() { Name = ""; NameEng = ""; PhoneNumber = ""; Address = ""; AddressEng = ""; } } }
10-2012-savi-golden
trunk/golden-footwear/DTO/CompanyInfo.cs
C#
asf20
501
<%@ Page Title="Register" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="golden_footwear.Account.Register" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <asp:CreateUserWizard ID="RegisterUser" runat="server" EnableViewState="false" OnCreatedUser="RegisterUser_CreatedUser"> <LayoutTemplate> <asp:PlaceHolder ID="wizardStepPlaceholder" runat="server"></asp:PlaceHolder> <asp:PlaceHolder ID="navigationPlaceholder" runat="server"></asp:PlaceHolder> </LayoutTemplate> <WizardSteps> <asp:CreateUserWizardStep ID="RegisterUserWizardStep" runat="server"> <ContentTemplate> <h2> Create a New Account </h2> <p> Use the form below to create a new account. </p> <p> Passwords are required to be a minimum of <%= Membership.MinRequiredPasswordLength %> characters in length. </p> <span class="failureNotification"> <asp:Literal ID="ErrorMessage" runat="server"></asp:Literal> </span> <asp:ValidationSummary ID="RegisterUserValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup"/> <div class="accountInfo"> <fieldset class="register"> <legend>Account Information</legend> <p> <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label> <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox> <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label> <asp:TextBox ID="Email" runat="server" CssClass="textEntry"></asp:TextBox> <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email" CssClass="failureNotification" ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label> <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label> <asp:TextBox ID="ConfirmPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ControlToValidate="ConfirmPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="Confirm Password is required." ID="ConfirmPasswordRequired" runat="server" ToolTip="Confirm Password is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match." ValidationGroup="RegisterUserValidationGroup">*</asp:CompareValidator> </p> </fieldset> <p class="submitButton"> <asp:Button ID="CreateUserButton" runat="server" CommandName="MoveNext" Text="Create User" ValidationGroup="RegisterUserValidationGroup"/> </p> </div> </ContentTemplate> <CustomNavigationTemplate> </CustomNavigationTemplate> </asp:CreateUserWizardStep> </WizardSteps> </asp:CreateUserWizard> </asp:Content>
10-2012-savi-golden
trunk/golden-footwear/Account/Register.aspx
ASP.NET
asf20
5,678
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace golden_footwear.Account { public partial class ChangePasswordSuccess : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
10-2012-savi-golden
trunk/golden-footwear/Account/ChangePasswordSuccess.aspx.cs
C#
asf20
360
<%@ Page Title="Change Password" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ChangePassword.aspx.cs" Inherits="golden_footwear.Account.ChangePassword" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Change Password </h2> <p> Use the form below to change your password. </p> <p> New passwords are required to be a minimum of <%= Membership.MinRequiredPasswordLength %> characters in length. </p> <asp:ChangePassword ID="ChangeUserPassword" runat="server" CancelDestinationPageUrl="~/" EnableViewState="false" RenderOuterTable="false" SuccessPageUrl="ChangePasswordSuccess.aspx"> <ChangePasswordTemplate> <span class="failureNotification"> <asp:Literal ID="FailureText" runat="server"></asp:Literal> </span> <asp:ValidationSummary ID="ChangeUserPasswordValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="ChangeUserPasswordValidationGroup"/> <div class="accountInfo"> <fieldset class="changePassword"> <legend>Account Information</legend> <p> <asp:Label ID="CurrentPasswordLabel" runat="server" AssociatedControlID="CurrentPassword">Old Password:</asp:Label> <asp:TextBox ID="CurrentPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="CurrentPasswordRequired" runat="server" ControlToValidate="CurrentPassword" CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Old Password is required." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="NewPasswordLabel" runat="server" AssociatedControlID="NewPassword">New Password:</asp:Label> <asp:TextBox ID="NewPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="NewPasswordRequired" runat="server" ControlToValidate="NewPassword" CssClass="failureNotification" ErrorMessage="New Password is required." ToolTip="New Password is required." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="ConfirmNewPasswordLabel" runat="server" AssociatedControlID="ConfirmNewPassword">Confirm New Password:</asp:Label> <asp:TextBox ID="ConfirmNewPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="ConfirmNewPasswordRequired" runat="server" ControlToValidate="ConfirmNewPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="Confirm New Password is required." ToolTip="Confirm New Password is required." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldValidator> <asp:CompareValidator ID="NewPasswordCompare" runat="server" ControlToCompare="NewPassword" ControlToValidate="ConfirmNewPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="The Confirm New Password must match the New Password entry." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:CompareValidator> </p> </fieldset> <p class="submitButton"> <asp:Button ID="CancelPushButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"/> <asp:Button ID="ChangePasswordPushButton" runat="server" CommandName="ChangePassword" Text="Change Password" ValidationGroup="ChangeUserPasswordValidationGroup"/> </p> </div> </ChangePasswordTemplate> </asp:ChangePassword> </asp:Content>
10-2012-savi-golden
trunk/golden-footwear/Account/ChangePassword.aspx
ASP.NET
asf20
4,484
<%@ Page Title="Log In" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="golden_footwear.Account.Login" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Log In </h2> <p> Please enter your username and password. <asp:HyperLink ID="RegisterHyperLink" runat="server" EnableViewState="false">Register</asp:HyperLink> if you don't have an account. </p> <asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false"> <LayoutTemplate> <span class="failureNotification"> <asp:Literal ID="FailureText" runat="server"></asp:Literal> </span> <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="LoginUserValidationGroup"/> <div class="accountInfo"> <fieldset class="login"> <legend>Account Information</legend> <p> <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label> <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox> <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label> <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:CheckBox ID="RememberMe" runat="server"/> <asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label> </p> </fieldset> <p class="submitButton"> <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup"/> </p> </div> </LayoutTemplate> </asp:Login> </asp:Content>
10-2012-savi-golden
trunk/golden-footwear/Account/Login.aspx
ASP.NET
asf20
3,072
<%@ Page Title="Change Password" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ChangePasswordSuccess.aspx.cs" Inherits="golden_footwear.Account.ChangePasswordSuccess" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Change Password </h2> <p> Your password has been changed successfully. </p> </asp:Content>
10-2012-savi-golden
trunk/golden-footwear/Account/ChangePasswordSuccess.aspx
ASP.NET
asf20
532
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace golden_footwear.Account { public partial class ChangePassword : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
10-2012-savi-golden
trunk/golden-footwear/Account/ChangePassword.aspx.cs
C#
asf20
353
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; namespace golden_footwear.Account { public partial class Register : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"]; } protected void RegisterUser_CreatedUser(object sender, EventArgs e) { FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */); string continueUrl = RegisterUser.ContinueDestinationPageUrl; if (String.IsNullOrEmpty(continueUrl)) { continueUrl = "~/"; } Response.Redirect(continueUrl); } } }
10-2012-savi-golden
trunk/golden-footwear/Account/Register.aspx.cs
C#
asf20
915
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace golden_footwear.Account { public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); } } }
10-2012-savi-golden
trunk/golden-footwear/Account/Login.aspx.cs
C#
asf20
473
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace footwear { public partial class ListProduct : System.Web.UI.Page { public CategoryBus categoryBus = new CategoryBus(); public ShoeInfoBus shoeInfoBus = new ShoeInfoBus(); public List<Category> listCategoryShowIndex; public List<ShoeInfo> listCategory1; public List<ShoeInfo> listCategory2; public List<ShoeInfo> listCategory3; public List<ShoeInfo> listCategory4; public List<ShoeInfo> list; public string name; protected void Page_Load(object sender, EventArgs e) { if (DbConnect.Connection == null) { var dbConnect = new DbConnect(); } listCategoryShowIndex = categoryBus.GetListCategoryShowIndex(); listCategory1 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[0].Type); listCategory2 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[1].Type); listCategory3 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[2].Type); listCategory4 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[3].Type); if (Request.QueryString["category"] != "all") { name = categoryBus.GetType(Convert.ToInt32(Request.QueryString["category"])); } else { name = "Tất cả"; } list = Request.QueryString["category"] == "all" ? shoeInfoBus.GetAllShoeItem() : shoeInfoBus.GetListShoesByCategory(name); } } }
10-2012-savi-golden
trunk/golden-footwear/ListProduct.aspx.cs
C#
asf20
1,782
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="footwear.index" %> <%@ Import Namespace="footwear" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Foot-were</title> <link rel="stylesheet" href="css/Master.css"/> <script type="text/javascript" src = "js/jquery.min.js"></script> <script type="text/javascript" src = "js/main.js"></script> </head> <body> <form id="form1" runat="server"> <div id = "Master"> <div id = "MasterContent"> <div class = "Left MasterDiv"> <input type = "text" class = "SearchBox Left"/> <span class = "Searchbtn Left"></span> </div> <div class = "Right MasterDiv"> <ul id = "TopRightMenu"> <li><a href = "index.aspx"><span class = "Vie">Trang chủ</span><span class = "Eng">Home</span></a></li> <li><a href = "#"><span class = "Vie">Liên hệ</span><span class = "Eng">Contact</span></a></li> <li><a href = "#"><span class = "Vie">Giới thiệu</span><span class = "Eng">Intro</span></a></li> <li><img src = "images/cart.png" width = "20" alt="CART"/></li> <li><a href = "#"><span class = "Vie">Giỏ hàng (0)</span><span class = "Eng">Your cart(0)</span></a></li> </ul> </div> <div class = "Center MasterDiv" id = "TopCenter"> <div class = "Left TwoTopbtn"><a href = "ListProduct.aspx?category=all"><div id = "BigLeft"></div></a></div> <div class = "Right TwoTopbtn"><div id = "BigRight"></div></div> </div> </div> </div> <div id = "HibridMenu" class = "Center"> <div class = "Left"> <ul class = "Right"> <li id = "Fashihon" class = "NewMenu imgRight"></li> <li id = "Profession" class = "NewMenu imgRight"></li> </ul> </div> <div class = "Right"> <ul class = "Left"> <li id = "Morden" class = "NewMenu imgLeft"></li> <li id = "Eff" class = "NewMenu imgLeft"></li> </ul> </div> <div class = "Center" id = "CenterHibrid"></div> </div> <div id = "HiddenMenu"> <ul id = "SpecUl"> <li class = "MidBig"> <a href = "ListProduct.aspx?category=<%=listCategoryShowIndex[0].Id %>" class = "abig"><%=listCategoryShowIndex[0].Type %> ></a> <ul> <li><a href = "Sanpham.aspx?code=<%=listCategory1[0].Code %>"><%=listCategory1[0].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory1[1].Code %>"><%=listCategory1[1].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory1[2].Code %>"><%=listCategory1[2].Name %> </a></li> </ul> </li> <li class = "MidBig"> <a href = "ListProduct.aspx?category=<%=listCategoryShowIndex[1].Id %>" class = "abig"><%=listCategoryShowIndex[1].Type %> ></a> <ul> <li><a href = "Sanpham.aspx?code=<%=listCategory2[0].Code %>"><%=listCategory2[0].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory2[1].Code %>"><%=listCategory2[1].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory2[2].Code %>"><%=listCategory2[2].Name %> </a></li> </ul> </li> <li class = "MidBig"> <a href = "ListProduct.aspx?category=<%=listCategoryShowIndex[2].Id %>" class = "abig"><%=listCategoryShowIndex[2].Type %> ></a> <ul> <li><a href = "Sanpham.aspx?code=<%=listCategory3[0].Code %>"><%=listCategory3[0].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory3[1].Code %>"><%=listCategory3[1].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory3[2].Code %>"><%=listCategory3[2].Name %> </a></li> </ul> </li> <li class = "MidBig"> <a href = "ListProduct.aspx?category=<%=listCategoryShowIndex[3].Id %>" class = "abig"><%=listCategoryShowIndex[3].Type %> ></a> <ul> <li><a href = "Sanpham.aspx?code=<%=listCategory4[0].Code %>"><%=listCategory4[0].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory4[1].Code %>"><%=listCategory4[1].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory4[2].Code %>"><%=listCategory4[2].Name %> </a></li> </ul> </li> </ul> </div> <% var posterAdsBus = new PosterAdsBus(); var listAds = posterAdsBus.GetListAds();%> <div id = "MiddleContainer"> <div class = "BoxMoving" id = "Bigest"></div> <div class = "BoxMoving Medium" id = "Box6"> <div class = "BoxBottom"> <div class = "BoxName"><%=listAds[0].Title %></div> <div class = "BoxDescript"><%=listAds[0].Description %></div> <a href = "#"><span class = "Vie">Chi tiết >></span><span class = "Eng">Detail >></span></a> </div> </div> <div class = "BoxMoving Medium" id = "Box1"> <div class = "BoxBottom"> <div class = "BoxName"><%=listAds[1].Title %></div> <div class = "BoxDescript"><%=listAds[1].Description %></div> <a href = "#"><span class = "Vie">Chi tiết >></span><span class = "Eng">Detail >></span></a> </div> </div> <div class = "BoxMoving Medium" id = "Box3"> <div class = "BoxBottom"> <div class = "BoxName"><%=listAds[2].Title %></div> <div class = "BoxDescript"><%=listAds[2].Description %></div> <a href = "#"><span class = "Vie">Chi tiết >></span><span class = "Eng">Detail >></span></a> </div> </div> <div class = "BoxMoving Medium" id = "Box4"> <div class = "BoxBottom"> <div class = "BoxName"><%=listAds[3].Title %></div> <div class = "BoxDescript"><%=listAds[3].Description %></div> <a href = "#"><span class = "Vie">Chi tiết >></span><span class = "Eng">Detail >></span></a> </div> </div> <div class = "BoxMoving Medium" id = "Box2"> <div class = "BoxBottom"> <div class = "BoxName"><%=listAds[4].Title %></div> <div class = "BoxDescript"><%=listAds[4].Description %></div> <a href = "#"><span class = "Vie">Chi tiết >></span><span class = "Eng">Detail >></span></a> </div> </div> <div class = "BoxMoving Medium" id = "Box5"> <div class = "BoxBottom"> <div class = "BoxName"><%=listAds[5].Title %></div> <div class = "BoxDescript"><%=listAds[5].Description %></div> <a href = "#"><span class = "Vie">Chi tiết >></span><span class = "Eng">Detail >></span></a> </div> </div> </div> <div id = "Bottom" class = "Center"> <div class = "Center" id = "HibridBot"> <div class = "HibridBot Left">Dép trẻ em</div> <div class = "HibridBot Left">Dép xỏ ngón</div> <div class = "HibridBot Left">Dép xốp</div> <div class = "HibridBot Left">Tấm EVA</div> </div> <ul class = "Center"> <li><img src = "images/icon-jpeg.png" alt = "small logo"/></li> <li><a href = "#"><span class = "Vie">Trang chủ</span><span class = "Eng">Home</span></a></li> <li><a href = "#"><span class = "Vie">Liên hệ</span><span class = "Eng">Contact</span></a></li> <li><a href = "#"><span class = "Vie">Giới thiệu</span><span class = "Eng">Intro</span></a></li> <li><a href = "#"><span class = "Vie">Sản phẩm</span><span class = "Eng">Products</span></a></li> <li><a href = "#"><span class = "Vie">Điều khoản</span><span class = "Eng">Policy</span></a></li> <li><a href = "#"><span class = "Vie">Thanh toán</span><span class = "Eng">Payments</span></a></li> </ul> </div> </form> </body> </html>
10-2012-savi-golden
trunk/golden-footwear/index.aspx
ASP.NET
asf20
7,483
var wdWidth = $(window).width(); var wdHeight = $(window).height(); $(document).ready( function(){ $('#BigLeft').hover( function (){ $('#HiddenMenu').animate({'top': '-55'}, 600); }, function(){ $('#HiddenMenu').mouseleave( function (){ $('#HiddenMenu').animate({'top': '-375'}, 300); }); }); $('#ImgList img').click( function(){ var src = $(this).attr('src'); $('#PreviewBig').find('img').attr('src', src ); }); $('#Zoom').css({ 'top': $('#poss').offset().top, 'left': $('#poss').offset().left }); var deTop = $('#PreviewBig').find('img').offset().top + 25; var deLeft = $('#PreviewBig').find('img').offset().left + 25; var oZoom = $('#Zoom').hide(); $('#PreviewBig').find('img').mouseenter( function(){ var src = $(this).attr('src'); var tmpName = src.split('/')[1]; src = src.replace(tmpName, 'b_' + tmpName); oZoom.css({'background-image': 'url(' + src + ')'}).show(); $('#PdMain').find('.Right').hide(); }).mousemove( function(e){ var x = e.pageX - deLeft; var y = e.pageY - deTop; $('title').text(e.pageX+ '-'+ deLeft); oZoom.css({ 'background-position': x + 'px ' + y + 'px' }); }).mouseout( function(){ oZoom.fadeOut('normal'); $('#PdMain').find('.Right').show(); }); });
10-2012-savi-golden
trunk/golden-footwear/js/mainPD.js
JavaScript
asf20
1,282
var wdWidth = $(window).width(); var wdHeight = $(window).height(); var Center = { X: Math.floor(wdWidth/2), Y: Math.floor(wdHeight/2) } var Unit = { X: Math.floor(wdWidth/100), Y: Math.floor(wdHeight/100) } // set layout function initialSize(){ if (wdWidth <= 1100 && wdWidth >= 1000){ $('#Bigest').css({ 'width': 350, 'height': 220 }); $('.Medium').css({ 'width': 260, 'height': 170 }); } else if (wdWidth <= 1400 && wdWidth > 1100) { $('#Bigest').css({ 'width': 380, 'height': 240 }); $('.Medium').css({ 'width': 280, 'height': 190 }); } else if (wdWidth > 1400) { $('#Bigest').css({ 'width': 450, 'height': 290 }); $('.Medium').css({ 'width': 290, 'height': 190 }); } } function initialPos(){ $('#Bigest').css({ 'top': Center.Y - 110 + 60, 'left': Center.X - 175 }); if (wdWidth <= 1100 && wdWidth >= 1000){ $('#Box1').css({ 'top': 190, 'left': -20 }); $('#Box2').css({ 'top': 300, 'left': 80 }); $('#Box3').css({ 'top': 180, 'left': 900 }); $('#Box4').css({ 'top': 250, 'left': 800 }); $('#Box5').css({ 'top': 350, 'left': 850 }); $('#Box6').css({ 'top': 350, 'left': -120 }); } else if (wdWidth <= 1550 && wdWidth > 1100) { $('#Box1').css({ 'top': 190, 'left': 20 }); $('#Box2').css({ 'top': 300, 'left': 120 }); $('#Box3').css({ 'top': 180, 'left': 1000 }); $('#Box4').css({ 'top': 270, 'left': 1100 }); $('#Box5').css({ 'top': 380, 'left': 1050 }); $('#Box6').css({ 'top': 450, 'left': 100 }); } else if (wdWidth > 1550) { $('#Box1').css({ 'top': 190, 'left': 50 }); $('#Box2').css({ 'top': 450, 'left': 120 }); $('#Box3').css({ 'top': 180, 'left': 1090 }); $('#Box4').css({ 'top': 550, 'left': 1150 }); $('#Box5').css({ 'top': 350, 'left': 1200 }); $('#Box6').css({ 'top': 350, 'left': 270 }); } } $(document).ready( function(){ initialSize(); initialPos(); $('#MiddleContainer').css('height', wdHeight - 405); $('.BoxMoving').hover( function(){ }); var tmpMouseX = 0; var tmpMouseY = 0; var isFirst = true; // $('body').mousemove( function(e){ // var isRow = Math.abs(tmpMouseX - e.pageX) > Math.abs(tmpMouseY - e.pageY); // var isDir = (tmpMouseX - e.pageX) > 0; // $('title').text(wdWidth); // if(isFirst){ // isFirst = false; // } else{ // $('.BoxMoving').each( function(){ // var tmp = $(this).offset().left; // $(this).css('left', tmp + (tmpMouseX - e.pageX)/4); // }); // } // tmpMouseX = e.pageX; // tmpMouseY = e.pageY; // }); $('#BigLeft').hover( function (){ $('#HiddenMenu').animate({'top': '-125'}, 600); }, function(){ $('#HiddenMenu').mouseleave( function (){ $('#HiddenMenu').animate({'top': '-375'}, 300); }); }); $('.BoxMoving').hover( function(){ $(this).find('.BoxBottom').animate({'height' : '80px'}, 600); $(this).find('.BoxDescript').show(); $(this).find('a').show(); }, function(){ $(this).find('.BoxDescript').hide(); $(this).find('a').hide(); $(this).find('.BoxBottom').animate({'height' : '30px'}, 600); }); var B1 = { x: 0, y: 0 } var B2 = { x: 0, y: 0 } $('.BoxMoving').hover(function(){ $(this).css('z-index', '5'); var cX = $(this).offset().left; var cY = $(this).offset().top; B1.x = $('#Box2').offset().left; B1.y = $('#Box2').offset().top; B2.x = $('#Box6').offset().left; B2.y = $('#Box6').offset().top; if($(this).attr('id') == 'Box1'){ $('#Box2').animate({ 'top': cY + 280, 'left': cX + 70 }, 500); $('#Box6').animate({ 'top': cY + 80, 'left': cX + 500 }, 500); } }, function(){ $(this).css('z-index', '3'); if($(this).attr('id') == 'Box1'){ $('#Box2').animate({ 'top': B1.y, 'left': B1.x }, 500); $('#Box6').animate({ 'top': B2.y, 'left': B2.x }, 500); } }); // Language $('#CenterHibrid').removeClass('UK').addClass('VN').attr('title', 'Chuyển sang tiếng việt'); $('.Eng').show(); $('.Vie').hide(); $('#CenterHibrid').click(function () { if ($(this).is('.VN')) { $(this).removeClass('VN').addClass('UK').attr('title', 'Go to english version'); $('.Vie').show(); $('.Eng').hide(); } else { $(this).removeClass('UK').addClass('VN').attr('title', 'Chuyển sang tiếng việt'); $('.Eng').show(); $('.Vie').hide(); } }); });
10-2012-savi-golden
trunk/golden-footwear/js/main.js
JavaScript
asf20
4,729
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManagePoster.aspx.cs" Inherits="footwear.ManagePoster" %> <%@ Import Namespace="footwear" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <form id="form1" runat="server"> <div> <% if (Session["Check"] == null) { Session["Check"] = "FAIL"; } if (Session["Check"].ToString() == "OK") {%> <%if (DbConnect.Connection == null) { var dbConnect = new DbConnect(); } var posterAdsBus = new PosterAdsBus(); var list = posterAdsBus.GetListAds(); %> <table border="1"> <tr> <td> <b>Tiêu đề</b> </td> <td> <b>Mô tả</b> </td> <td> <b>Đường dẫn hình</b> </td> <td> <b>Hoạt động</b> </td> </tr> <% foreach (var posterAds in list) {%> <tr> <td> <%=posterAds.Title %> </td> <td> <%=posterAds.Description %> </td> <td> <%=posterAds.ImageSource %> </td> <td> <a href="ManagePoster.aspx?action=edit&id=<%=posterAds.Id %>">Edit</a> </td> </tr> <%} %> </table> Id: <asp:TextBox ID="txtId" runat="server" Enabled="False"></asp:TextBox><br/> Tiêu đề: <asp:TextBox ID="txtTitle" runat="server"></asp:TextBox><br/> Mô tả: <asp:TextBox ID="txtDescription" runat="server"></asp:TextBox><br/> Đường dẫn hình: <asp:TextBox ID="txtImageLink" runat="server"></asp:TextBox><br/> <asp:Button ID="Button1" runat="server" Text="OK" onclick="Button1_Click" /> <%} else {%> Bạn chưa đăng nhập vào chức năng quản lý. Vui lòng click tại <a href="LoginPage.aspx">đây</a>. <%} %> </div> </form> </body> </html>
10-2012-savi-golden
trunk/golden-footwear/ManagePoster.aspx
ASP.NET
asf20
2,674
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace footwear { public partial class Manage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
10-2012-savi-golden
trunk/golden-footwear/Manage.aspx.cs
C#
asf20
328
using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace footwear { public partial class LoginPage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if (txtPassword.Text == ConfigurationSettings.AppSettings["passwordLogin"] && txtUsername.Text == ConfigurationSettings.AppSettings["usernameLogin"]) { Session["Check"] = "OK"; Response.Redirect("./Manage.aspx"); } else { Session["Check"] = "FAIL"; } } } }
10-2012-savi-golden
trunk/golden-footwear/LoginPage.aspx.cs
C#
asf20
830
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Security; using System.Web.SessionState; namespace golden_footwear { public class Global : System.Web.HttpApplication { void Application_Start(object sender, EventArgs e) { // Code that runs on application startup } void Application_End(object sender, EventArgs e) { // Code that runs on application shutdown } void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs } void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started } void Session_End(object sender, EventArgs e) { // Code that runs when a session ends. // Note: The Session_End event is raised only when the sessionstate mode // is set to InProc in the Web.config file. If session mode is set to StateServer // or SQLServer, the event is not raised. } } }
10-2012-savi-golden
trunk/golden-footwear/Global.asax.cs
C#
asf20
1,198
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace footwear { public partial class index : System.Web.UI.Page { public CategoryBus categoryBus = new CategoryBus(); public ShoeInfoBus shoeInfoBus = new ShoeInfoBus(); public List<Category> listCategoryShowIndex; public List<ShoeInfo> listCategory1; public List<ShoeInfo> listCategory2; public List<ShoeInfo> listCategory3; public List<ShoeInfo> listCategory4; protected void Page_Load(object sender, EventArgs e) { if (DbConnect.Connection == null) { var dbConnect = new DbConnect(); } listCategoryShowIndex = categoryBus.GetListCategoryShowIndex(); listCategory1 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[0].Type); listCategory2 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[1].Type); listCategory3 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[2].Type); listCategory4 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[3].Type); } } }
10-2012-savi-golden
trunk/golden-footwear/index.aspx.cs
C#
asf20
1,325
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ListProduct.aspx.cs" Inherits="footwear.ListProduct" %> <%@ Import Namespace="footwear" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Foot-were</title> <link rel="stylesheet" href="css/Master.css"/> <script type="text/javascript" src = "js/jquery.min.js"></script> <script type="text/javascript" src = "js/main.js"></script> </head> <body style="overflow: auto"> <form id="form1" runat="server"> <div id = "Master"> <div id = "MasterContent"> <div class = "Left MasterDiv"> <input type = "text" class = "SearchBox Left"/> <span class = "Searchbtn Left"></span> </div> <div class = "Right MasterDiv"> <ul id = "TopRightMenu"> <li><a href = "index.aspx">Home</a></li> <li><a href = "#">order status</a></li> <li><a href = "#">your account</a></li> <li><img src = "images/cart.png" width = "20" alt="CART"/></li> <li><a href = "#">your cart (0)</a></li> </ul> </div> <div class = "Center MasterDiv" id = "TopCenter"> <div class = "Left TwoTopbtn"><a href = "ListProduct.aspx?category=all"><div id = "BigLeft"></div></a></div> <div class = "Right TwoTopbtn"><div id = "BigRight"></div></div> </div> </div> </div> <div id = "HibridMenu" class = "Center"></div> <div id = "HiddenMenu"> <ul id = "SpecUl"> <li class = "MidBig"> <a href = "ListProduct.aspx?category=<%=listCategoryShowIndex[0].Id %>" class = "abig"><%=listCategoryShowIndex[0].Type %> ></a> <ul> <li><a href = "Sanpham.aspx?code=<%=listCategory1[0].Code %>"><%=listCategory1[0].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory1[1].Code %>"><%=listCategory1[1].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory1[2].Code %>"><%=listCategory1[2].Name %> </a></li> </ul> </li> <li class = "MidBig"> <a href = "ListProduct.aspx?category=<%=listCategoryShowIndex[1].Id %>" class = "abig"><%=listCategoryShowIndex[1].Type %> ></a> <ul> <li><a href = "Sanpham.aspx?code=<%=listCategory2[0].Code %>"><%=listCategory2[0].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory2[1].Code %>"><%=listCategory2[1].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory2[2].Code %>"><%=listCategory2[2].Name %> </a></li> </ul> </li> <li class = "MidBig"> <a href = "ListProduct.aspx?category=<%=listCategoryShowIndex[2].Id %>" class = "abig"><%=listCategoryShowIndex[2].Type %> ></a> <ul> <li><a href = "Sanpham.aspx?code=<%=listCategory3[0].Code %>"><%=listCategory3[0].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory3[1].Code %>"><%=listCategory3[1].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory3[2].Code %>"><%=listCategory3[2].Name %> </a></li> </ul> </li> <li class = "MidBig"> <a href = "ListProduct.aspx?category=<%=listCategoryShowIndex[3].Id %>" class = "abig"><%=listCategoryShowIndex[3].Type %> ></a> <ul> <li><a href = "Sanpham.aspx?code=<%=listCategory4[0].Code %>"><%=listCategory4[0].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory4[1].Code %>"><%=listCategory4[1].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory4[2].Code %>"><%=listCategory4[2].Name %> </a></li> </ul> </li> </ul> </div> <div id="TableContent"> <div id ="ImgBanner"><img src="images/shoes_banner.jpg" alt="BANNER" width ="700px"/></div> <ul id ="ProductContainer"> <%foreach (var item in list) {%> <li> <a href = "Sanpham.aspx?code=<%=item.Code %>"><img alt="NO IMAGE" width = "200" height = "150" style="alignment-adjust: central" src="<%=item.ImageSource %>"/></a> <%=item.Name %> <%=item.Price %> </li> <%}%> </ul> </div> <div id = "Bottom" class = "Center" style = "clear: both;"> <div class = "Center" id = "HibridBot"> <div class = "HibridBot Left">Music</div> <div class = "HibridBot Left">Vật liệu</div> <div class = "HibridBot Left">Dép pro</div> <div class = "HibridBot Left">Dép cho voi</div> </div> <ul class = "Center"> <li><img src = "images/icon-jpegs.png" alt = "small logo" style = "margin-top: -1px"/></li> <li><a href = "#">Liên hệ</a></li> <li><a href = "#">Giới thiệu</a></li> <li><a href = "#">Sản phẩm</a></li> <li><a href = "#">Đặt hàng</a></li> <li><a href = "#">Điều khoản</a></li> <li><a href = "#">Thanh toán</a></li> </ul> </div> </form> </body> </html>
10-2012-savi-golden
trunk/golden-footwear/ListProduct.aspx
ASP.NET
asf20
5,189
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace golden_footwear { public partial class About : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
10-2012-savi-golden
trunk/golden-footwear/About.aspx.cs
C#
asf20
336
html{ } body{ margin: 0px; padding: 0px; min-width: 800px; font-family: "helvetica neue", "arial", sans-serif; min-height: 768px; min-width: 1024px; overflow: hidden; background-image: url(../images/paper.jpg); } ul{ list-style: none; padding-left: 0px; } a{ text-decoration: none; } #Bigest{ background-image: url(../images/1.jpg); } #Box1{ background-image: url(../images/eva1.jpg); } #Box2{ background-image: url(../images/2.jpg); } #Box3{ background-image: url(../images/dep.jpg); } #Box4{ background-image: url(../images/4.jpg); } #Box5{ background-image: url(../images/5.jpg); } #Box6{ background-image: url(../images/6.jpg); } #Master{ height: 12S0px; padding: 0px; background-image: url(../images/bg.png); background-position: bottom; position: relative; z-index: 5; } #MasterContent{ width: 80%; height:90px; padding: 10px; margin: 0px auto; } .Left{ float: left; } .Center{ margin: 0px auto; } .Right{ float: right; } .MasterDiv{ height: 110px; } .SearchBox{ width: 200px; height: 16px; padding: 5px; border: dashed 2px #c8c8c8; margin-top: 10px; background-color: transparent; } .Searchbtn{ display: inline-block; background-image: url(../images/Find.png); background-repeat: no-repeat; background-position: 9px -25px; width: 40px; height: 30px; margin-top: 10px; margin-left: -40px; cursor: pointer; } .Searchbtn:hover{ background-position: 9px 5px; } .Searchbtn:active{ background-position: 9px -25px; } #TopCenter{ margin-top: -5px; height: 100px; width: 219px; background: url(../images/logo.png) 0px 5px no-repeat transparent; } #HiddenMenu{ margin: 0px auto; width: 900px; height: 170px; position: relative; top: -275px; background-image: url(../images/bg.png); background-position: bottom; z-index: 3; } #SpecUl{ position: relative; top: 20px; margin-left: 20px } #HiddenMenu ul{ margin-top: 10px; } #HiddenMenu a:not(.abig){ color: #c8c8c8; font-size: 10pt; font-weight: bold; margin-left: 20px; } .abig, .BoxName { padding: 5px; color: #c8c8c8; font-weight: bold; } #HiddenMenu a:hover{ color: white; } .MidBig{ width: 200px; margin: 10px; float:left; } #TopRightMenu li{ float: left; margin-left: 8px; font-size: 9pt; } #TopRightMenu a{ color: #c8c8c8; font-weight: bold; } .TwoTopbtn{ background-color: transparent; background-image: url(../images/bg_btn.png); background-position: center; background-repeat: no-repeat; height: 72px; font-size: 15pt; width: 100px; margin-top: 25px; } .TwoTopbtn:hover{ } .TwoTopbtn div{ width: 100px; height: 24px; background-position: top center; background-repeat: no-repeat; margin-top: 20px; cursor: pointer; } .TwoTopbtn div:hover{ background-position: bottom center; } #BigLeft{ background-image: url(../images/Shop.png); } #BigRight{ background-image: url(../images/abt.png); } .imgRight{ background-position: top right; } .imgRight:hover{ background-position: bottom right; } .imgLeft{ background-position: top left; } .imgLeft:hover{ background-position: bottom left; } #Fashihon{ background-image: url(../images/fashion.png); } #Profession{ background-image: url(../images/pro.png); } #Morden{ background-image: url(../images/Mor.png); } #Eff{ background-image: url(../images/eff.png); } .NewMenu{ display: block; width: 250px; height: 28px; background-repeat: no-repeat; cursor: pointer; } #HibridMenu{ Width: 600px; height: 63px; margin-top: 17px; } #HibridMenu div:not(#CenterHibrid){ height: 60px; } #HibridMenu ul{ margin-top: -10px; } #HibridMenu li{ margin: 5px; } #CenterHibrid{ height: 56px; width: 56px; border-radius: 60px; border: solid 2px white; box-shadow: 0px 0px 2px 2px #333; margin-top: 5px; } .VN { background: url(../images/vn.jpg) top center no-repeat black; } .UK { background: url(../images/uk.jpg) top center no-repeat black; } #MiddleContainer{ background-color: orange; background-image: url(../images/paper.jpg); } #Bottom{ height: 20px; background-color: black; width: 1000px; padding: 5px; background-image: url(../images/bg3.jpg); border-top-left-radius: 10px; border-top-right-radius: 10px; } #Bottom ul{ height: 20px; width: 470px; margin-top: 10px; } #Bottom a{ color: white; font-weight: bold; } #Bottom li{ float: left; margin-left: 10px; font-size: 9pt; } .BoxMoving{ position: absolute; box-shadow: 0px 0px 5px 2px #333; } .BoxMoving a{ color: #c8c8c8; font-size: 10pt; font-weight: bold; padding-left: 5px; display: none; } .BoxBottom{ width: 100%; background-image: url(../images/bg3.jpg); height: 30px; position: absolute; bottom: 0px; } .BoxDescript{ color: #c8c8c8; font-size: 11pt; margin-left: 15px; display: none; } #Bigest{ width: 390px; height: 270px; background-color: black; } .Medium{ width: 270px; height: 180px; background-color: red; border: solid black 2px; } .HibridBot{ width: 210px; text-align: center; padding: 4px; margin: 2px 3px; background-color: white; box-shadow: 0px 0px 2px 0px #333; font-size: 13pt; } #HibridBot{ width: 898px; margin-top: -35px; height: 30px; } #ImgBanner { width: 700px; margin: 0px auto; }
10-2012-savi-golden
trunk/golden-footwear/css/Master.css
CSS
asf20
5,456
.inside{ width: 85%; margin: 0px auto; } #MiddleContainer{ position: relative; top: -180px; } #PdTop a{ font-size: 9pt; color: black; font-weight: 700; } #PdTop{ height: 30px; } #PdMain{ padding: 5px 20px; clear: both; height: 600px; width: 1000px; margin: 5px auto; margin-top: -180px; } #PdBottom{ clear: both; height: 300px; width: 1000px; padding-left: 20px; } #ImgList li{ float: left; margin-left: 25px; } #ImgList img{ width: 120px; height: 70px; } #PreviewBig img{ width: 700px; height: 450px; padding: 25px; } #PdMain .Right{ padding-top: 26px; } .PdName{ font-family: "Times new roman"; font-size: 25pt; border-bottom: solid black 1px; padding-bottom: 10px; } .PdPrice{ font-size: 12pt; font-weight: bold; } .PdPrices{ font-size: 10pt; font-weight: bold; } .PdSize img{ border-radius: 20px; background-color: black; } #PdMain .Right li{ margin-bottom: 10px; } .Text{ position: relative; top: -8px; padding-left: 10px; } .PdCart{ background-color: black; color: #c8c8c8; padding-top: 5px; padding-left: 5px; } #Zoom{ top: 150px; right: 30px; position: absolute; width: 230px; height: 450px; } .Recent, .Recent img{ width: 120px; text-align: center; } .Recent{ margin-left: 10px; } h2.Titi{ font-size: 12pt; background-color: black; color: white; }
10-2012-savi-golden
trunk/golden-footwear/css/pDetail.css
CSS
asf20
1,416
html{ } body{ margin: 0px; padding: 0px; min-width: 800px; font-family: "helvetica neue", "arial", sans-serif; min-height: 768px; min-width: 1024px; overflow: hidden; background-image: url(../images/paper.jpg); } ul{ list-style: none; padding-left: 0px; } a{ text-decoration: none; } #Bigest{ background-image: url(../images/big.jpg); } #Box1{ background-image: url(../images/1.jpg); } #Box2{ background-image: url(../images/2.jpg); } #Box3{ background-image: url(../images/3.jpg); } #Box4{ background-image: url(../images/4.jpg); } #Box5{ background-image: url(../images/5.jpg); } #Box6{ background-image: url(../images/6.jpg); } #Master{ height: 12S0px; padding: 0px; background-image: url(../images/bg.png); background-position: bottom; position: relative; z-index: 5; } #MasterContent{ width: 80%; height:90px; padding: 10px; margin: 0px auto; } .Left{ float: left; } .Center{ margin: 0px auto; } .Right{ float: right; } .MasterDiv{ height: 110px; } .SearchBox{ width: 200px; height: 16px; padding: 5px; border: dashed 2px #c8c8c8; margin-top: 10px; background-color: transparent; } .Searchbtn{ display: inline-block; background-image: url(../images/Find.png); background-repeat: no-repeat; background-position: 9px -25px; width: 40px; height: 30px; margin-top: 10px; margin-left: -40px; cursor: pointer; } .Searchbtn:hover{ background-position: 9px 5px; } .Searchbtn:active{ background-position: 9px -25px; } #TopCenter{ margin-top: -5px; height: 100px; width: 200px; background: url(../images/logo.png) 40px 5px no-repeat transparent; } #HiddenMenu{ margin: 0px auto; width: 900px; height: 170px; position: relative; top: -275px; background-image: url(../images/bg.png); background-position: bottom; z-index: 3; } #SpecUl{ position: relative; top: 20px; margin-left: 20px } #HiddenMenu ul{ margin-top: 10px; } #HiddenMenu a:not(.abig){ color: #c8c8c8; font-size: 10pt; font-weight: bold; margin-left: 20px; } .abig, .BoxName { padding: 5px; color: #c8c8c8; font-weight: bold; } #HiddenMenu a:hover{ color: white; } .MidBig{ width: 200px; margin: 10px; float:left; } #TopRightMenu li{ float: left; margin-left: 8px; font-size: 9pt; } #TopRightMenu a{ color: #c8c8c8; font-weight: bold; } .TwoTopbtn{ background-color: transparent; background-image: url(../images/bg_btn.png); background-position: center; background-repeat: no-repeat; height: 72px; font-size: 15pt; width: 100px; margin-top: 25px; } .TwoTopbtn:hover{ } .TwoTopbtn div{ width: 100px; height: 24px; background-position: top center; background-repeat: no-repeat; margin-top: 20px; cursor: pointer; } .TwoTopbtn div:hover{ background-position: bottom center; } #BigLeft{ background-image: url(../images/Shop.png); } #BigRight{ background-image: url(../images/abt.png); } .imgRight{ background-position: top right; } .imgRight:hover{ background-position: bottom right; } .imgLeft{ background-position: top left; } .imgLeft:hover{ background-position: bottom left; } #Fashihon{ background-image: url(../images/fashion.png); } #Profession{ background-image: url(../images/pro.png); } #Morden{ background-image: url(../images/Mor.png); } #Eff{ background-image: url(../images/eff.png); } .NewMenu{ display: block; width: 250px; height: 28px; background-repeat: no-repeat; cursor: pointer; } #HibridMenu{ Width: 600px; height: 63px; margin-top: 17px; } #HibridMenu div:not(#CenterHibrid){ height: 60px; } #HibridMenu ul{ margin-top: -10px; } #HibridMenu li{ margin: 5px; } #CenterHibrid{ height: 56px; width: 56px; border-radius: 60px; background: url(../images/icon-jpeg.png) top center no-repeat black; border: solid 2px white; box-shadow: 0px 0px 2px 2px #333; margin-top: 5px; } #MiddleContainer{ background-color: orange; background-image: url(../images/paper.jpg); } #Bottom{ height: 20px; background-color: black; width: 1000px; padding: 5px; background-image: url(../images/bg3.jpg); border-top-left-radius: 10px; border-top-right-radius: 10px; } #Bottom ul{ height: 20px; width: 470px; margin-top: 10px; } #Bottom a{ color: white; font-weight: bold; } #Bottom li{ float: left; margin-left: 10px; font-size: 9pt; } .BoxMoving{ position: absolute; box-shadow: 0px 0px 5px 2px #333; } .BoxMoving a{ color: #c8c8c8; font-size: 10pt; font-weight: bold; padding-left: 5px; display: none; } .BoxBottom{ width: 100%; background-image: url(../images/bg3.jpg); height: 30px; position: absolute; bottom: 0px; } .BoxDescript{ color: #c8c8c8; font-size: 11pt; margin-left: 15px; display: none; } #Bigest{ width: 390px; height: 270px; background-color: black; } .Medium{ width: 270px; height: 180px; background-color: red; border: solid black 2px; } .HibridBot{ width: 210px; text-align: center; padding: 4px; margin: 2px 3px; background-color: white; box-shadow: 0px 0px 2px 0px #333; font-size: 13pt; } #HibridBot{ width: 898px; margin-top: -35px; height: 30px; } #ImgBanner { width: 700px; margin: 0px auto; }
10-2012-savi-golden
trunk/golden-footwear/css/ListProduct.css
CSS
asf20
5,365
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManageProduct.aspx.cs" Inherits="footwear.ManageProduct" %> <%@ Import Namespace="footwear" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <% if (Session["Check"] == null) { Session["Check"] = "FAIL"; } if (Session["Check"].ToString() == "OK") {%> <%if (DbConnect.Connection == null) { var dbConnect = new DbConnect(); } var shoeInfoBus = new ShoeInfoBus(); var list = shoeInfoBus.GetAllShoeItem(); %> <table border="1"> <tr> <td> <b>Mã</b> </td> <td> <b>Tên</b> </td> <td> <b>Giá</b> </td> <td> <b>Link hình ảnh chính</b> </td> <td> <b>Đặt làm sản phẩm tiêu biểu</b> </td> <td> <b>Loại</b> </td> <td> <b>Kích cỡ</b> </td> <td> <b>Màu sắc</b> </td> <td> <b>Mô tả</b> </td> <td> <b>Hình bên trái</b> </td> <td> <b>Hình bên phải</b> </td> <td> <b>Hình phía trước</b> </td> <td> <b>Hình phía sau</b> </td> <td> <b>Hình ở trên</b> </td> <td> <b>Hoạt động</b> </td> </tr> <% foreach (var shoe in list) { var specShoe = shoeInfoBus.GetSpecificShoe(shoe.Code);%> <tr> <td> <%=specShoe.Code%> </td> <td> <%=specShoe.Name%> </td> <td> <%=specShoe.Price%> </td> <td> <%=specShoe.ImageSource%> </td> <td> <%if (specShoe.ShowIndex == 1) {%> Có <%} else {%> Không <%} %> </td> <td> <%=specShoe.ShoeSubInfo.Type%> </td> <td> <%=specShoe.ShoeSubInfo.Size%> </td> <td> <%=specShoe.ShoeSubInfo.Color%> </td> <td> <%=specShoe.ShoeSubInfo.Description%> </td> <td> <%=specShoe.ShoeSubInfo.LeftImageSource%> </td> <td> <%=specShoe.ShoeSubInfo.RightImageSource%> </td> <td> <%=specShoe.ShoeSubInfo.FrontImageSource%> </td> <td> <%=specShoe.ShoeSubInfo.BackImageSource%> </td> <td> <%=specShoe.ShoeSubInfo.TopImageSource%> </td> <td> <a href="ManageProduct.aspx?action=edit&id=<%=specShoe.Code %>">Chỉnh sửa</a><br/> <a href="ManageProduct.aspx?action=delete&id=<%=specShoe.Code %>">Xóa</a> </td> </tr> <%} %> </table> Mã: <asp:TextBox ID="txtCode" runat="server" ></asp:TextBox><br/> Tên: <asp:TextBox ID="txtName" runat="server"></asp:TextBox><br/> Giá: <asp:TextBox ID="txtPrice" runat="server"></asp:TextBox><br/> Link hình ảnh chính: <asp:TextBox ID="txtMainLink" runat="server"></asp:TextBox><br/> Đặt làm sản phẩm tiêu biểu: <asp:CheckBox ID="chkMenu" runat="server" /><br/> Loại: <asp:DropDownList ID="DropDownType" runat="server"></asp:DropDownList> Kích cỡ: <asp:TextBox ID="txtSize" runat="server"></asp:TextBox><br/> Màu sắc: <asp:TextBox ID="txtColor" runat="server"></asp:TextBox><br/> Mô tả: <asp:TextBox ID="txtDescription" runat="server"></asp:TextBox><br/> Hình bên trái: <asp:TextBox ID="txtLeftLink" runat="server"></asp:TextBox><br/> Hình bên phải: <asp:TextBox ID="txtRightLink" runat="server"></asp:TextBox><br/> Hình ở trước: <asp:TextBox ID="txtFrontLink" runat="server"></asp:TextBox><br/> Hình phía sau: <asp:TextBox ID="txtBackLink" runat="server"></asp:TextBox><br/> Hình phía trên: <asp:TextBox ID="txtTopLink" runat="server"></asp:TextBox><br/> <asp:Button ID="Button1" runat="server" Text="OK" onclick="Button1_Click" /> <%} else {%> Bạn chưa đăng nhập vào chức năng quản lý. Vui lòng click tại <a href="LoginPage.aspx">đây</a>. <%} %> </div> </form> </body> </html>
10-2012-savi-golden
trunk/golden-footwear/ManageProduct.aspx
ASP.NET
asf20
6,305
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("golden_footwear")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("golden_footwear")] [assembly: AssemblyCopyright("Copyright © 2012")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("e982da9a-e462-4627-a558-f0239590ab01")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
10-2012-savi-golden
trunk/golden-footwear/Properties/AssemblyInfo.cs
C#
asf20
1,401
<%@ Page Title="About Us" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="golden_footwear.About" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> About </h2> <p> Put content here. </p> </asp:Content>
10-2012-savi-golden
trunk/golden-footwear/About.aspx
ASP.NET
asf20
448
using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace footwear { public partial class ManageCategory : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (DbConnect.Connection == null) { var dbConnect = new DbConnect(); } if (Request.QueryString["action"] != null && Request.QueryString["action"] != "") { var categoryBus = new CategoryBus(); var item = categoryBus.GetCategoryById(Request.QueryString["id"]); if (!Page.IsPostBack) { txtId.Text = item.Id.ToString(CultureInfo.InvariantCulture); txtType.Text = item.Type; chkMenu.Checked = item.ShowIndex == 1; Button1.Text = "Sửa"; } } else { Button1.Text = "Thêm"; } } protected void Button1_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(txtType.Text)) { var categoryBus = new CategoryBus(); if (String.IsNullOrEmpty(txtId.Text)) { categoryBus.AddCategoryById(txtType.Text, chkMenu.Checked ? "1" : "0"); } else { categoryBus.UpdateCategoryById(txtId.Text, txtType.Text, chkMenu.Checked ? "1" : "0"); } txtId.Text = ""; txtType.Text = ""; chkMenu.Checked = false; Button1.Text = "Thêm"; } } } }
10-2012-savi-golden
trunk/golden-footwear/ManageCategory.aspx.cs
C#
asf20
1,902
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace golden_footwear { public partial class SiteMaster : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { } } }
10-2012-savi-golden
trunk/golden-footwear/Site.Master.cs
C#
asf20
347
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace footwear { public partial class ManagePoster : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (DbConnect.Connection == null) { var dbConnect = new DbConnect(); } if (Request.QueryString["action"] != null && Request.QueryString["action"] != "") { var posterAdsBus = new PosterAdsBus(); var item = posterAdsBus.GetAdsById(Request.QueryString["id"]); if (!Page.IsPostBack) { txtId.Text = item.Id; txtTitle.Text = item.Title; txtDescription.Text = item.Description; txtImageLink.Text = item.ImageSource; } } } protected void Button1_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(txtId.Text)) { var posterAdsBus = new PosterAdsBus(); posterAdsBus.UpdateAdsById(txtId.Text, txtTitle.Text, txtDescription.Text, txtImageLink.Text); txtId.Text = ""; txtTitle.Text = ""; txtDescription.Text = ""; txtImageLink.Text = ""; } } } }
10-2012-savi-golden
trunk/golden-footwear/ManagePoster.aspx.cs
C#
asf20
1,508
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace footwear { public partial class Sanpham : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
10-2012-savi-golden
trunk/golden-footwear/Sanpham.aspx.cs
C#
asf20
329
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Sanpham.aspx.cs" Inherits="footwear.Sanpham" %> <%@ Import Namespace="footwear" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Foot-were</title> <link rel="stylesheet" href="css/Master.css"/> <link rel="stylesheet" href="css/pDetail.css"/> <script type="text/javascript" src = "js/jquery.min.js"></script> <script type="text/javascript" src = "js/mainPD.js"></script> </head> <body style = "overflow: auto;"> <form id="form1" runat="server"> <div id = "Master"> <div id = "MasterContent"> <div class = "Left MasterDiv"> <input type = "text" class = "SearchBox Left"/> <span class = "Searchbtn Left"></span> </div> <div class = "Right MasterDiv"> <ul id = "TopRightMenu"> <li><a href = "index.aspx">Home</a></li> <li><a href = "#">order status</a></li> <li><a href = "#">your account</a></li> <li><img src = "images/cart.png" width = "20" alt="CART"/></li> <li><a href = "#">your cart (0)</a></li> </ul> </div> <div class = "Center MasterDiv" id = "TopCenter"> <div class = "Left TwoTopbtn"><a href = "ListProduct.aspx?category=all"><div id = "BigLeft"></div></a></div> <div class = "Right TwoTopbtn"><div id = "BigRight"></div></div> </div> </div> </div> <div id = "HibridMenu" class = "Center"> <div class = "Left"> <ul class = "Right"> <li id = "Fashihon" class = "NewMenu imgRight"></li> <li id = "Profession" class = "NewMenu imgRight"></li> </ul> </div> <div class = "Right"> <ul class = "Left"> <li id = "Morden" class = "NewMenu imgLeft"></li> <li id = "Eff" class = "NewMenu imgLeft"></li> </ul> </div> <div class = "Center" id = "CenterHibrid"></div> </div> <%if (DbConnect.Connection == null) { var dbConnect = new DbConnect(); } var categoryBus = new CategoryBus(); var shoeInfoBus = new ShoeInfoBus(); var listCategoryShowIndex = categoryBus.GetListCategoryShowIndex(); var listCategory1 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[0].Type); var listCategory2 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[1].Type); var listCategory3 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[2].Type); var listCategory4 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[3].Type); %> <div id = "HiddenMenu"> <ul id = "SpecUl"> <li class = "MidBig"> <a href = "ListProduct.aspx?category=<%=listCategoryShowIndex[0].Id %>" class = "abig"><%=listCategoryShowIndex[0].Type %> ></a> <ul> <li><a href = "Sanpham.aspx?code=<%=listCategory1[0].Code %>"><%=listCategory1[0].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory1[1].Code %>"><%=listCategory1[1].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory1[2].Code %>"><%=listCategory1[2].Name %> </a></li> </ul> </li> <li class = "MidBig"> <a href = "ListProduct.aspx?category=<%=listCategoryShowIndex[1].Id %>" class = "abig"><%=listCategoryShowIndex[1].Type %> ></a> <ul> <li><a href = "Sanpham.aspx?code=<%=listCategory2[0].Code %>"><%=listCategory2[0].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory2[1].Code %>"><%=listCategory2[1].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory2[2].Code %>"><%=listCategory2[2].Name %> </a></li> </ul> </li> <li class = "MidBig"> <a href = "ListProduct.aspx?category=<%=listCategoryShowIndex[2].Id %>" class = "abig"><%=listCategoryShowIndex[2].Type %> ></a> <ul> <li><a href = "Sanpham.aspx?code=<%=listCategory3[0].Code %>"><%=listCategory3[0].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory3[1].Code %>"><%=listCategory3[1].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory3[2].Code %>"><%=listCategory3[2].Name %> </a></li> </ul> </li> <li class = "MidBig"> <a href = "ListProduct.aspx?category=<%=listCategoryShowIndex[3].Id %>" class = "abig"><%=listCategoryShowIndex[3].Type %> ></a> <ul> <li><a href = "Sanpham.aspx?code=<%=listCategory4[0].Code %>"><%=listCategory4[0].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory4[1].Code %>"><%=listCategory4[1].Name %> </a></li> <li><a href = "Sanpham.aspx?code=<%=listCategory4[2].Code %>"><%=listCategory4[2].Name %> </a></li> </ul> </li> </ul> </div> <% var item = shoeInfoBus.GetSpecificShoe(Request.QueryString["code"]); %> <div id = "MiddleContainer"> <div class = "inside"> <div id = "PdTop"> <span class = "Left"><a href = "javascript: history.go(-1)">< Back To List</a></span> </div> <div id = "PdMain"> <ul class = "Left"> <li id = "PreviewBig"><img alt="MAIN IMG" src = "<%=item.ImageSource %>"/></li> <li> <ul id = "ImgList"> <li><img alt="SUB IMG" src = "<%=item.ShoeSubInfo.FrontImageSource %>"/></li> <li><img alt="SUB IMG" src = "<%=item.ShoeSubInfo.BackImageSource %>"/></li> <li><img alt="SUB IMG" src = "<%=item.ShoeSubInfo.LeftImageSource %>"/></li> <li><img alt="SUB IMG" src = "<%=item.ShoeSubInfo.BackImageSource %>"/></li> <li><img alt="SUB IMG" src = "<%=item.ShoeSubInfo.TopImageSource %>"/></li> </ul> </li> </ul> <ul class = "Right"> <li class = "PdName" id = "poss"><%=item.Name %></li> <li class = "PdPrice"><%=item.Price %></li> <li class = "PdPrices"><%=item.ShoeSubInfo.Color %></li> <li class = "PdPrices">Code: <%=item.Code %></li> <li class = "PdSize PdPrices"><img src = "images/icon-jpeg.png" width = "30" alt = "small logo"/><span class = "Text">Size: <%=item.ShoeSubInfo.Size %></span></li> <li class = "PdPrices">Quantity:</li> <li class = "PdQuantity"><input type = "text" name = "Quantity"/></li> <li class = "PdCart"><img src = "images/cart.png" width = "30"/><span class = "Text">add to cart</span></li> </ul> </div> <div id = "PdBottom" class = "Center"> <div class = "Left"> <h1>Dép xuất khẩu</h1> <p><img src = "images/icon-jpeg.png"/><%=item.ShoeSubInfo.Description %></p> <strong>Còn chờ gì nữa?</strong> <h3>Mua nhanh nào</h3> </div> <%--<div class = "Right"> <div class = "Left Recent"> <h2 class = "Titi">Recent</h2> <img src = "images/car-shoe-grey-trainers-01.jpg"/> </div> <div class = "Right Recent"> <h2 class = "Titi">Also like</h2> <img src = "images/dep3.jpg"/> </div> </div>--%> </div> </div> </div> <div id = "Bottom" class = "Center"> <div class = "Center" id = "HibridBot"> <div class = "HibridBot Left">Dép trẻ em</div> <div class = "HibridBot Left">Dép xỏ ngón</div> <div class = "HibridBot Left">Dép xốp</div> <div class = "HibridBot Left">Tấm EVA</div> </div> <ul class = "Center"> <li><img src = "images/icon-jpeg.png" alt = "small logo"/></li> <li><a href = "#">Liên hệ</a></li> <li><a href = "#">Giới thiệu</a></li> <li><a href = "#">Sản phẩm</a></li> <li><a href = "#">Đặt hàng</a></li> <li><a href = "#">Điều khoản</a></li> <li><a href = "#">Thanh toán</a></li> </ul> </div> </form> </body> </html>
10-2012-savi-golden
trunk/golden-footwear/Sanpham.aspx
ASP.NET
asf20
7,800
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManageCategory.aspx.cs" Inherits="footwear.ManageCategory" %> <%@ Import Namespace="footwear" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <form id="form1" runat="server"> <div> <% if (Session["Check"] == null) { Session["Check"] = "FAIL"; } if (Session["Check"].ToString() == "OK") {%> <%if (DbConnect.Connection == null) { var dbConnect = new DbConnect(); } var categoryBus = new CategoryBus(); var list = categoryBus.GetListCategory(); %> <table border="1"> <tr> <td> <b>Tên</b> </td> <td> <b>Đặt trên menu chính</b> </td> <td> <b>Hoạt động</b> </td> </tr> <% foreach (var category in list) {%> <tr> <td> <%=category.Type %> </td> <td> <%if (category.ShowIndex == 1) {%> Có <%} else {%> Không <%} %> </td> <td> <a href="ManageCategory.aspx?action=edit&id=<%=category.Id %>">Edit</a> </td> </tr> <%} %> </table> Id: <asp:TextBox ID="txtId" runat="server" Enabled="False"></asp:TextBox><br/> Tên: <asp:TextBox ID="txtType" runat="server"></asp:TextBox><br/> Đặt trên menu chính: <asp:CheckBox ID="chkMenu" runat="server" /><br/> <asp:Button ID="Button1" runat="server" Text="OK" onclick="Button1_Click" /> <%} else {%> Bạn chưa đăng nhập vào chức năng quản lý. Vui lòng click tại <a href="LoginPage.aspx">đây</a>. <%} %> </div> </form> </body> </html>
10-2012-savi-golden
trunk/golden-footwear/ManageCategory.aspx
ASP.NET
asf20
2,627
using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace footwear { public partial class ManageProduct : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (DbConnect.Connection == null) { var dbConnect = new DbConnect(); } var categoryBus = new CategoryBus(); var list = categoryBus.GetListCategory(); if (Request.QueryString["action"] != null && Request.QueryString["action"] != "") { var shoeInfoBus = new ShoeInfoBus(); var item = shoeInfoBus.GetSpecificShoe(Request.QueryString["id"]); if (!Page.IsPostBack) { txtCode.Text = item.Code; txtName.Text = item.Name; txtMainLink.Text = item.ImageSource; txtPrice.Text = item.Price; chkMenu.Checked = item.ShowIndex == 1; txtBackLink.Text = item.ShoeSubInfo.BackImageSource; txtColor.Text = item.ShoeSubInfo.Color; txtDescription.Text = item.ShoeSubInfo.Description; txtFrontLink.Text = item.ShoeSubInfo.FrontImageSource; txtLeftLink.Text = item.ShoeSubInfo.LeftImageSource; txtRightLink.Text = item.ShoeSubInfo.RightImageSource; txtSize.Text = item.ShoeSubInfo.Size; txtTopLink.Text = item.ShoeSubInfo.TopImageSource; DropDownType.Items.Clear(); foreach (var category in list) { DropDownType.Items.Add(category.Type); } DropDownType.Text = item.ShoeSubInfo.Type; Button1.Text = "Sửa"; txtCode.Enabled = false; } } else { if (Request.QueryString["action"] == "delete") { var shoeInfoBus = new ShoeInfoBus(); shoeInfoBus.DeleteProductByCode(Request.QueryString["id"]); } Button1.Text = "Thêm"; } } protected void Button1_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(txtName.Text)) { var shoeInfoBus = new ShoeInfoBus(); var typeId = DropDownType.SelectedIndex + 1; var showMenu = ""; if (chkMenu.Checked) { showMenu = "1"; } else { showMenu = "0"; } if (txtCode.Enabled) { shoeInfoBus.AddProduct(txtCode.Text, txtName.Text, txtPrice.Text, txtMainLink.Text, showMenu, typeId.ToString(), txtSize.Text, txtColor.Text, txtDescription.Text, txtLeftLink.Text, txtRightLink.Text, txtFrontLink.Text, txtBackLink.Text, txtTopLink.Text); } else { shoeInfoBus.UpdateProductByCode(txtCode.Text, txtName.Text, txtPrice.Text, txtMainLink.Text, showMenu, typeId.ToString(), txtSize.Text, txtColor.Text, txtDescription.Text, txtLeftLink.Text, txtRightLink.Text, txtFrontLink.Text, txtBackLink.Text, txtTopLink.Text); } txtCode.Text = ""; txtName.Text = ""; txtMainLink.Text = ""; txtPrice.Text = ""; txtBackLink.Text = ""; txtColor.Text = ""; txtDescription.Text = ""; txtFrontLink.Text = ""; txtLeftLink.Text = ""; txtRightLink.Text = ""; txtSize.Text = ""; txtTopLink.Text = ""; DropDownType.SelectedIndex = 0; chkMenu.Checked = false; txtCode.Enabled = true; Button1.Text = "Thêm"; } } } }
10-2012-savi-golden
trunk/golden-footwear/ManageProduct.aspx.cs
C#
asf20
4,592
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Text; using System.Text.RegularExpressions; using System.Data; using System.Data.SqlClient; using System.Data.Common; namespace TREC.Data { public class DataCommon { public DataCommon() { } #region 是否存在 && 获取行数 && 最大值/ID /// <summary> /// 判断是否存在 /// </summary> /// <param name="tableName">表名</param> /// <param name="strWhere">where '' 条件</param> /// <returns>如果存在返回数量count(1)</returns> public static int Exists(string tableName,string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(1) from " + tableName + strWhere); return Convert.ToInt32(DbHelper.ExecuteScalar(strSql.ToString())); } /// <summary> /// 判断是否存在 /// </summary> /// <param name="tableName">表名</param> /// <param name="strWhere">where '' 条件</param> /// <returns>如果存在返回数量count(1)</returns> public static int Exists(string tableName, string strWhere, params DbParameter[] commandParameters) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(1) from " + tableName + strWhere); return Convert.ToInt32(DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), commandParameters)); } /// <summary> /// 获取记录总数 /// </summary> /// <param name="where">where '' 条件</param> /// <returns></returns> public static int GetRecordCout(string tableName,string where) { return Exists(tableName, where); } /// <summary> /// 获取最大值 /// </summary> /// <param name="tableName">表名</param> /// <param name="strWhere">条件 where '' </param> /// <param name="field">字段</param> /// <returns>返回结果.ToStirng()</returns> public static string GetMaxValue(string tableName, string strWhere, string field) { StringBuilder strSql = new StringBuilder(); strSql.Append("select max(["); if(field=="") strSql.Append(" id "); else strSql.Append(field); strSql.Append("]) from " + tableName + strWhere); object obj = DbHelper.ExecuteScalar(strSql.ToString()); return obj == null ? "" : obj.ToString(); } /// <summary> /// 获取最大ID(如果空则为1) /// </summary> /// <param name="tableName">表名</param> /// <param name="strWhere">条件 where '' </param> /// <param name="field">字段</param> /// <returns>如果存在返回数量count(1)</returns> public static int GetMaxID(string tableName, string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select max(ID)+1 from " + tableName + strWhere); object obj = DbHelper.ExecuteScalar(strSql.ToString()); return obj == DBNull.Value ? 1 : Convert.ToInt32(obj); } #endregion #region 行操作 (增,删,改) /// <summary> /// 删除行 by strWhere /// </summary> /// <param name="tableName">表名</param> /// <param name="strWhere">Where ='' </param> /// <returns></returns> public static int Delete(string tableName, string strWhere) { string sql = "Delete From " + tableName + strWhere; return DbHelper.ExecuteNonQuery(sql); } /// <summary> /// 插入(返回插入ID或影响行数) /// </summary> /// <param name="dr">数据行</param> /// <param name="key">主键/或自动增加字段(不进行SQL拼接)</param> /// <param name="returnKeyValue">返回插入ID</param> /// <returns></returns> public static int SaveInsert(DataRow dr,string key,bool returnID) { int id = 0; string sql = ""; string cols = ""; string vals = ""; string colName = ""; key = key.Trim(); foreach (DataColumn col in dr.Table.Columns) { colName = col.ColumnName; if (colName == key.Trim() && returnID) { continue; } if (dr[colName] != DBNull.Value) { cols += "[" + colName + "],"; vals += "'" + dr[colName] + "',"; } } if ((cols.Length > 0) && (vals.Length > 0) && (dr.Table.TableName.Length > 0)) { cols = cols.Substring(0, cols.Length - 1); vals = vals.Substring(0, vals.Length - 1); sql = "Insert Into " + dr.Table.TableName + " (" + cols + ") Values (" + vals + ")"; if (returnID) { sql += ";select @@identity "; id = Convert.ToInt32(DbHelper.ExecuteScalar(sql)); } else { id=Convert.ToInt32(DbHelper.ExecuteNonQuery(sql)); } } return id; } /// <summary> /// 修改操作 /// </summary> /// <param name="dr">行数据</param> /// <param name="key">主键/或自动增加字段 (可能用于修改条件)</param> /// <param name="strWhere">Where='' 修改条件 为空时key=dr[key] 条件要加 and </param> /// <param name="returnID">=="key" 时返回dr[key]值</param> /// <returns>返回dr[key]值或影响行数</returns> public static int SaveUpdate(DataRow dr, string key,string strWhere,string returnID) { int result = 0; string vals = ""; string colName = ""; string tableName = dr.Table.TableName; //string where = ""; foreach (DataColumn col in dr.Table.Columns) { colName = col.ColumnName; if (dr[colName] != DBNull.Value) { if (colName.ToLower() == key.Trim().ToLower()) { continue; } vals += "[" + colName + "]= '" + dr[colName] + "',"; } } if ((vals.Length > 0) && (tableName.Length > 0)) { vals = vals.Substring(0, vals.Length - 1); if (strWhere == "") strWhere = key + "='" + dr[key].ToString() + "'"; string sql = "Update " + tableName + " Set " + vals + strWhere;//And "+ key +" = '" + dr[key].ToString() + "'"; ///返回影响行数 result=DbHelper.ExecuteNonQuery(sql); } if (returnID.ToLower() == "key") { /// result=Convert.ToInt32(dr[key]); } return result; } /// <summary> /// 修改自定义字段数据 /// </summary> /// <param name="tableName">表名</param> /// <param name="fields">字段 ","</param> /// <param name="values">值 ","</param> /// <param name="strWhere">条件 where ''</param> /// <returns>影响行数</returns> public static int UpdateValue(string tableName,string fields, string values, string strWhere) { if (string.IsNullOrEmpty(fields) || values==null) { return 0; } else { string[] attField = Regex.Split(fields.EndsWith(",") ? fields.Substring(0, fields.Length - 1) : fields, Regex.Escape(","), RegexOptions.IgnoreCase); string[] attValue = Regex.Split(values.EndsWith(",") ? values.Substring(0, values.Length - 1) : values, Regex.Escape(","), RegexOptions.IgnoreCase); if (attField.Length < 0 || attValue.Length < 0 || attField.Length != attValue.Length) return 0; StringBuilder sb=new StringBuilder(); sb.Append(" update "+tableName); sb.Append(" set "); if (attField.Length == 1) { sb.Append(fields + "='" + attValue[0] + "'"); } else { for (int i = 0; i < attField.Length; i++) { sb.Append(attField[i] + "='" + values + "'"); } } sb.Append(strWhere); return DbHelper.ExecuteNonQuery(sb.ToString()); } } #endregion #region 数据查询 /// <summary> /// 获取DataRow 第一行数据 /// </summary> /// <param name="tableName">表</param> /// <param name="field">字段</param> /// <param name="strWhere">条件 where ''</param> /// <param name="sort">排序</param> /// <returns></returns> public static DataRow GetDataRow(string tableName, string field, string strWhere, string sort) { StringBuilder strSql = new StringBuilder(); strSql.Append("select "); if (field != "") strSql.Append(field); else strSql.Append(" * "); strSql.Append(" from " + tableName + strWhere + sort); DataTable dt = DbHelper.ExecuteDataset(strSql.ToString()).Tables[0]; if (dt.Rows.Count > 0) { dt.Rows[0].Table.TableName = tableName; return dt.Rows[0]; } else { DataRow dr = dt.NewRow(); dr.Table.TableName = tableName; return dr; } } /// <summary> /// 获取DataSet /// </summary> /// <param name="tableName">表</param> /// <param name="field">字段</param> /// <param name="strWhere">条件 where ''</param> /// <param name="sort">排序</param> /// <returns></returns> public static DataSet GetDataSet(string tableName, string field, string strWhere, string sort) { StringBuilder strSql = new StringBuilder(); strSql.Append("select "); strSql.Append(field == "" ? " * " : field); strSql.Append(" from " + tableName + strWhere + sort); return DbHelper.ExecuteDataset(strSql.ToString()); } /// <summary> /// 获取DataTable /// </summary> /// <param name="tableName">表</param> /// <param name="field">字段</param> /// <param name="strWhere">条件 where ''</param> /// <param name="sort">排序</param> /// <returns></returns> public static DataTable GetDataTable(string tableName, string field, string strWhere, string sort) { StringBuilder strSql = new StringBuilder(); strSql.Append("select "); strSql.Append(field == "" ? " * " : field); strSql.Append(" from " + tableName + strWhere + sort); return DbHelper.ExecuteDataset(strSql.ToString()).Tables[0]; } /// <summary> /// 获取分页数据 /// </summary> /// <param name="tableName">表名</param> /// <param name="PageIndex">页码</param> /// <param name="PageSize">页大小</param> /// <param name="strWhere">条件</param> /// <param name="key">主键</param> /// <param name="orderType">排序</param> /// <param name="pageCount">总数</param> /// <returns></returns> public static DataTable GetPageDataTable(string tableName, int PageIndex, int PageSize, string strWhere, string key, int orderType, out int pageCount) { if (string.IsNullOrEmpty(key)) { key = "id"; } if (string.IsNullOrEmpty(strWhere)) { strWhere = "1=1"; } if (PageIndex == -1) { if (!string.IsNullOrEmpty(strWhere)) strWhere = " where " + strWhere; string strOrderBy = ""; if (orderType == 1) { strOrderBy = " order by " + key + " desc"; } else { strOrderBy = " order by " + key + " asc"; } DataSet ds = new DataSet(); if (PageSize > 0) { ds = DbHelper.ExecuteDataset("select top " + PageSize + " * from " + tableName + strWhere + strOrderBy); } else { ds = DbHelper.ExecuteDataset("select * from " + tableName + strWhere + strOrderBy); } if (ds.Tables.Count > 0) { object obj=DbHelper.ExecuteScalar("select count(1) from " + tableName + strWhere); pageCount = obj != null ? int.Parse(obj.ToString()) : 0; return ds.Tables[0]; } } else { SqlParameter[] parameters = { new SqlParameter("@tblName", SqlDbType.VarChar, 255), new SqlParameter("@fldName", SqlDbType.VarChar, 255), new SqlParameter("@PageSize", SqlDbType.Int), new SqlParameter("@PageIndex", SqlDbType.Int), new SqlParameter("@IsReCount", SqlDbType.Bit), new SqlParameter("@OrderType", SqlDbType.Bit), new SqlParameter("@strWhere", SqlDbType.VarChar,1000), new SqlParameter("@ReCount",SqlDbType.Int,4) }; parameters[0].Value = tableName; parameters[1].Value = key; parameters[2].Value = PageSize; parameters[3].Value = PageIndex; parameters[4].Value = 1; parameters[5].Value = orderType; parameters[6].Value = strWhere; parameters[7].Direction = ParameterDirection.Output; parameters[7].Value = 0; DataSet ds = DbHelper.ExecuteDataset(CommandType.StoredProcedure, "UP_GetRecordByPage", parameters); pageCount = Convert.ToInt32(parameters[7].Value); if (ds.Tables.Count > 0) { return ds.Tables[0]; } } DataTable dt = DbHelper.ExecuteDataset("select * from " + tableName + " where 1<>1").Tables[0]; dt.TableName = tableName; pageCount = 0; return dt; } /// <summary> /// 获取DataReader /// </summary> /// <param name="tableName">表</param> /// <param name="field">字段</param> /// <param name="strWhere">条件 where ''</param> /// <param name="sort">排序</param> /// <returns></returns> public static IDataReader GetDataIReader(string tableName, string field, string strWhere, string sort) { StringBuilder strSql = new StringBuilder(); strSql.Append("select "); if (field == "") strSql.Append(" * "); else strSql.Append(field); strSql.Append(" from " + tableName + strWhere + sort); IDataReader dr = DbHelper.ExecuteReader(strSql.ToString()); return dr; } // public static IDataReader GetPageDataReader(string tableName, string key,int pageIndex, int pageSize, string strWhere, string filed, string orderby, out int pageCount) // { // //降序 // string str = @" SELECT TOP {0} {2} // FROM {3} // WHERE {6} <= // ( // SELECT ISNULL(MIN({6}),0) // FROM // (SELECT TOP ({0}*({1}-1)+1) {6} FROM {3} {7} order by {6} desc) A ) {5} {4}"; // //顺序 // string str2 = @" SELECT TOP {0} {2} // FROM {3} // WHERE {6} >= // ( // SELECT ISNULL(max({6}),0) // FROM // (SELECT TOP ({0}*({1}-1)+1) {6} FROM {3} {7} order by {6}) A ) {5} {4}"; // key = key != "" ? key : " id "; // filed = filed != "" ? filed : " * "; // orderby = orderby != "" ? orderby : " order by id"; // string ostrWhere = strWhere != "" ? " where 1=1 " + strWhere : ""; // object obj = DbHelper.ExecuteScalar("select count(1) from " + tableName + ostrWhere); // if(obj!=null){pageCount=int.Parse(obj.ToString());}else{pageCount=0;} // if (orderby != "" && (orderby.ToLower().Contains("asc") || (!orderby.ToLower().Contains("asc") && !orderby.ToLower().Contains("desc")))) // { // return DbHelper.ExecuteReader(string.Format(str2.ToString(), pageSize, pageIndex, filed, tableName, orderby, strWhere, key, ostrWhere)); // } // else // { // return DbHelper.ExecuteReader(string.Format(str.ToString(), pageSize, pageIndex, filed, tableName, orderby, strWhere, key, ostrWhere)); // } // } /// <summary> /// 单字段排序分页 /// </summary> /// <param name="tableName">表名</param> /// <param name="sortkey">排序字段</param> /// <param name="pageIndex">页码</param> /// <param name="pagesSize">页大小</param> /// <param name="strWhere">条件</param> /// <param name="field">查询字段</param> /// <param name="orderByType">排序方式 0,顺序,1降顺</param> /// <param name="pageCount">总数</param> /// <returns></returns> public static IDataReader GetPageDataReader(string tableName, int pageIndex, int pagesSize, string strWhere, string field, string sortkey, string orderByType, out int pageCount) { sortkey = sortkey == "" ? "id" : sortkey; field = field == "" ? " * " : field; orderByType = orderByType == "0" || orderByType.Replace(" ", "").Trim() == "asc" ? " asc " : " desc "; string ostrWhere = strWhere == "" ? "" : " where 1=1 " + strWhere; string orderNull = sortkey != "id" ? ",id asc" : ""; string orderNull2 = sortkey != "id" ? ",id desc" : ""; // string strAsc=@"SELECT TOP {2} {4} FROM {0} WHERE {5} >= // (SELECT ISNULL(max({5}),0) FROM (SELECT TOP ({2}*({1}-1)+1) {5} FROM {0} ORDER BY {5} {6} ) A) {3} ORDER BY {5} {6}"; // string strDesc = @"SELECT TOP {2} {4} FROM {0} WHERE {5} <= // (SELECT ISNULL(MIN({5}),0) FROM (SELECT TOP ({2}*({1}-1)+1) {5} FROM {0} ORDER BY {5} Desc {6}) A) {3} ORDER BY {5} Desc {6} "; // pageCount = 0; // object obj = DbHelper.ExecuteScalar("select count(1) from " + tableName + ostrWhere); // if (obj != null) { pageCount = int.Parse(obj.ToString()); } else { pageCount = 0; } // if (orderByType == "0" || orderByType.Contains("asc")) // { // return DbHelper.ExecuteReader(string.Format(strAsc.ToString(), tableName, pageIndex, pagesSize, strWhere, field, sortkey,orderNull)); // } // else // { // return DbHelper.ExecuteReader(string.Format(strDesc.ToString(), tableName, pageIndex, pagesSize, strWhere, field, sortkey, orderNull2)); // } pageCount = 0; object obj = DbHelper.ExecuteScalar("select count(1) from " + tableName + ostrWhere); if (obj != null) { pageCount = int.Parse(obj.ToString()); } else { pageCount = 0; } string strSql = @"select {4} from (select row_number()over(order by {5} {6})rownumber,{4} from {0} {3})a where rownumber between ({2}*({1}-1)+1) and ({2}*{1})"; return DbHelper.ExecuteReader(string.Format(strSql.ToString(), tableName, pageIndex, pagesSize, ostrWhere, field, sortkey, orderByType)); } /// <summary> /// 单字段排序分页2 /// </summary> /// <param name="tableName">表名</param> /// <param name="pageIndex">页码</param> /// <param name="pagesSize">页大小</param> /// <param name="strWhere">条件</param> /// <param name="field">查询字段</param> /// <param name="orderByType">排序方式 0,顺序,1降顺</param> /// <param name="pageCount">总数</param> public static IDataReader GetPageDataReader(string tableName, int pageIndex, int pageSize, string strWhere, string sortkey, string orderByType, out int pageCount) { return GetPageDataReader(tableName, pageIndex, pageSize, strWhere, "",sortkey, orderByType, out pageCount); } #endregion #region 结构 /// <summary> /// 获取某表结构 /// </summary> /// <param name="tableName"></param> /// <returns></returns> public static DataRow GetTableStructure(string tableName) { //IDataReader read = DbHelper.ExecuteReader("select * from " + tableName + " where 1<>1"); DataTable dt = DbHelper.ExecuteDataset("select * from " + tableName + " where 1<>1").Tables[0]; dt.TableName = tableName; return dt.NewRow(); } /// <summary> /// 判断是否存在某表的某个字段 /// </summary> /// <param name="tableName">表名称</param> /// <param name="columnName">列名称</param> /// <returns>是否存在</returns> public static bool ColumnExists(string tableName, string columnName) { string sql = "select count(1) from syscolumns where [id]=object_id('" + tableName + "') and [name]='" + columnName + "'"; object res = DbHelper.ExecuteScalar(sql.ToString()); if (res == null) { return false; } return Convert.ToInt32(res) > 0; } /// <summary> /// 表是否存在 /// </summary> /// <param name="TableName"></param> /// <returns></returns> public static bool TabExists(string TableName) { string strsql = "select count(*) from sysobjects where id = object_id(N'[" + TableName + "]') and OBJECTPROPERTY(id, N'IsUserTable') = 1"; //string strsql = "SELECT count(*) FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + TableName + "]') AND type in (N'U')"; object obj = DbHelper.ExecuteScalar(strsql.ToString()); int cmdresult; if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) { cmdresult = 0; } else { cmdresult = int.Parse(obj.ToString()); } if (cmdresult == 0) { return false; } else { return true; } } #endregion //分类上移 public static int CategoryNodeUp(string procedurename, int id) { SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int) }; parameters[0].Value = id; return DbHelper.ExecuteNonQuery(CommandType.StoredProcedure, procedurename, parameters); } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/DataCommon.cs
C#
oos
25,098
using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Web; using Microsoft.VisualBasic; using System.Collections; using System.Net; namespace TREC.Data { public class Tools { /// <summary> /// 分割字符串 /// </summary> public static string[] SplitString(string strContent, string strSplit) { if (!string.IsNullOrEmpty(strContent)) { if (strContent.IndexOf(strSplit) < 0) return new string[] { strContent }; return Regex.Split(strContent, Regex.Escape(strSplit), RegexOptions.IgnoreCase); } else return new string[0] { }; } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Tools.cs
C#
oos
919
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Areas { #region 共公模块 /// <summary> /// 更新对像 /// </summary> public static int EditArea(EnArea model) { if (model.areacode == "0" || model.areacode=="") { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_area("); strSql.Append("areacode,parentcode,areaname,areazipcode,grouparea)"); strSql.Append(" values ("); strSql.Append("@areacode,@parentcode,@areaname,@areazipcode,@grouparea)"); SqlParameter[] parameters = { new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@parentcode", SqlDbType.VarChar,10), new SqlParameter("@areaname", SqlDbType.NVarChar,25), new SqlParameter("@areazipcode", SqlDbType.VarChar,10), new SqlParameter("@grouparea", SqlDbType.NVarChar,25)}; parameters[0].Value = model.areacode; parameters[1].Value = model.parentcode; parameters[2].Value = model.areaname; parameters[3].Value = model.areazipcode; parameters[4].Value = model.grouparea; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_area set "); strSql.Append("parentcode=@parentcode,"); strSql.Append("areaname=@areaname,"); strSql.Append("areazipcode=@areazipcode,"); strSql.Append("grouparea=@grouparea"); strSql.Append(" where areacode=@areacode"); SqlParameter[] parameters = { new SqlParameter("@parentcode", SqlDbType.VarChar,10), new SqlParameter("@areaname", SqlDbType.NVarChar,25), new SqlParameter("@areazipcode", SqlDbType.VarChar,10), new SqlParameter("@grouparea", SqlDbType.NVarChar,25), new SqlParameter("@areacode", SqlDbType.VarChar,10)}; parameters[0].Value = model.parentcode; parameters[1].Value = model.areaname; parameters[2].Value = model.areazipcode; parameters[3].Value = model.grouparea; parameters[4].Value = model.areacode; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return int.Parse(model.areacode); } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnArea GetAreaInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Area "); strSql.Append(strWhere); EnArea model = new EnArea(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["parentcode"] != null && reader["parentcode"].ToString() != "") { model.parentcode = reader["parentcode"].ToString(); } if (reader["areaname"] != null && reader["areaname"].ToString() != "") { model.areaname = reader["areaname"].ToString(); } if (reader["areazipcode"] != null && reader["areazipcode"].ToString() != "") { model.areazipcode = reader["areazipcode"].ToString(); } if (reader["grouparea"] != null && reader["grouparea"].ToString() != "") { model.grouparea = reader["grouparea"].ToString(); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnArea> GetAreaList(string strWhere) { List<EnArea> modelList = new List<EnArea>(); DataTable dt = DataCommon.GetDataTable(TableName.TBArea, "",strWhere,""); if (dt.Rows.Count > 0) { EnArea model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnArea(); if (dt.Rows[n]["areacode"] != null && dt.Rows[n]["areacode"].ToString() != "") { model.areacode = dt.Rows[n]["areacode"].ToString(); } if (dt.Rows[n]["parentcode"] != null && dt.Rows[n]["parentcode"].ToString() != "") { model.parentcode = dt.Rows[n]["parentcode"].ToString(); } if (dt.Rows[n]["areaname"] != null && dt.Rows[n]["areaname"].ToString() != "") { model.areaname = dt.Rows[n]["areaname"].ToString(); } if (dt.Rows[n]["areazipcode"] != null && dt.Rows[n]["areazipcode"].ToString() != "") { model.areazipcode = dt.Rows[n]["areazipcode"].ToString(); } if (dt.Rows[n]["grouparea"] != null && dt.Rows[n]["grouparea"].ToString() != "") { model.grouparea = dt.Rows[n]["grouparea"].ToString(); } modelList.Add(model); } } return modelList; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Areas.cs
C#
oos
6,770
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class AppPromotions { /// <summary> /// 更新对像 /// </summary> public static int EditPromotionAppBrand(EnPromotionAppBrand model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_promotionappbrand("); strSql.Append("title,letter,bid,blogo,fordio,thumb,banner,htmltitle,descript,appcount,sort)"); strSql.Append(" values ("); strSql.Append("@title,@letter,@bid,@blogo,@fordio,@thumb,@banner,@htmltitle,@descript,@appcount,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,50), new SqlParameter("@letter", SqlDbType.VarChar,50), new SqlParameter("@bid", SqlDbType.Int,4), new SqlParameter("@blogo", SqlDbType.VarChar,50), new SqlParameter("@fordio", SqlDbType.VarChar,10), new SqlParameter("@thumb", SqlDbType.VarChar,50), new SqlParameter("@banner", SqlDbType.VarChar,240), new SqlParameter("@htmltitle", SqlDbType.NVarChar,80), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@appcount", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.letter; parameters[2].Value = model.bid; parameters[3].Value = model.blogo; parameters[4].Value = model.fordio; parameters[5].Value = model.thumb; parameters[6].Value = model.banner; parameters[7].Value = model.htmltitle; parameters[8].Value = model.descript; parameters[9].Value = model.appcount; parameters[10].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_promotionappbrand set "); strSql.Append("title=@title,"); strSql.Append("letter=@letter,"); strSql.Append("bid=@bid,"); strSql.Append("blogo=@blogo,"); strSql.Append("fordio=@fordio,"); strSql.Append("thumb=@thumb,"); strSql.Append("banner=@banner,"); strSql.Append("htmltitle=@htmltitle,"); strSql.Append("descript=@descript,"); strSql.Append("appcount=@appcount,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,50), new SqlParameter("@letter", SqlDbType.VarChar,50), new SqlParameter("@bid", SqlDbType.Int,4), new SqlParameter("@blogo", SqlDbType.VarChar,50), new SqlParameter("@fordio", SqlDbType.VarChar,10), new SqlParameter("@thumb", SqlDbType.VarChar,50), new SqlParameter("@banner", SqlDbType.VarChar,240), new SqlParameter("@htmltitle", SqlDbType.NVarChar,80), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@appcount", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.letter; parameters[2].Value = model.bid; parameters[3].Value = model.blogo; parameters[4].Value = model.fordio; parameters[5].Value = model.thumb; parameters[6].Value = model.banner; parameters[7].Value = model.htmltitle; parameters[8].Value = model.descript; parameters[9].Value = model.appcount; parameters[10].Value = model.sort; parameters[11].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnPromotionAppBrand GetPromotionAppBrandInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_PromotionAppBrand "); strSql.Append(strWhere); EnPromotionAppBrand model = new EnPromotionAppBrand(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["bid"] != null && reader["bid"].ToString() != "") { model.bid = int.Parse(reader["bid"].ToString()); } if (reader["blogo"] != null && reader["blogo"].ToString() != "") { model.blogo = reader["blogo"].ToString(); } if (reader["fordio"] != null && reader["fordio"].ToString() != "") { model.fordio = reader["fordio"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["banner"] != null && reader["banner"].ToString() != "") { model.banner = reader["banner"].ToString(); } if (reader["htmltitle"] != null && reader["htmltitle"].ToString() != "") { model.htmltitle = reader["htmltitle"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["appcount"] != null && reader["appcount"].ToString() != "") { model.appcount = int.Parse(reader["appcount"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnPromotionAppBrand> GetPromotionAppBrandList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnPromotionAppBrand> modelList = new List<EnPromotionAppBrand>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBPromotionAppBrand, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnPromotionAppBrand model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnPromotionAppBrand(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["bid"] != null && dt.Rows[n]["bid"].ToString() != "") { model.bid = int.Parse(dt.Rows[n]["bid"].ToString()); } if (dt.Rows[n]["blogo"] != null && dt.Rows[n]["blogo"].ToString() != "") { model.blogo = dt.Rows[n]["blogo"].ToString(); } if (dt.Rows[n]["fordio"] != null && dt.Rows[n]["fordio"].ToString() != "") { model.fordio = dt.Rows[n]["fordio"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["banner"] != null && dt.Rows[n]["banner"].ToString() != "") { model.banner = dt.Rows[n]["banner"].ToString(); } if (dt.Rows[n]["htmltitle"] != null && dt.Rows[n]["htmltitle"].ToString() != "") { model.htmltitle = dt.Rows[n]["htmltitle"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["appcount"] != null && dt.Rows[n]["appcount"].ToString() != "") { model.appcount = int.Parse(dt.Rows[n]["appcount"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } /// <summary> /// 更新对像 /// </summary> public static int EditAppBrandCustomer(EnAppBrandCustomer model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_appbrandcustomer("); strSql.Append("aid,name,phone,mphone,email,address,descript,cus)"); strSql.Append(" values ("); strSql.Append("@aid,@name,@phone,@mphone,@email,@address,@descript,@cus)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@aid", SqlDbType.Int,4), new SqlParameter("@name", SqlDbType.NVarChar,50), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@mphone", SqlDbType.VarChar,20), new SqlParameter("@email", SqlDbType.VarChar,30), new SqlParameter("@address", SqlDbType.NVarChar,50), new SqlParameter("@descript", SqlDbType.NVarChar,600), new SqlParameter("@cus", SqlDbType.NText)}; parameters[0].Value = model.aid; parameters[1].Value = model.name; parameters[2].Value = model.phone; parameters[3].Value = model.mphone; parameters[4].Value = model.email; parameters[5].Value = model.address; parameters[6].Value = model.descript; parameters[7].Value = model.cus; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_appbrandcustomer set "); strSql.Append("aid=@aid,"); strSql.Append("name=@name,"); strSql.Append("phone=@phone,"); strSql.Append("mphone=@mphone,"); strSql.Append("email=@email,"); strSql.Append("address=@address,"); strSql.Append("descript=@descript,"); strSql.Append("cus=@cus"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@aid", SqlDbType.Int,4), new SqlParameter("@name", SqlDbType.NVarChar,50), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@mphone", SqlDbType.VarChar,20), new SqlParameter("@email", SqlDbType.VarChar,30), new SqlParameter("@address", SqlDbType.NVarChar,50), new SqlParameter("@descript", SqlDbType.NVarChar,600), new SqlParameter("@cus", SqlDbType.NText), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.aid; parameters[1].Value = model.name; parameters[2].Value = model.phone; parameters[3].Value = model.mphone; parameters[4].Value = model.email; parameters[5].Value = model.address; parameters[6].Value = model.descript; parameters[7].Value = model.cus; parameters[8].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnAppBrandCustomer GetAppBrandCustomerInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_AppBrandCustomer "); strSql.Append(strWhere); EnAppBrandCustomer model = new EnAppBrandCustomer(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["aid"] != null && reader["aid"].ToString() != "") { model.aid = int.Parse(reader["aid"].ToString()); } if (reader["name"] != null && reader["name"].ToString() != "") { model.name = reader["name"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["mphone"] != null && reader["mphone"].ToString() != "") { model.mphone = reader["mphone"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["cus"] != null && reader["cus"].ToString() != "") { model.cus = reader["cus"].ToString(); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnAppBrandCustomer> GetAppBrandCustomerList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnAppBrandCustomer> modelList = new List<EnAppBrandCustomer>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBAppBrandCustomer, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnAppBrandCustomer model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnAppBrandCustomer(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["aid"] != null && dt.Rows[n]["aid"].ToString() != "") { model.aid = int.Parse(dt.Rows[n]["aid"].ToString()); } if (dt.Rows[n]["name"] != null && dt.Rows[n]["name"].ToString() != "") { model.name = dt.Rows[n]["name"].ToString(); } if (dt.Rows[n]["phone"] != null && dt.Rows[n]["phone"].ToString() != "") { model.phone = dt.Rows[n]["phone"].ToString(); } if (dt.Rows[n]["mphone"] != null && dt.Rows[n]["mphone"].ToString() != "") { model.mphone = dt.Rows[n]["mphone"].ToString(); } if (dt.Rows[n]["email"] != null && dt.Rows[n]["email"].ToString() != "") { model.email = dt.Rows[n]["email"].ToString(); } if (dt.Rows[n]["address"] != null && dt.Rows[n]["address"].ToString() != "") { model.address = dt.Rows[n]["address"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["cus"] != null && dt.Rows[n]["cus"].ToString() != "") { model.cus = dt.Rows[n]["cus"].ToString(); } modelList.Add(model); } } return modelList; } public static List<EnAppProduct> GetAppBrandProductList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnAppProduct> modelList = new List<EnAppProduct>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBAppBrandProduct, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnAppProduct model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnAppProduct(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["mid"] != null && dt.Rows[n]["mid"].ToString() != "") { model.mid = int.Parse(dt.Rows[n]["mid"].ToString()); } if (dt.Rows[n]["name"] != null && dt.Rows[n]["name"].ToString() != "") { model.name = dt.Rows[n]["name"].ToString(); } if (dt.Rows[n]["memail"] != null && dt.Rows[n]["memail"].ToString() != "") { model.memail = dt.Rows[n]["memail"].ToString(); } if (dt.Rows[n]["mphone"] != null && dt.Rows[n]["mphone"].ToString() != "") { model.mphone = dt.Rows[n]["mphone"].ToString(); } if (dt.Rows[n]["productid"] != null && dt.Rows[n]["productid"].ToString() != "") { model.productid = int.Parse(dt.Rows[n]["productid"].ToString()); } if (dt.Rows[n]["productname"] != null && dt.Rows[n]["productname"].ToString() != "") { model.productname = dt.Rows[n]["productname"].ToString(); } if (dt.Rows[n]["materialid"] != null && dt.Rows[n]["materialid"].ToString() != "") { model.materialid = int.Parse(dt.Rows[n]["materialid"].ToString()); } if (dt.Rows[n]["materialname"] != null && dt.Rows[n]["materialname"].ToString() != "") { model.materialname = dt.Rows[n]["materialname"].ToString(); } if (dt.Rows[n]["sizevalue"] != null && dt.Rows[n]["sizevalue"].ToString() != "") { model.sizevalue = dt.Rows[n]["sizevalue"].ToString(); } if (dt.Rows[n]["brandid"] != null && dt.Rows[n]["brandid"].ToString() != "") { model.brandid = int.Parse(dt.Rows[n]["brandid"].ToString()); } if (dt.Rows[n]["brandname"] != null && dt.Rows[n]["brandname"].ToString() != "") { model.brandname = dt.Rows[n]["brandname"].ToString(); } if (dt.Rows[n]["addtime"] != null && dt.Rows[n]["addtime"].ToString() != "") { model.addtime = DateTime.Parse(dt.Rows[n]["addtime"].ToString()); } modelList.Add(model); } } return modelList; } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/AppPromotions.cs
C#
oos
24,019
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Markets { public static int ExitMarketLetter(string title) { SqlParameter[] parames = { new SqlParameter("@letter", SqlDbType.NVarChar, 30)}; parames[0].Value = title; return DataCommon.Exists(TableName.TBMarket, " where letter=@letter", parames); } public static int ExitMarket(string title) { SqlParameter[] parames = { new SqlParameter("@title", SqlDbType.NVarChar, 30)}; parames[0].Value = title; return DataCommon.Exists(TableName.TBMarket, " where title=@title", parames); } public static EnWebMarket GetWebMarketInfo(string strWhere) { EnWebMarket model = new EnWebMarket(); IDataReader reader = DataCommon.GetDataIReader(TableName.TVMarket, "", strWhere, ""); while (reader.Read()) { if (reader["shopcount"] != null && reader["shopcount"].ToString() != "") { model.shopcount = int.Parse(reader["shopcount"].ToString()); } if (reader["shopxml"] != null && reader["shopxml"].ToString() != "") { model.shopxml = reader["shopxml"].ToString(); } if (reader["brandxml"] != null && reader["brandxml"].ToString() != "") { model.brandxml = reader["brandxml"].ToString(); } if (reader["marketstoreyxml"] != null && reader["marketstoreyxml"].ToString() != "") { model.marketstoreyxml = reader["marketstoreyxml"].ToString(); } if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["mid"] != null && reader["mid"].ToString() != "") { model.mid = int.Parse(reader["mid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["industry"] != null && reader["industry"].ToString() != "") { model.industry = reader["industry"].ToString(); } if (reader["productcategory"] != null && reader["productcategory"].ToString() != "") { model.productcategory = reader["productcategory"].ToString(); } if (reader["vip"] != null && reader["vip"].ToString() != "") { model.vip = int.Parse(reader["vip"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["mapapi"] != null && reader["mapapi"].ToString() != "") { model.mapapi = reader["mapapi"].ToString(); } if (reader["staffsize"] != null && reader["staffsize"].ToString() != "") { model.staffsize = int.Parse(reader["staffsize"].ToString()); } if (reader["regyear"] != null && reader["regyear"].ToString() != "") { model.regyear = reader["regyear"].ToString(); } if (reader["regcity"] != null && reader["regcity"].ToString() != "") { model.regcity = reader["regcity"].ToString(); } if (reader["buy"] != null && reader["buy"].ToString() != "") { model.buy = reader["buy"].ToString(); } if (reader["sell"] != null && reader["sell"].ToString() != "") { model.sell = reader["sell"].ToString(); } if (reader["cbm"] != null && reader["cbm"].ToString() != "") { model.cbm = decimal.Parse(reader["cbm"].ToString()); } if (reader["lphone"] != null && reader["lphone"].ToString() != "") { model.lphone = reader["lphone"].ToString(); } if (reader["zphone"] != null && reader["zphone"].ToString() != "") { model.zphone = reader["zphone"].ToString(); } if (reader["busroute"] != null && reader["busroute"].ToString() != "") { model.busroute = reader["busroute"].ToString(); } if (reader["hours"] != null && reader["hours"].ToString() != "") { model.hours = reader["hours"].ToString(); } if (reader["linkman"] != null && reader["linkman"].ToString() != "") { model.linkman = reader["linkman"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["mphone"] != null && reader["mphone"].ToString() != "") { model.mphone = reader["mphone"].ToString(); } if (reader["fax"] != null && reader["fax"].ToString() != "") { model.fax = reader["fax"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["postcode"] != null && reader["postcode"].ToString() != "") { model.postcode = reader["postcode"].ToString(); } if (reader["homepage"] != null && reader["homepage"].ToString() != "") { model.homepage = reader["homepage"].ToString(); } if (reader["domain"] != null && reader["domain"].ToString() != "") { model.domain = reader["domain"].ToString(); } if (reader["domainip"] != null && reader["domainip"].ToString() != "") { model.domainip = reader["domainip"].ToString(); } if (reader["icp"] != null && reader["icp"].ToString() != "") { model.icp = reader["icp"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } } return model; } //卖场列表 public static List<EnWebMarket> GetWebMarketList(int PageIndex, int PageSize, string strWhere,string sortkey, string ordertype, out int pageCount) { List<EnWebMarket> list = new List<EnWebMarket>(); IDataReader reader = DataCommon.GetPageDataReader(TableName.TVMarket, PageIndex, PageSize, strWhere, sortkey, ordertype, out pageCount); while (reader.Read()) { EnWebMarket model = new EnWebMarket(); if (reader["shopcount"] != null && reader["shopcount"].ToString() != "") { model.shopcount = int.Parse(reader["shopcount"].ToString()); } if (reader["shopxml"] != null && reader["shopxml"].ToString() != "") { model.shopxml = reader["shopxml"].ToString(); } if (reader["brandxml"] != null && reader["brandxml"].ToString() != "") { model.brandxml = reader["brandxml"].ToString(); } if (reader["marketstoreyxml"] != null && reader["marketstoreyxml"].ToString() != "") { model.marketstoreyxml = reader["marketstoreyxml"].ToString(); } if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["mid"] != null && reader["mid"].ToString() != "") { model.mid = int.Parse(reader["mid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["industry"] != null && reader["industry"].ToString() != "") { model.industry = reader["industry"].ToString(); } if (reader["productcategory"] != null && reader["productcategory"].ToString() != "") { model.productcategory = reader["productcategory"].ToString(); } if (reader["vip"] != null && reader["vip"].ToString() != "") { model.vip = int.Parse(reader["vip"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["mapapi"] != null && reader["mapapi"].ToString() != "") { model.mapapi = reader["mapapi"].ToString(); } if (reader["staffsize"] != null && reader["staffsize"].ToString() != "") { model.staffsize = int.Parse(reader["staffsize"].ToString()); } if (reader["regyear"] != null && reader["regyear"].ToString() != "") { model.regyear = reader["regyear"].ToString(); } if (reader["regcity"] != null && reader["regcity"].ToString() != "") { model.regcity = reader["regcity"].ToString(); } if (reader["buy"] != null && reader["buy"].ToString() != "") { model.buy = reader["buy"].ToString(); } if (reader["sell"] != null && reader["sell"].ToString() != "") { model.sell = reader["sell"].ToString(); } if (reader["cbm"] != null && reader["cbm"].ToString() != "") { model.cbm = decimal.Parse(reader["cbm"].ToString()); } if (reader["lphone"] != null && reader["lphone"].ToString() != "") { model.lphone = reader["lphone"].ToString(); } if (reader["zphone"] != null && reader["zphone"].ToString() != "") { model.zphone = reader["zphone"].ToString(); } if (reader["busroute"] != null && reader["busroute"].ToString() != "") { model.busroute = reader["busroute"].ToString(); } if (reader["hours"] != null && reader["hours"].ToString() != "") { model.hours = reader["hours"].ToString(); } if (reader["linkman"] != null && reader["linkman"].ToString() != "") { model.linkman = reader["linkman"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["mphone"] != null && reader["mphone"].ToString() != "") { model.mphone = reader["mphone"].ToString(); } if (reader["fax"] != null && reader["fax"].ToString() != "") { model.fax = reader["fax"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["postcode"] != null && reader["postcode"].ToString() != "") { model.postcode = reader["postcode"].ToString(); } if (reader["homepage"] != null && reader["homepage"].ToString() != "") { model.homepage = reader["homepage"].ToString(); } if (reader["domain"] != null && reader["domain"].ToString() != "") { model.domain = reader["domain"].ToString(); } if (reader["domainip"] != null && reader["domainip"].ToString() != "") { model.domainip = reader["domainip"].ToString(); } if (reader["icp"] != null && reader["icp"].ToString() != "") { model.icp = reader["icp"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } list.Add(model); } return list; } public static List<EnSearchItem> GetMarketSearchItem() { List<EnSearchItem> list = new List<EnSearchItem>(); IDataReader reader = DbHelper.ExecuteReader(" select * from " + TableName.TVMarketSearchItem); while (reader.Read()) { EnSearchItem model = new EnSearchItem(); if (reader["t"] != null && reader["t"].ToString() != "") { model.type = reader["t"].ToString(); } if (reader["v"] != null && reader["v"].ToString() != "") { model.value = reader["v"].ToString(); } else { model.value = "0"; } if (reader["n"] != null && reader["n"].ToString() != "") { model.title = reader["n"].ToString(); } if (reader["c"] != null && reader["c"].ToString() != "") { model.count = int.Parse(reader["c"].ToString()); } model.isCur = false; list.Add(model); } return list; } #region 共公模块 /// <summary> /// 更新对像 /// </summary> public static int EditMarket(EnMarket model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_market("); strSql.Append("mid,title,letter,groupid,attribute,industry,productcategory,vip,areacode,address,mapapi,staffsize,regyear,regcity,buy,sell,cbm,lphone,zphone,busroute,hours,linkman,phone,mphone,fax,email,postcode,homepage,domain,domainip,icp,surface,logo,thumb,bannel,desimage,descript,keywords,template,hits,sort,createmid,lastedid,lastedittime,auditstatus,linestatus)"); strSql.Append(" values ("); strSql.Append("@mid,@title,@letter,@groupid,@attribute,@industry,@productcategory,@vip,@areacode,@address,@mapapi,@staffsize,@regyear,@regcity,@buy,@sell,@cbm,@lphone,@zphone,@busroute,@hours,@linkman,@phone,@mphone,@fax,@email,@postcode,@homepage,@domain,@domainip,@icp,@surface,@logo,@thumb,@bannel,@desimage,@descript,@keywords,@template,@hits,@sort,@createmid,@lastedid,@lastedittime,@auditstatus,@linestatus)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@mid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@groupid", SqlDbType.Int,4), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@industry", SqlDbType.VarChar,50), new SqlParameter("@productcategory", SqlDbType.VarChar,50), new SqlParameter("@vip", SqlDbType.Int,4), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,60), new SqlParameter("@mapapi", SqlDbType.NVarChar,80), new SqlParameter("@staffsize", SqlDbType.Int,4), new SqlParameter("@regyear", SqlDbType.VarChar,7), new SqlParameter("@regcity", SqlDbType.VarChar,10), new SqlParameter("@buy", SqlDbType.NVarChar,300), new SqlParameter("@sell", SqlDbType.NVarChar,300), new SqlParameter("@cbm", SqlDbType.Decimal,9), new SqlParameter("@lphone", SqlDbType.VarChar,50), new SqlParameter("@zphone", SqlDbType.VarChar,50), new SqlParameter("@busroute", SqlDbType.NVarChar,160), new SqlParameter("@hours", SqlDbType.NVarChar,160), new SqlParameter("@linkman", SqlDbType.NVarChar,20), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@mphone", SqlDbType.VarChar,20), new SqlParameter("@fax", SqlDbType.VarChar,20), new SqlParameter("@email", SqlDbType.VarChar,50), new SqlParameter("@postcode", SqlDbType.VarChar,15), new SqlParameter("@homepage", SqlDbType.VarChar,50), new SqlParameter("@domain", SqlDbType.VarChar,50), new SqlParameter("@domainip", SqlDbType.VarChar,50), new SqlParameter("@icp", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4)}; parameters[0].Value = model.mid; parameters[1].Value = model.title; parameters[2].Value = model.letter; parameters[3].Value = model.groupid; parameters[4].Value = model.attribute; parameters[5].Value = model.industry; parameters[6].Value = model.productcategory; parameters[7].Value = model.vip; parameters[8].Value = model.areacode; parameters[9].Value = model.address; parameters[10].Value = model.mapapi; parameters[11].Value = model.staffsize; parameters[12].Value = model.regyear; parameters[13].Value = model.regcity; parameters[14].Value = model.buy; parameters[15].Value = model.sell; parameters[16].Value = model.cbm; parameters[17].Value = model.lphone; parameters[18].Value = model.zphone; parameters[19].Value = model.busroute; parameters[20].Value = model.hours; parameters[21].Value = model.linkman; parameters[22].Value = model.phone; parameters[23].Value = model.mphone; parameters[24].Value = model.fax; parameters[25].Value = model.email; parameters[26].Value = model.postcode; parameters[27].Value = model.homepage; parameters[28].Value = model.domain; parameters[29].Value = model.domainip; parameters[30].Value = model.icp; parameters[31].Value = model.surface; parameters[32].Value = model.logo; parameters[33].Value = model.thumb; parameters[34].Value = model.bannel; parameters[35].Value = model.desimage; parameters[36].Value = model.descript; parameters[37].Value = model.keywords; parameters[38].Value = model.template; parameters[39].Value = model.hits; parameters[40].Value = model.sort; parameters[41].Value = model.createmid; parameters[42].Value = model.lastedid; parameters[43].Value = model.lastedittime; parameters[44].Value = model.auditstatus; parameters[45].Value = model.linestatus; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_market set "); strSql.Append("mid=@mid,"); strSql.Append("title=@title,"); strSql.Append("letter=@letter,"); strSql.Append("groupid=@groupid,"); strSql.Append("attribute=@attribute,"); strSql.Append("industry=@industry,"); strSql.Append("productcategory=@productcategory,"); strSql.Append("vip=@vip,"); strSql.Append("areacode=@areacode,"); strSql.Append("address=@address,"); strSql.Append("mapapi=@mapapi,"); strSql.Append("staffsize=@staffsize,"); strSql.Append("regyear=@regyear,"); strSql.Append("regcity=@regcity,"); strSql.Append("buy=@buy,"); strSql.Append("sell=@sell,"); strSql.Append("cbm=@cbm,"); strSql.Append("lphone=@lphone,"); strSql.Append("zphone=@zphone,"); strSql.Append("busroute=@busroute,"); strSql.Append("hours=@hours,"); strSql.Append("linkman=@linkman,"); strSql.Append("phone=@phone,"); strSql.Append("mphone=@mphone,"); strSql.Append("fax=@fax,"); strSql.Append("email=@email,"); strSql.Append("postcode=@postcode,"); strSql.Append("homepage=@homepage,"); strSql.Append("domain=@domain,"); strSql.Append("domainip=@domainip,"); strSql.Append("icp=@icp,"); strSql.Append("surface=@surface,"); strSql.Append("logo=@logo,"); strSql.Append("thumb=@thumb,"); strSql.Append("bannel=@bannel,"); strSql.Append("desimage=@desimage,"); strSql.Append("descript=@descript,"); strSql.Append("keywords=@keywords,"); strSql.Append("template=@template,"); strSql.Append("hits=@hits,"); strSql.Append("sort=@sort,"); strSql.Append("createmid=@createmid,"); strSql.Append("lastedid=@lastedid,"); strSql.Append("lastedittime=@lastedittime,"); strSql.Append("auditstatus=@auditstatus,"); strSql.Append("linestatus=@linestatus"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@mid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@groupid", SqlDbType.Int,4), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@industry", SqlDbType.VarChar,50), new SqlParameter("@productcategory", SqlDbType.VarChar,50), new SqlParameter("@vip", SqlDbType.Int,4), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,60), new SqlParameter("@mapapi", SqlDbType.NVarChar,80), new SqlParameter("@staffsize", SqlDbType.Int,4), new SqlParameter("@regyear", SqlDbType.VarChar,7), new SqlParameter("@regcity", SqlDbType.VarChar,10), new SqlParameter("@buy", SqlDbType.NVarChar,300), new SqlParameter("@sell", SqlDbType.NVarChar,300), new SqlParameter("@cbm", SqlDbType.Decimal,9), new SqlParameter("@lphone", SqlDbType.VarChar,50), new SqlParameter("@zphone", SqlDbType.VarChar,50), new SqlParameter("@busroute", SqlDbType.NVarChar,160), new SqlParameter("@hours", SqlDbType.NVarChar,160), new SqlParameter("@linkman", SqlDbType.NVarChar,20), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@mphone", SqlDbType.VarChar,20), new SqlParameter("@fax", SqlDbType.VarChar,20), new SqlParameter("@email", SqlDbType.VarChar,50), new SqlParameter("@postcode", SqlDbType.VarChar,15), new SqlParameter("@homepage", SqlDbType.VarChar,50), new SqlParameter("@domain", SqlDbType.VarChar,50), new SqlParameter("@domainip", SqlDbType.VarChar,50), new SqlParameter("@icp", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.mid; parameters[1].Value = model.title; parameters[2].Value = model.letter; parameters[3].Value = model.groupid; parameters[4].Value = model.attribute; parameters[5].Value = model.industry; parameters[6].Value = model.productcategory; parameters[7].Value = model.vip; parameters[8].Value = model.areacode; parameters[9].Value = model.address; parameters[10].Value = model.mapapi; parameters[11].Value = model.staffsize; parameters[12].Value = model.regyear; parameters[13].Value = model.regcity; parameters[14].Value = model.buy; parameters[15].Value = model.sell; parameters[16].Value = model.cbm; parameters[17].Value = model.lphone; parameters[18].Value = model.zphone; parameters[19].Value = model.busroute; parameters[20].Value = model.hours; parameters[21].Value = model.linkman; parameters[22].Value = model.phone; parameters[23].Value = model.mphone; parameters[24].Value = model.fax; parameters[25].Value = model.email; parameters[26].Value = model.postcode; parameters[27].Value = model.homepage; parameters[28].Value = model.domain; parameters[29].Value = model.domainip; parameters[30].Value = model.icp; parameters[31].Value = model.surface; parameters[32].Value = model.logo; parameters[33].Value = model.thumb; parameters[34].Value = model.bannel; parameters[35].Value = model.desimage; parameters[36].Value = model.descript; parameters[37].Value = model.keywords; parameters[38].Value = model.template; parameters[39].Value = model.hits; parameters[40].Value = model.sort; parameters[41].Value = model.createmid; parameters[42].Value = model.lastedid; parameters[43].Value = model.lastedittime; parameters[44].Value = model.auditstatus; parameters[45].Value = model.linestatus; parameters[46].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnMarket GetMarketInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Market "); strSql.Append(strWhere); EnMarket model = new EnMarket(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["mid"] != null && reader["mid"].ToString() != "") { model.mid = int.Parse(reader["mid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["industry"] != null && reader["industry"].ToString() != "") { model.industry = reader["industry"].ToString(); } if (reader["productcategory"] != null && reader["productcategory"].ToString() != "") { model.productcategory = reader["productcategory"].ToString(); } if (reader["vip"] != null && reader["vip"].ToString() != "") { model.vip = int.Parse(reader["vip"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["mapapi"] != null && reader["mapapi"].ToString() != "") { model.mapapi = reader["mapapi"].ToString(); } if (reader["staffsize"] != null && reader["staffsize"].ToString() != "") { model.staffsize = int.Parse(reader["staffsize"].ToString()); } if (reader["regyear"] != null && reader["regyear"].ToString() != "") { model.regyear = reader["regyear"].ToString(); } if (reader["regcity"] != null && reader["regcity"].ToString() != "") { model.regcity = reader["regcity"].ToString(); } if (reader["buy"] != null && reader["buy"].ToString() != "") { model.buy = reader["buy"].ToString(); } if (reader["sell"] != null && reader["sell"].ToString() != "") { model.sell = reader["sell"].ToString(); } if (reader["cbm"] != null && reader["cbm"].ToString() != "") { model.cbm = decimal.Parse(reader["cbm"].ToString()); } if (reader["lphone"] != null && reader["lphone"].ToString() != "") { model.lphone = reader["lphone"].ToString(); } if (reader["zphone"] != null && reader["zphone"].ToString() != "") { model.zphone = reader["zphone"].ToString(); } if (reader["busroute"] != null && reader["busroute"].ToString() != "") { model.busroute = reader["busroute"].ToString(); } if (reader["hours"] != null && reader["hours"].ToString() != "") { model.hours = reader["hours"].ToString(); } if (reader["linkman"] != null && reader["linkman"].ToString() != "") { model.linkman = reader["linkman"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["mphone"] != null && reader["mphone"].ToString() != "") { model.mphone = reader["mphone"].ToString(); } if (reader["fax"] != null && reader["fax"].ToString() != "") { model.fax = reader["fax"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["postcode"] != null && reader["postcode"].ToString() != "") { model.postcode = reader["postcode"].ToString(); } if (reader["homepage"] != null && reader["homepage"].ToString() != "") { model.homepage = reader["homepage"].ToString(); } if (reader["domain"] != null && reader["domain"].ToString() != "") { model.domain = reader["domain"].ToString(); } if (reader["domainip"] != null && reader["domainip"].ToString() != "") { model.domainip = reader["domainip"].ToString(); } if (reader["icp"] != null && reader["icp"].ToString() != "") { model.icp = reader["icp"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnMarket> GetMarketList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnMarket> modelList = new List<EnMarket>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBMarket, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnMarket model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnMarket(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["mid"] != null && dt.Rows[n]["mid"].ToString() != "") { model.mid = int.Parse(dt.Rows[n]["mid"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["groupid"] != null && dt.Rows[n]["groupid"].ToString() != "") { model.groupid = int.Parse(dt.Rows[n]["groupid"].ToString()); } if (dt.Rows[n]["attribute"] != null && dt.Rows[n]["attribute"].ToString() != "") { model.attribute = dt.Rows[n]["attribute"].ToString(); } if (dt.Rows[n]["industry"] != null && dt.Rows[n]["industry"].ToString() != "") { model.industry = dt.Rows[n]["industry"].ToString(); } if (dt.Rows[n]["productcategory"] != null && dt.Rows[n]["productcategory"].ToString() != "") { model.productcategory = dt.Rows[n]["productcategory"].ToString(); } if (dt.Rows[n]["vip"] != null && dt.Rows[n]["vip"].ToString() != "") { model.vip = int.Parse(dt.Rows[n]["vip"].ToString()); } if (dt.Rows[n]["areacode"] != null && dt.Rows[n]["areacode"].ToString() != "") { model.areacode = dt.Rows[n]["areacode"].ToString(); } if (dt.Rows[n]["address"] != null && dt.Rows[n]["address"].ToString() != "") { model.address = dt.Rows[n]["address"].ToString(); } if (dt.Rows[n]["mapapi"] != null && dt.Rows[n]["mapapi"].ToString() != "") { model.mapapi = dt.Rows[n]["mapapi"].ToString(); } if (dt.Rows[n]["staffsize"] != null && dt.Rows[n]["staffsize"].ToString() != "") { model.staffsize = int.Parse(dt.Rows[n]["staffsize"].ToString()); } if (dt.Rows[n]["regyear"] != null && dt.Rows[n]["regyear"].ToString() != "") { model.regyear = dt.Rows[n]["regyear"].ToString(); } if (dt.Rows[n]["regcity"] != null && dt.Rows[n]["regcity"].ToString() != "") { model.regcity = dt.Rows[n]["regcity"].ToString(); } if (dt.Rows[n]["buy"] != null && dt.Rows[n]["buy"].ToString() != "") { model.buy = dt.Rows[n]["buy"].ToString(); } if (dt.Rows[n]["sell"] != null && dt.Rows[n]["sell"].ToString() != "") { model.sell = dt.Rows[n]["sell"].ToString(); } if (dt.Rows[n]["cbm"] != null && dt.Rows[n]["cbm"].ToString() != "") { model.cbm = decimal.Parse(dt.Rows[n]["cbm"].ToString()); } if (dt.Rows[n]["lphone"] != null && dt.Rows[n]["lphone"].ToString() != "") { model.lphone = dt.Rows[n]["lphone"].ToString(); } if (dt.Rows[n]["zphone"] != null && dt.Rows[n]["zphone"].ToString() != "") { model.zphone = dt.Rows[n]["zphone"].ToString(); } if (dt.Rows[n]["busroute"] != null && dt.Rows[n]["busroute"].ToString() != "") { model.busroute = dt.Rows[n]["busroute"].ToString(); } if (dt.Rows[n]["hours"] != null && dt.Rows[n]["hours"].ToString() != "") { model.hours = dt.Rows[n]["hours"].ToString(); } if (dt.Rows[n]["linkman"] != null && dt.Rows[n]["linkman"].ToString() != "") { model.linkman = dt.Rows[n]["linkman"].ToString(); } if (dt.Rows[n]["phone"] != null && dt.Rows[n]["phone"].ToString() != "") { model.phone = dt.Rows[n]["phone"].ToString(); } if (dt.Rows[n]["mphone"] != null && dt.Rows[n]["mphone"].ToString() != "") { model.mphone = dt.Rows[n]["mphone"].ToString(); } if (dt.Rows[n]["fax"] != null && dt.Rows[n]["fax"].ToString() != "") { model.fax = dt.Rows[n]["fax"].ToString(); } if (dt.Rows[n]["email"] != null && dt.Rows[n]["email"].ToString() != "") { model.email = dt.Rows[n]["email"].ToString(); } if (dt.Rows[n]["postcode"] != null && dt.Rows[n]["postcode"].ToString() != "") { model.postcode = dt.Rows[n]["postcode"].ToString(); } if (dt.Rows[n]["homepage"] != null && dt.Rows[n]["homepage"].ToString() != "") { model.homepage = dt.Rows[n]["homepage"].ToString(); } if (dt.Rows[n]["domain"] != null && dt.Rows[n]["domain"].ToString() != "") { model.domain = dt.Rows[n]["domain"].ToString(); } if (dt.Rows[n]["domainip"] != null && dt.Rows[n]["domainip"].ToString() != "") { model.domainip = dt.Rows[n]["domainip"].ToString(); } if (dt.Rows[n]["icp"] != null && dt.Rows[n]["icp"].ToString() != "") { model.icp = dt.Rows[n]["icp"].ToString(); } if (dt.Rows[n]["surface"] != null && dt.Rows[n]["surface"].ToString() != "") { model.surface = dt.Rows[n]["surface"].ToString(); } if (dt.Rows[n]["logo"] != null && dt.Rows[n]["logo"].ToString() != "") { model.logo = dt.Rows[n]["logo"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["bannel"] != null && dt.Rows[n]["bannel"].ToString() != "") { model.bannel = dt.Rows[n]["bannel"].ToString(); } if (dt.Rows[n]["desimage"] != null && dt.Rows[n]["desimage"].ToString() != "") { model.desimage = dt.Rows[n]["desimage"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["keywords"] != null && dt.Rows[n]["keywords"].ToString() != "") { model.keywords = dt.Rows[n]["keywords"].ToString(); } if (dt.Rows[n]["template"] != null && dt.Rows[n]["template"].ToString() != "") { model.template = dt.Rows[n]["template"].ToString(); } if (dt.Rows[n]["hits"] != null && dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["createmid"] != null && dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } if (dt.Rows[n]["lastedid"] != null && dt.Rows[n]["lastedid"].ToString() != "") { model.lastedid = int.Parse(dt.Rows[n]["lastedid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["auditstatus"] != null && dt.Rows[n]["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(dt.Rows[n]["auditstatus"].ToString()); } if (dt.Rows[n]["linestatus"] != null && dt.Rows[n]["linestatus"].ToString() != "") { model.linestatus = int.Parse(dt.Rows[n]["linestatus"].ToString()); } modelList.Add(model); } } return modelList; } /// <summary> /// 获得数据列表 /// </summary> public static List<EnMarket> GetMarketList(string filed, string strWhere, string sort) { List<EnMarket> modelList = new List<EnMarket>(); DataTable dt =DataCommon.GetDataTable(TableName.TBMarket, filed, strWhere, sort); if (dt.Rows.Count > 0) { EnMarket model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnMarket(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["mid"] != null && dt.Rows[n]["mid"].ToString() != "") { model.mid = int.Parse(dt.Rows[n]["mid"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["groupid"] != null && dt.Rows[n]["groupid"].ToString() != "") { model.groupid = int.Parse(dt.Rows[n]["groupid"].ToString()); } if (dt.Rows[n]["attribute"] != null && dt.Rows[n]["attribute"].ToString() != "") { model.attribute = dt.Rows[n]["attribute"].ToString(); } if (dt.Rows[n]["industry"] != null && dt.Rows[n]["industry"].ToString() != "") { model.industry = dt.Rows[n]["industry"].ToString(); } if (dt.Rows[n]["productcategory"] != null && dt.Rows[n]["productcategory"].ToString() != "") { model.productcategory = dt.Rows[n]["productcategory"].ToString(); } if (dt.Rows[n]["vip"] != null && dt.Rows[n]["vip"].ToString() != "") { model.vip = int.Parse(dt.Rows[n]["vip"].ToString()); } if (dt.Rows[n]["areacode"] != null && dt.Rows[n]["areacode"].ToString() != "") { model.areacode = dt.Rows[n]["areacode"].ToString(); } if (dt.Rows[n]["address"] != null && dt.Rows[n]["address"].ToString() != "") { model.address = dt.Rows[n]["address"].ToString(); } if (dt.Rows[n]["mapapi"] != null && dt.Rows[n]["mapapi"].ToString() != "") { model.mapapi = dt.Rows[n]["mapapi"].ToString(); } if (dt.Rows[n]["staffsize"] != null && dt.Rows[n]["staffsize"].ToString() != "") { model.staffsize = int.Parse(dt.Rows[n]["staffsize"].ToString()); } if (dt.Rows[n]["regyear"] != null && dt.Rows[n]["regyear"].ToString() != "") { model.regyear = dt.Rows[n]["regyear"].ToString(); } if (dt.Rows[n]["regcity"] != null && dt.Rows[n]["regcity"].ToString() != "") { model.regcity = dt.Rows[n]["regcity"].ToString(); } if (dt.Rows[n]["buy"] != null && dt.Rows[n]["buy"].ToString() != "") { model.buy = dt.Rows[n]["buy"].ToString(); } if (dt.Rows[n]["sell"] != null && dt.Rows[n]["sell"].ToString() != "") { model.sell = dt.Rows[n]["sell"].ToString(); } if (dt.Rows[n]["cbm"] != null && dt.Rows[n]["cbm"].ToString() != "") { model.cbm = decimal.Parse(dt.Rows[n]["cbm"].ToString()); } if (dt.Rows[n]["lphone"] != null && dt.Rows[n]["lphone"].ToString() != "") { model.lphone = dt.Rows[n]["lphone"].ToString(); } if (dt.Rows[n]["zphone"] != null && dt.Rows[n]["zphone"].ToString() != "") { model.zphone = dt.Rows[n]["zphone"].ToString(); } if (dt.Rows[n]["busroute"] != null && dt.Rows[n]["busroute"].ToString() != "") { model.busroute = dt.Rows[n]["busroute"].ToString(); } if (dt.Rows[n]["hours"] != null && dt.Rows[n]["hours"].ToString() != "") { model.hours = dt.Rows[n]["hours"].ToString(); } if (dt.Rows[n]["linkman"] != null && dt.Rows[n]["linkman"].ToString() != "") { model.linkman = dt.Rows[n]["linkman"].ToString(); } if (dt.Rows[n]["phone"] != null && dt.Rows[n]["phone"].ToString() != "") { model.phone = dt.Rows[n]["phone"].ToString(); } if (dt.Rows[n]["mphone"] != null && dt.Rows[n]["mphone"].ToString() != "") { model.mphone = dt.Rows[n]["mphone"].ToString(); } if (dt.Rows[n]["fax"] != null && dt.Rows[n]["fax"].ToString() != "") { model.fax = dt.Rows[n]["fax"].ToString(); } if (dt.Rows[n]["email"] != null && dt.Rows[n]["email"].ToString() != "") { model.email = dt.Rows[n]["email"].ToString(); } if (dt.Rows[n]["postcode"] != null && dt.Rows[n]["postcode"].ToString() != "") { model.postcode = dt.Rows[n]["postcode"].ToString(); } if (dt.Rows[n]["homepage"] != null && dt.Rows[n]["homepage"].ToString() != "") { model.homepage = dt.Rows[n]["homepage"].ToString(); } if (dt.Rows[n]["domain"] != null && dt.Rows[n]["domain"].ToString() != "") { model.domain = dt.Rows[n]["domain"].ToString(); } if (dt.Rows[n]["domainip"] != null && dt.Rows[n]["domainip"].ToString() != "") { model.domainip = dt.Rows[n]["domainip"].ToString(); } if (dt.Rows[n]["icp"] != null && dt.Rows[n]["icp"].ToString() != "") { model.icp = dt.Rows[n]["icp"].ToString(); } if (dt.Rows[n]["surface"] != null && dt.Rows[n]["surface"].ToString() != "") { model.surface = dt.Rows[n]["surface"].ToString(); } if (dt.Rows[n]["logo"] != null && dt.Rows[n]["logo"].ToString() != "") { model.logo = dt.Rows[n]["logo"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["bannel"] != null && dt.Rows[n]["bannel"].ToString() != "") { model.bannel = dt.Rows[n]["bannel"].ToString(); } if (dt.Rows[n]["desimage"] != null && dt.Rows[n]["desimage"].ToString() != "") { model.desimage = dt.Rows[n]["desimage"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["keywords"] != null && dt.Rows[n]["keywords"].ToString() != "") { model.keywords = dt.Rows[n]["keywords"].ToString(); } if (dt.Rows[n]["template"] != null && dt.Rows[n]["template"].ToString() != "") { model.template = dt.Rows[n]["template"].ToString(); } if (dt.Rows[n]["hits"] != null && dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["createmid"] != null && dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } if (dt.Rows[n]["lastedid"] != null && dt.Rows[n]["lastedid"].ToString() != "") { model.lastedid = int.Parse(dt.Rows[n]["lastedid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["auditstatus"] != null && dt.Rows[n]["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(dt.Rows[n]["auditstatus"].ToString()); } if (dt.Rows[n]["linestatus"] != null && dt.Rows[n]["linestatus"].ToString() != "") { model.linestatus = int.Parse(dt.Rows[n]["linestatus"].ToString()); } modelList.Add(model); } } return modelList; } #endregion #region 共公模块-组 /// <summary> /// 更新对像 /// </summary> public static int EditMarketGroup(EnMarketGroup model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_marketgroup("); strSql.Append("title,color,avatar,integral,money,adcount,shopcount,brandcount,promotioncount,storeycount,storeyshopcount,adrecommend,shoprecommend,brandrecommend,promotionrecommend,lev,permissions,descript,sort)"); strSql.Append(" values ("); strSql.Append("@title,@color,@avatar,@integral,@money,@adcount,@shopcount,@brandcount,@promotioncount,@storeycount,@storeyshopcount,@adrecommend,@shoprecommend,@brandrecommend,@promotionrecommend,@lev,@permissions,@descript,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@color", SqlDbType.Char,7), new SqlParameter("@avatar", SqlDbType.VarChar,40), new SqlParameter("@integral", SqlDbType.Decimal,9), new SqlParameter("@money", SqlDbType.Decimal,9), new SqlParameter("@adcount", SqlDbType.Int,4), new SqlParameter("@shopcount", SqlDbType.Int,4), new SqlParameter("@brandcount", SqlDbType.Int,4), new SqlParameter("@promotioncount", SqlDbType.Int,4), new SqlParameter("@storeycount", SqlDbType.Int,4), new SqlParameter("@storeyshopcount", SqlDbType.Int,4), new SqlParameter("@adrecommend", SqlDbType.Int,4), new SqlParameter("@shoprecommend", SqlDbType.Int,4), new SqlParameter("@brandrecommend", SqlDbType.Int,4), new SqlParameter("@promotionrecommend", SqlDbType.Int,4), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@permissions", SqlDbType.NText), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.color; parameters[2].Value = model.avatar; parameters[3].Value = model.integral; parameters[4].Value = model.money; parameters[5].Value = model.adcount; parameters[6].Value = model.shopcount; parameters[7].Value = model.brandcount; parameters[8].Value = model.promotioncount; parameters[9].Value = model.storeycount; parameters[10].Value = model.storeyshopcount; parameters[11].Value = model.adrecommend; parameters[12].Value = model.shoprecommend; parameters[13].Value = model.brandrecommend; parameters[14].Value = model.promotionrecommend; parameters[15].Value = model.lev; parameters[16].Value = model.permissions; parameters[17].Value = model.descript; parameters[18].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_marketgroup set "); strSql.Append("title=@title,"); strSql.Append("color=@color,"); strSql.Append("avatar=@avatar,"); strSql.Append("integral=@integral,"); strSql.Append("money=@money,"); strSql.Append("adcount=@adcount,"); strSql.Append("shopcount=@shopcount,"); strSql.Append("brandcount=@brandcount,"); strSql.Append("promotioncount=@promotioncount,"); strSql.Append("storeycount=@storeycount,"); strSql.Append("storeyshopcount=@storeyshopcount,"); strSql.Append("adrecommend=@adrecommend,"); strSql.Append("shoprecommend=@shoprecommend,"); strSql.Append("brandrecommend=@brandrecommend,"); strSql.Append("promotionrecommend=@promotionrecommend,"); strSql.Append("lev=@lev,"); strSql.Append("permissions=@permissions,"); strSql.Append("descript=@descript,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@color", SqlDbType.Char,7), new SqlParameter("@avatar", SqlDbType.VarChar,40), new SqlParameter("@integral", SqlDbType.Decimal,9), new SqlParameter("@money", SqlDbType.Decimal,9), new SqlParameter("@adcount", SqlDbType.Int,4), new SqlParameter("@shopcount", SqlDbType.Int,4), new SqlParameter("@brandcount", SqlDbType.Int,4), new SqlParameter("@promotioncount", SqlDbType.Int,4), new SqlParameter("@storeycount", SqlDbType.Int,4), new SqlParameter("@storeyshopcount", SqlDbType.Int,4), new SqlParameter("@adrecommend", SqlDbType.Int,4), new SqlParameter("@shoprecommend", SqlDbType.Int,4), new SqlParameter("@brandrecommend", SqlDbType.Int,4), new SqlParameter("@promotionrecommend", SqlDbType.Int,4), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@permissions", SqlDbType.NText), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.color; parameters[2].Value = model.avatar; parameters[3].Value = model.integral; parameters[4].Value = model.money; parameters[5].Value = model.adcount; parameters[6].Value = model.shopcount; parameters[7].Value = model.brandcount; parameters[8].Value = model.promotioncount; parameters[9].Value = model.storeycount; parameters[10].Value = model.storeyshopcount; parameters[11].Value = model.adrecommend; parameters[12].Value = model.shoprecommend; parameters[13].Value = model.brandrecommend; parameters[14].Value = model.promotionrecommend; parameters[15].Value = model.lev; parameters[16].Value = model.permissions; parameters[17].Value = model.descript; parameters[18].Value = model.sort; parameters[19].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnMarketGroup GetMarketGroupInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_MarketGroup "); strSql.Append(strWhere); EnMarketGroup model = new EnMarketGroup(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["color"] != null && reader["color"].ToString() != "") { model.color = reader["color"].ToString(); } if (reader["avatar"] != null && reader["avatar"].ToString() != "") { model.avatar = reader["avatar"].ToString(); } if (reader["integral"] != null && reader["integral"].ToString() != "") { model.integral = decimal.Parse(reader["integral"].ToString()); } if (reader["money"] != null && reader["money"].ToString() != "") { model.money = decimal.Parse(reader["money"].ToString()); } if (reader["adcount"] != null && reader["adcount"].ToString() != "") { model.adcount = int.Parse(reader["adcount"].ToString()); } if (reader["shopcount"] != null && reader["shopcount"].ToString() != "") { model.shopcount = int.Parse(reader["shopcount"].ToString()); } if (reader["brandcount"] != null && reader["brandcount"].ToString() != "") { model.brandcount = int.Parse(reader["brandcount"].ToString()); } if (reader["promotioncount"] != null && reader["promotioncount"].ToString() != "") { model.promotioncount = int.Parse(reader["promotioncount"].ToString()); } if (reader["storeycount"] != null && reader["storeycount"].ToString() != "") { model.storeycount = int.Parse(reader["storeycount"].ToString()); } if (reader["storeyshopcount"] != null && reader["storeyshopcount"].ToString() != "") { model.storeyshopcount = int.Parse(reader["storeyshopcount"].ToString()); } if (reader["adrecommend"] != null && reader["adrecommend"].ToString() != "") { model.adrecommend = int.Parse(reader["adrecommend"].ToString()); } if (reader["shoprecommend"] != null && reader["shoprecommend"].ToString() != "") { model.shoprecommend = int.Parse(reader["shoprecommend"].ToString()); } if (reader["brandrecommend"] != null && reader["brandrecommend"].ToString() != "") { model.brandrecommend = int.Parse(reader["brandrecommend"].ToString()); } if (reader["promotionrecommend"] != null && reader["promotionrecommend"].ToString() != "") { model.promotionrecommend = int.Parse(reader["promotionrecommend"].ToString()); } if (reader["lev"] != null && reader["lev"].ToString() != "") { model.lev = int.Parse(reader["lev"].ToString()); } if (reader["permissions"] != null && reader["permissions"].ToString() != "") { model.permissions = reader["permissions"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnMarketGroup> GetMarketGroupList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnMarketGroup> modelList = new List<EnMarketGroup>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBMarketGroup, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnMarketGroup model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnMarketGroup(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["color"] != null && dt.Rows[n]["color"].ToString() != "") { model.color = dt.Rows[n]["color"].ToString(); } if (dt.Rows[n]["avatar"] != null && dt.Rows[n]["avatar"].ToString() != "") { model.avatar = dt.Rows[n]["avatar"].ToString(); } if (dt.Rows[n]["integral"] != null && dt.Rows[n]["integral"].ToString() != "") { model.integral = decimal.Parse(dt.Rows[n]["integral"].ToString()); } if (dt.Rows[n]["money"] != null && dt.Rows[n]["money"].ToString() != "") { model.money = decimal.Parse(dt.Rows[n]["money"].ToString()); } if (dt.Rows[n]["adcount"] != null && dt.Rows[n]["adcount"].ToString() != "") { model.adcount = int.Parse(dt.Rows[n]["adcount"].ToString()); } if (dt.Rows[n]["shopcount"] != null && dt.Rows[n]["shopcount"].ToString() != "") { model.shopcount = int.Parse(dt.Rows[n]["shopcount"].ToString()); } if (dt.Rows[n]["brandcount"] != null && dt.Rows[n]["brandcount"].ToString() != "") { model.brandcount = int.Parse(dt.Rows[n]["brandcount"].ToString()); } if (dt.Rows[n]["promotioncount"] != null && dt.Rows[n]["promotioncount"].ToString() != "") { model.promotioncount = int.Parse(dt.Rows[n]["promotioncount"].ToString()); } if (dt.Rows[n]["storeycount"] != null && dt.Rows[n]["storeycount"].ToString() != "") { model.storeycount = int.Parse(dt.Rows[n]["storeycount"].ToString()); } if (dt.Rows[n]["storeyshopcount"] != null && dt.Rows[n]["storeyshopcount"].ToString() != "") { model.storeyshopcount = int.Parse(dt.Rows[n]["storeyshopcount"].ToString()); } if (dt.Rows[n]["adrecommend"] != null && dt.Rows[n]["adrecommend"].ToString() != "") { model.adrecommend = int.Parse(dt.Rows[n]["adrecommend"].ToString()); } if (dt.Rows[n]["shoprecommend"] != null && dt.Rows[n]["shoprecommend"].ToString() != "") { model.shoprecommend = int.Parse(dt.Rows[n]["shoprecommend"].ToString()); } if (dt.Rows[n]["brandrecommend"] != null && dt.Rows[n]["brandrecommend"].ToString() != "") { model.brandrecommend = int.Parse(dt.Rows[n]["brandrecommend"].ToString()); } if (dt.Rows[n]["promotionrecommend"] != null && dt.Rows[n]["promotionrecommend"].ToString() != "") { model.promotionrecommend = int.Parse(dt.Rows[n]["promotionrecommend"].ToString()); } if (dt.Rows[n]["lev"] != null && dt.Rows[n]["lev"].ToString() != "") { model.lev = int.Parse(dt.Rows[n]["lev"].ToString()); } if (dt.Rows[n]["permissions"] != null && dt.Rows[n]["permissions"].ToString() != "") { model.permissions = dt.Rows[n]["permissions"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Markets.cs
C#
oos
87,563
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Configs { #region 共公模块 /// <summary> /// 更新对像 /// </summary> public static int EditConfig(EnConfig model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_config("); strSql.Append("title,value,type,module,sort)"); strSql.Append(" values ("); strSql.Append("@title,@value,@type,@module,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,400), new SqlParameter("@value", SqlDbType.NVarChar,400), new SqlParameter("@type", SqlDbType.Int,4), new SqlParameter("@module", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.value; parameters[2].Value = model.type; parameters[3].Value = model.module; parameters[4].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_config set "); strSql.Append("title=@title,"); strSql.Append("value=@value,"); strSql.Append("type=@type,"); strSql.Append("module=@module,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,400), new SqlParameter("@value", SqlDbType.NVarChar,400), new SqlParameter("@type", SqlDbType.Int,4), new SqlParameter("@module", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.value; parameters[2].Value = model.type; parameters[3].Value = model.module; parameters[4].Value = model.sort; parameters[5].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnConfig GetConfigInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Config "); strSql.Append(strWhere); EnConfig model = new EnConfig(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["value"] != null && reader["value"].ToString() != "") { model.value = reader["value"].ToString(); } if (reader["type"] != null && reader["type"].ToString() != "") { model.type = int.Parse(reader["type"].ToString()); } if (reader["module"] != null && reader["module"].ToString() != "") { model.module = int.Parse(reader["module"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnConfig> GetConfigList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnConfig> modelList = new List<EnConfig>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBConfig, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnConfig model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnConfig(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["value"] != null && dt.Rows[n]["value"].ToString() != "") { model.value = dt.Rows[n]["value"].ToString(); } if (dt.Rows[n]["type"] != null && dt.Rows[n]["type"].ToString() != "") { model.type = int.Parse(dt.Rows[n]["type"].ToString()); } if (dt.Rows[n]["module"] != null && dt.Rows[n]["module"].ToString() != "") { model.module = int.Parse(dt.Rows[n]["module"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } #endregion /// <summary> /// 更新对像 /// </summary> public static int EditConfigType(EnConfigType model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_configtype("); strSql.Append("title,mark,letter,type,sort,count,descript)"); strSql.Append(" values ("); strSql.Append("@title,@mark,@letter,@type,@sort,@count,@descript)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@mark", SqlDbType.VarChar,20), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@type", SqlDbType.VarChar,100), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@count", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,400)}; parameters[0].Value = model.title; parameters[1].Value = model.mark; parameters[2].Value = model.letter; parameters[3].Value = model.type; parameters[4].Value = model.sort; parameters[5].Value = model.count; parameters[6].Value = model.descript; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_configtype set "); strSql.Append("title=@title,"); strSql.Append("mark=@mark,"); strSql.Append("letter=@letter,"); strSql.Append("type=@type,"); strSql.Append("sort=@sort,"); strSql.Append("count=@count,"); strSql.Append("descript=@descript"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@mark", SqlDbType.VarChar,20), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@type", SqlDbType.VarChar,100), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@count", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,400), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.mark; parameters[2].Value = model.letter; parameters[3].Value = model.type; parameters[4].Value = model.sort; parameters[5].Value = model.count; parameters[6].Value = model.descript; parameters[7].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnConfigType GetConfigTypeInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_ConfigType "); strSql.Append(strWhere); EnConfigType model = new EnConfigType(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["mark"] != null && reader["mark"].ToString() != "") { model.mark = reader["mark"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["type"] != null && reader["type"].ToString() != "") { model.type = reader["type"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["count"] != null && reader["count"].ToString() != "") { model.count = int.Parse(reader["count"].ToString()); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnConfigType> GetConfigTypeList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnConfigType> modelList = new List<EnConfigType>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBConfigType, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnConfigType model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnConfigType(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["mark"] != null && dt.Rows[n]["mark"].ToString() != "") { model.mark = dt.Rows[n]["mark"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["type"] != null && dt.Rows[n]["type"].ToString() != "") { model.type = dt.Rows[n]["type"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["count"] != null && dt.Rows[n]["count"].ToString() != "") { model.count = int.Parse(dt.Rows[n]["count"].ToString()); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } modelList.Add(model); } } return modelList; } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Configs.cs
C#
oos
15,332
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class GroupOrders { #region GroupOrder /// <summary> /// 更新对像 /// </summary> public static int EditGroupOrder(EnGroupOrder model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_grouporder("); strSql.Append("grouporderno,mid,fjmid,name,email,phone,fax,mphone,zip,areacode,address,descript,totlepromoney,totalmoney,invoicemoney,installationmeney,status,createtime)"); strSql.Append(" values ("); strSql.Append("@grouporderno,@mid,@fjmid,@name,@email,@phone,@fax,@mphone,@zip,@areacode,@address,@descript,@totlepromoney,@totalmoney,@invoicemoney,@installationmeney,@status,@createtime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@grouporderno", SqlDbType.VarChar,20), new SqlParameter("@mid", SqlDbType.Int,4), new SqlParameter("@fjmid", SqlDbType.Int,4), new SqlParameter("@name", SqlDbType.NVarChar,20), new SqlParameter("@email", SqlDbType.NVarChar,20), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@fax", SqlDbType.VarChar,20), new SqlParameter("@mphone", SqlDbType.VarChar,20), new SqlParameter("@zip", SqlDbType.VarChar,20), new SqlParameter("@areacode", SqlDbType.VarChar,50), new SqlParameter("@address", SqlDbType.VarChar,20), new SqlParameter("@descript", SqlDbType.NVarChar,600), new SqlParameter("@totlepromoney", SqlDbType.Decimal,9), new SqlParameter("@totalmoney", SqlDbType.Decimal,9), new SqlParameter("@invoicemoney", SqlDbType.Decimal,9), new SqlParameter("@installationmeney", SqlDbType.Decimal,9), new SqlParameter("@status", SqlDbType.Int,4), new SqlParameter("@createtime", SqlDbType.DateTime)}; parameters[0].Value = model.grouporderno; parameters[1].Value = model.mid; parameters[2].Value = model.fjmid; parameters[3].Value = model.name; parameters[4].Value = model.email; parameters[5].Value = model.phone; parameters[6].Value = model.fax; parameters[7].Value = model.mphone; parameters[8].Value = model.zip; parameters[9].Value = model.areacode; parameters[10].Value = model.address; parameters[11].Value = model.descript; parameters[12].Value = model.totlepromoney; parameters[13].Value = model.totalmoney; parameters[14].Value = model.invoicemoney; parameters[15].Value = model.installationmeney; parameters[16].Value = model.status; parameters[17].Value = model.createtime; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_grouporder set "); strSql.Append("grouporderno=@grouporderno,"); strSql.Append("mid=@mid,"); strSql.Append("fjmid=@fjmid,"); strSql.Append("name=@name,"); strSql.Append("email=@email,"); strSql.Append("phone=@phone,"); strSql.Append("fax=@fax,"); strSql.Append("mphone=@mphone,"); strSql.Append("zip=@zip,"); strSql.Append("areacode=@areacode,"); strSql.Append("address=@address,"); strSql.Append("descript=@descript,"); strSql.Append("totlepromoney=@totlepromoney,"); strSql.Append("totalmoney=@totalmoney,"); strSql.Append("invoicemoney=@invoicemoney,"); strSql.Append("installationmeney=@installationmeney,"); strSql.Append("status=@status,"); strSql.Append("createtime=@createtime"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@grouporderno", SqlDbType.VarChar,20), new SqlParameter("@mid", SqlDbType.Int,4), new SqlParameter("@fjmid", SqlDbType.Int,4), new SqlParameter("@name", SqlDbType.NVarChar,20), new SqlParameter("@email", SqlDbType.NVarChar,20), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@fax", SqlDbType.VarChar,20), new SqlParameter("@mphone", SqlDbType.VarChar,20), new SqlParameter("@zip", SqlDbType.VarChar,20), new SqlParameter("@areacode", SqlDbType.VarChar,50), new SqlParameter("@address", SqlDbType.VarChar,20), new SqlParameter("@descript", SqlDbType.NVarChar,600), new SqlParameter("@totlepromoney", SqlDbType.Decimal,9), new SqlParameter("@totalmoney", SqlDbType.Decimal,9), new SqlParameter("@invoicemoney", SqlDbType.Decimal,9), new SqlParameter("@installationmeney", SqlDbType.Decimal,9), new SqlParameter("@status", SqlDbType.Int,4), new SqlParameter("@createtime", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.grouporderno; parameters[1].Value = model.mid; parameters[2].Value = model.fjmid; parameters[3].Value = model.name; parameters[4].Value = model.email; parameters[5].Value = model.phone; parameters[6].Value = model.fax; parameters[7].Value = model.mphone; parameters[8].Value = model.zip; parameters[9].Value = model.areacode; parameters[10].Value = model.address; parameters[11].Value = model.descript; parameters[12].Value = model.totlepromoney; parameters[13].Value = model.totalmoney; parameters[14].Value = model.invoicemoney; parameters[15].Value = model.installationmeney; parameters[16].Value = model.status; parameters[17].Value = model.createtime; parameters[18].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnGroupOrder GetGroupOrderInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_grouporder "); strSql.Append(strWhere); EnGroupOrder model = new EnGroupOrder(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["grouporderno"] != null && reader["grouporderno"].ToString() != "") { model.grouporderno = reader["grouporderno"].ToString(); } if (reader["name"] != null && reader["name"].ToString() != "") { model.name = reader["name"].ToString(); } if (reader["mid"] != null && reader["mid"].ToString() != "") { model.mid = int.Parse(reader["mid"].ToString()); } if (reader["fjmid"] != null && reader["fjmid"].ToString() != "") { model.fjmid = int.Parse(reader["fjmid"].ToString()); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["fax"] != null && reader["fax"].ToString() != "") { model.fax = reader["fax"].ToString(); } if (reader["mphone"] != null && reader["mphone"].ToString() != "") { model.mphone = reader["mphone"].ToString(); } if (reader["zip"] != null && reader["zip"].ToString() != "") { model.zip = reader["zip"].ToString(); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["totlepromoney"] != null && reader["totlepromoney"].ToString() != "") { model.totlepromoney = decimal.Parse(reader["totlepromoney"].ToString()); } if (reader["totalmoney"] != null && reader["totalmoney"].ToString() != "") { model.totalmoney = decimal.Parse(reader["totalmoney"].ToString()); } if (reader["invoicemoney"] != null && reader["invoicemoney"].ToString() != "") { model.invoicemoney = decimal.Parse(reader["invoicemoney"].ToString()); } if (reader["installationmeney"] != null && reader["installationmeney"].ToString() != "") { model.installationmeney = decimal.Parse(reader["installationmeney"].ToString()); } if (reader["status"] != null && reader["status"].ToString() != "") { model.status = int.Parse(reader["status"].ToString()); } if (reader["createtime"] != null && reader["createtime"].ToString() != "") { model.createtime = DateTime.Parse(reader["createtime"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnGroupOrder> GetGroupOrderList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnGroupOrder> modelList = new List<EnGroupOrder>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBGroupOrder, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnGroupOrder model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnGroupOrder(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["grouporderno"] != null && dt.Rows[n]["grouporderno"].ToString() != "") { model.grouporderno = dt.Rows[n]["grouporderno"].ToString(); } if (dt.Rows[n]["mid"] != null && dt.Rows[n]["mid"].ToString() != "") { model.mid = int.Parse(dt.Rows[n]["mid"].ToString()); } if (dt.Rows[n]["fjmid"] != null && dt.Rows[n]["fjmid"].ToString() != "") { model.fjmid = int.Parse(dt.Rows[n]["fjmid"].ToString()); } if (dt.Rows[n]["name"] != null && dt.Rows[n]["name"].ToString() != "") { model.name = dt.Rows[n]["name"].ToString(); } if (dt.Rows[n]["email"] != null && dt.Rows[n]["email"].ToString() != "") { model.email = dt.Rows[n]["email"].ToString(); } if (dt.Rows[n]["phone"] != null && dt.Rows[n]["phone"].ToString() != "") { model.phone = dt.Rows[n]["phone"].ToString(); } if (dt.Rows[n]["fax"] != null && dt.Rows[n]["fax"].ToString() != "") { model.fax = dt.Rows[n]["fax"].ToString(); } if (dt.Rows[n]["mphone"] != null && dt.Rows[n]["mphone"].ToString() != "") { model.mphone = dt.Rows[n]["mphone"].ToString(); } if (dt.Rows[n]["zip"] != null && dt.Rows[n]["zip"].ToString() != "") { model.zip = dt.Rows[n]["zip"].ToString(); } if (dt.Rows[n]["areacode"] != null && dt.Rows[n]["areacode"].ToString() != "") { model.areacode = dt.Rows[n]["areacode"].ToString(); } if (dt.Rows[n]["address"] != null && dt.Rows[n]["address"].ToString() != "") { model.address = dt.Rows[n]["address"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["totlepromoney"] != null && dt.Rows[n]["totlepromoney"].ToString() != "") { model.totlepromoney = decimal.Parse(dt.Rows[n]["totlepromoney"].ToString()); } if (dt.Rows[n]["totalmoney"] != null && dt.Rows[n]["totalmoney"].ToString() != "") { model.totalmoney = decimal.Parse(dt.Rows[n]["totalmoney"].ToString()); } if (dt.Rows[n]["invoicemoney"] != null && dt.Rows[n]["invoicemoney"].ToString() != "") { model.invoicemoney = decimal.Parse(dt.Rows[n]["invoicemoney"].ToString()); } if (dt.Rows[n]["installationmeney"] != null && dt.Rows[n]["installationmeney"].ToString() != "") { model.installationmeney = decimal.Parse(dt.Rows[n]["installationmeney"].ToString()); } if (dt.Rows[n]["status"] != null && dt.Rows[n]["status"].ToString() != "") { model.status = int.Parse(dt.Rows[n]["status"].ToString()); } if (dt.Rows[n]["createtime"] != null && dt.Rows[n]["createtime"].ToString() != "") { model.createtime = DateTime.Parse(dt.Rows[n]["createtime"].ToString()); } modelList.Add(model); } } return modelList; } #endregion #region grouporderpay /// <summary> /// 更新对像 /// </summary> public static int EditGroupOrderPay(EnGroupOrderPay model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_grouporderpay("); strSql.Append("grouporderid,grouporderno,paycode,paytype,paymoney,descript,paystatus,paydatetime)"); strSql.Append(" values ("); strSql.Append("@grouporderid,@grouporderno,@paycode,@paytype,@paymoney,@descript,@paystatus,@paydatetime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@grouporderid", SqlDbType.Int,4), new SqlParameter("@grouporderno", SqlDbType.VarChar,20), new SqlParameter("@paycode", SqlDbType.VarChar,20), new SqlParameter("@paytype", SqlDbType.Int,4), new SqlParameter("@paymoney", SqlDbType.Decimal,9), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@paystatus", SqlDbType.Int,4), new SqlParameter("@paydatetime", SqlDbType.DateTime)}; parameters[0].Value = model.grouporderid; parameters[1].Value = model.grouporderno; parameters[2].Value = model.paycode; parameters[3].Value = model.paytype; parameters[4].Value = model.paymoney; parameters[5].Value = model.descript; parameters[6].Value = model.paystatus; parameters[7].Value = model.paydatetime; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_grouporderpay set "); strSql.Append("grouporderid=@grouporderid,"); strSql.Append("grouporderno=@grouporderno,"); strSql.Append("paycode=@paycode,"); strSql.Append("paytype=@paytype,"); strSql.Append("paymoney=@paymoney,"); strSql.Append("descript=@descript,"); strSql.Append("paystatus=@paystatus,"); strSql.Append("paydatetime=@paydatetime"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@grouporderid", SqlDbType.Int,4), new SqlParameter("@grouporderno", SqlDbType.VarChar,20), new SqlParameter("@paycode", SqlDbType.VarChar,20), new SqlParameter("@paytype", SqlDbType.Int,4), new SqlParameter("@paymoney", SqlDbType.Decimal,9), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@paystatus", SqlDbType.Int,4), new SqlParameter("@paydatetime", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.grouporderid; parameters[1].Value = model.grouporderno; parameters[2].Value = model.paycode; parameters[3].Value = model.paytype; parameters[4].Value = model.paymoney; parameters[5].Value = model.descript; parameters[6].Value = model.paystatus; parameters[7].Value = model.paydatetime; parameters[8].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnGroupOrderPay GetGroupOrderPayInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_grouporderpay "); strSql.Append(strWhere); EnGroupOrderPay model = new EnGroupOrderPay(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["grouporderid"] != null && reader["grouporderid"].ToString() != "") { model.grouporderid = int.Parse(reader["grouporderid"].ToString()); } if (reader["grouporderno"] != null && reader["grouporderno"].ToString() != "") { model.grouporderno = reader["grouporderno"].ToString(); } if (reader["paycode"] != null && reader["paycode"].ToString() != "") { model.paycode = reader["paycode"].ToString(); } if (reader["paytype"] != null && reader["paytype"].ToString() != "") { model.paytype = int.Parse(reader["paytype"].ToString()); } if (reader["paymoney"] != null && reader["paymoney"].ToString() != "") { model.paymoney = decimal.Parse(reader["paymoney"].ToString()); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["paystatus"] != null && reader["paystatus"].ToString() != "") { model.paystatus = int.Parse(reader["paystatus"].ToString()); } if (reader["paydatetime"] != null && reader["paydatetime"].ToString() != "") { model.paydatetime = DateTime.Parse(reader["paydatetime"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnGroupOrderPay> GetGroupOrderPayList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnGroupOrderPay> modelList = new List<EnGroupOrderPay>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBGroupOrderPay, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnGroupOrderPay model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnGroupOrderPay(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["grouporderid"] != null && dt.Rows[n]["grouporderid"].ToString() != "") { model.grouporderid = int.Parse(dt.Rows[n]["grouporderid"].ToString()); } if (dt.Rows[n]["grouporderno"] != null && dt.Rows[n]["grouporderno"].ToString() != "") { model.grouporderno = dt.Rows[n]["grouporderno"].ToString(); } if (dt.Rows[n]["paycode"] != null && dt.Rows[n]["paycode"].ToString() != "") { model.paycode = dt.Rows[n]["paycode"].ToString(); } if (dt.Rows[n]["paytype"] != null && dt.Rows[n]["paytype"].ToString() != "") { model.paytype = int.Parse(dt.Rows[n]["paytype"].ToString()); } if (dt.Rows[n]["paymoney"] != null && dt.Rows[n]["paymoney"].ToString() != "") { model.paymoney = decimal.Parse(dt.Rows[n]["paymoney"].ToString()); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["paystatus"] != null && dt.Rows[n]["paystatus"].ToString() != "") { model.paystatus = int.Parse(dt.Rows[n]["paystatus"].ToString()); } if (dt.Rows[n]["paydatetime"] != null && dt.Rows[n]["paydatetime"].ToString() != "") { model.paydatetime = DateTime.Parse(dt.Rows[n]["paydatetime"].ToString()); } modelList.Add(model); } } return modelList; } #endregion #region grouporderproduct /// <summary> /// 更新对像 /// </summary> public static int EditGroupOrderProduct(EnGroupOrderProduct model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_grouporderproduct("); strSql.Append("grouporderid,grouporderno,promotionid,promotiondefid,promoteionstageid,promoteionstagevalue,productid,productattributeid,productcode,productname,color,material,size,cbm,num,price,totalmoney,proprice,prototalmoney)"); strSql.Append(" values ("); strSql.Append("@grouporderid,@grouporderno,@promotionid,@promotiondefid,@promoteionstageid,@promoteionstagevalue,@productid,@productattributeid,@productcode,@productname,@color,@material,@size,@cbm,@num,@price,@totalmoney,@proprice,@prototalmoney)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@grouporderid", SqlDbType.Int,4), new SqlParameter("@grouporderno", SqlDbType.VarChar,20), new SqlParameter("@promotionid", SqlDbType.Int,4), new SqlParameter("@promotiondefid", SqlDbType.Int,4), new SqlParameter("@promoteionstageid", SqlDbType.Int,4), new SqlParameter("@promoteionstagevalue", SqlDbType.VarChar,20), new SqlParameter("@productid", SqlDbType.Int,4), new SqlParameter("@productattributeid", SqlDbType.Int,4), new SqlParameter("@productcode", SqlDbType.VarChar,20), new SqlParameter("@productname", SqlDbType.NVarChar,50), new SqlParameter("@color", SqlDbType.NVarChar,50), new SqlParameter("@material", SqlDbType.NVarChar,50), new SqlParameter("@size", SqlDbType.NVarChar,50), new SqlParameter("@cbm", SqlDbType.Decimal,9), new SqlParameter("@num", SqlDbType.Decimal,9), new SqlParameter("@price", SqlDbType.Decimal,9), new SqlParameter("@totalmoney", SqlDbType.Decimal,9), new SqlParameter("@proprice", SqlDbType.Decimal,9), new SqlParameter("@prototalmoney", SqlDbType.Decimal,9)}; parameters[0].Value = model.grouporderid; parameters[1].Value = model.grouporderno; parameters[2].Value = model.promotionid; parameters[3].Value = model.promotiondefid; parameters[4].Value = model.promoteionstageid; parameters[5].Value = model.promoteionstagevalue; parameters[6].Value = model.productid; parameters[7].Value = model.productattributeid; parameters[8].Value = model.productcode; parameters[9].Value = model.productname; parameters[10].Value = model.color; parameters[11].Value = model.material; parameters[12].Value = model.size; parameters[13].Value = model.cbm; parameters[14].Value = model.num; parameters[15].Value = model.price; parameters[16].Value = model.totalmoney; parameters[17].Value = model.proprice; parameters[18].Value = model.prototalmoney; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_grouporderproduct set "); strSql.Append("grouporderid=@grouporderid,"); strSql.Append("grouporderno=@grouporderno,"); strSql.Append("promotionid=@promotionid,"); strSql.Append("promotiondefid=@promotiondefid,"); strSql.Append("promoteionstageid=@promoteionstageid,"); strSql.Append("promoteionstagevalue=@promoteionstagevalue,"); strSql.Append("productid=@productid,"); strSql.Append("productattributeid=@productattributeid,"); strSql.Append("productcode=@productcode,"); strSql.Append("productname=@productname,"); strSql.Append("color=@color,"); strSql.Append("material=@material,"); strSql.Append("size=@size,"); strSql.Append("cbm=@cbm,"); strSql.Append("num=@num,"); strSql.Append("price=@price,"); strSql.Append("totalmoney=@totalmoney,"); strSql.Append("proprice=@proprice,"); strSql.Append("prototalmoney=@prototalmoney"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@grouporderid", SqlDbType.Int,4), new SqlParameter("@grouporderno", SqlDbType.VarChar,20), new SqlParameter("@promotionid", SqlDbType.Int,4), new SqlParameter("@promotiondefid", SqlDbType.Int,4), new SqlParameter("@promoteionstageid", SqlDbType.Int,4), new SqlParameter("@promoteionstagevalue", SqlDbType.VarChar,20), new SqlParameter("@productid", SqlDbType.Int,4), new SqlParameter("@productattributeid", SqlDbType.Int,4), new SqlParameter("@productcode", SqlDbType.VarChar,20), new SqlParameter("@productname", SqlDbType.NVarChar,50), new SqlParameter("@color", SqlDbType.NVarChar,50), new SqlParameter("@material", SqlDbType.NVarChar,50), new SqlParameter("@size", SqlDbType.NVarChar,50), new SqlParameter("@cbm", SqlDbType.Decimal,9), new SqlParameter("@num", SqlDbType.Decimal,9), new SqlParameter("@price", SqlDbType.Decimal,9), new SqlParameter("@totalmoney", SqlDbType.Decimal,9), new SqlParameter("@proprice", SqlDbType.Decimal,9), new SqlParameter("@prototalmoney", SqlDbType.Decimal,9), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.grouporderid; parameters[1].Value = model.grouporderno; parameters[2].Value = model.promotionid; parameters[3].Value = model.promotiondefid; parameters[4].Value = model.promoteionstageid; parameters[5].Value = model.promoteionstagevalue; parameters[6].Value = model.productid; parameters[7].Value = model.productattributeid; parameters[8].Value = model.productcode; parameters[9].Value = model.productname; parameters[10].Value = model.color; parameters[11].Value = model.material; parameters[12].Value = model.size; parameters[13].Value = model.cbm; parameters[14].Value = model.num; parameters[15].Value = model.price; parameters[16].Value = model.totalmoney; parameters[17].Value = model.proprice; parameters[18].Value = model.prototalmoney; parameters[19].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnGroupOrderProduct GetGroupOrderProductInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_GroupOrderProduct "); strSql.Append(strWhere); EnGroupOrderProduct model = new EnGroupOrderProduct(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["grouporderid"] != null && reader["grouporderid"].ToString() != "") { model.grouporderid = int.Parse(reader["grouporderid"].ToString()); } if (reader["grouporderno"] != null && reader["grouporderno"].ToString() != "") { model.grouporderno = reader["grouporderno"].ToString(); } if (reader["promotionid"] != null && reader["promotionid"].ToString() != "") { model.promotionid = int.Parse(reader["promotionid"].ToString()); } if (reader["promotiondefid"] != null && reader["promotiondefid"].ToString() != "") { model.promotiondefid = int.Parse(reader["promotiondefid"].ToString()); } if (reader["promoteionstageid"] != null && reader["promoteionstageid"].ToString() != "") { model.promoteionstageid = int.Parse(reader["promoteionstageid"].ToString()); } if (reader["promoteionstagevalue"] != null && reader["promoteionstagevalue"].ToString() != "") { model.promoteionstagevalue = reader["promoteionstagevalue"].ToString(); } if (reader["productid"] != null && reader["productid"].ToString() != "") { model.productid = int.Parse(reader["productid"].ToString()); } if (reader["productattributeid"] != null && reader["productattributeid"].ToString() != "") { model.productattributeid = int.Parse(reader["productattributeid"].ToString()); } if (reader["productcode"] != null && reader["productcode"].ToString() != "") { model.productcode = reader["productcode"].ToString(); } if (reader["productname"] != null && reader["productname"].ToString() != "") { model.productname = reader["productname"].ToString(); } if (reader["color"] != null && reader["color"].ToString() != "") { model.color = reader["color"].ToString(); } if (reader["material"] != null && reader["material"].ToString() != "") { model.material = reader["material"].ToString(); } if (reader["size"] != null && reader["size"].ToString() != "") { model.size = reader["size"].ToString(); } if (reader["cbm"] != null && reader["cbm"].ToString() != "") { model.cbm = decimal.Parse(reader["cbm"].ToString()); } if (reader["num"] != null && reader["num"].ToString() != "") { model.num = int.Parse(reader["num"].ToString()); } if (reader["price"] != null && reader["price"].ToString() != "") { model.price = decimal.Parse(reader["price"].ToString()); } if (reader["totalmoney"] != null && reader["totalmoney"].ToString() != "") { model.totalmoney = decimal.Parse(reader["totalmoney"].ToString()); } if (reader["proprice"] != null && reader["proprice"].ToString() != "") { model.proprice = decimal.Parse(reader["proprice"].ToString()); } if (reader["prototalmoney"] != null && reader["prototalmoney"].ToString() != "") { model.prototalmoney = decimal.Parse(reader["prototalmoney"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnGroupOrderProduct> GetGroupOrderProductList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnGroupOrderProduct> modelList = new List<EnGroupOrderProduct>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBGroupOrderProduct, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnGroupOrderProduct model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnGroupOrderProduct(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["grouporderid"] != null && dt.Rows[n]["grouporderid"].ToString() != "") { model.grouporderid = int.Parse(dt.Rows[n]["grouporderid"].ToString()); } if (dt.Rows[n]["grouporderno"] != null && dt.Rows[n]["grouporderno"].ToString() != "") { model.grouporderno = dt.Rows[n]["grouporderno"].ToString(); } if (dt.Rows[n]["promotionid"] != null && dt.Rows[n]["promotionid"].ToString() != "") { model.promotionid = int.Parse(dt.Rows[n]["promotionid"].ToString()); } if (dt.Rows[n]["promotiondefid"] != null && dt.Rows[n]["promotiondefid"].ToString() != "") { model.promotiondefid = int.Parse(dt.Rows[n]["promotiondefid"].ToString()); } if (dt.Rows[n]["promoteionstageid"] != null && dt.Rows[n]["promoteionstageid"].ToString() != "") { model.promoteionstageid = int.Parse(dt.Rows[n]["promoteionstageid"].ToString()); } if (dt.Rows[n]["promoteionstagevalue"] != null && dt.Rows[n]["promoteionstagevalue"].ToString() != "") { model.promoteionstagevalue = dt.Rows[n]["promoteionstagevalue"].ToString(); } if (dt.Rows[n]["productid"] != null && dt.Rows[n]["productid"].ToString() != "") { model.productid = int.Parse(dt.Rows[n]["productid"].ToString()); } if (dt.Rows[n]["productattributeid"] != null && dt.Rows[n]["productattributeid"].ToString() != "") { model.productattributeid = int.Parse(dt.Rows[n]["productattributeid"].ToString()); } if (dt.Rows[n]["productcode"] != null && dt.Rows[n]["productcode"].ToString() != "") { model.productcode = dt.Rows[n]["productcode"].ToString(); } if (dt.Rows[n]["productname"] != null && dt.Rows[n]["productname"].ToString() != "") { model.productname = dt.Rows[n]["productname"].ToString(); } if (dt.Rows[n]["color"] != null && dt.Rows[n]["color"].ToString() != "") { model.color = dt.Rows[n]["color"].ToString(); } if (dt.Rows[n]["material"] != null && dt.Rows[n]["material"].ToString() != "") { model.material = dt.Rows[n]["material"].ToString(); } if (dt.Rows[n]["size"] != null && dt.Rows[n]["size"].ToString() != "") { model.size = dt.Rows[n]["size"].ToString(); } if (dt.Rows[n]["cbm"] != null && dt.Rows[n]["cbm"].ToString() != "") { model.cbm = decimal.Parse(dt.Rows[n]["cbm"].ToString()); } if (dt.Rows[n]["num"] != null && dt.Rows[n]["num"].ToString() != "") { model.num = int.Parse(dt.Rows[n]["num"].ToString()); } if (dt.Rows[n]["price"] != null && dt.Rows[n]["price"].ToString() != "") { model.price = decimal.Parse(dt.Rows[n]["price"].ToString()); } if (dt.Rows[n]["totalmoney"] != null && dt.Rows[n]["totalmoney"].ToString() != "") { model.totalmoney = decimal.Parse(dt.Rows[n]["totalmoney"].ToString()); } if (dt.Rows[n]["proprice"] != null && dt.Rows[n]["proprice"].ToString() != "") { model.proprice = decimal.Parse(dt.Rows[n]["proprice"].ToString()); } if (dt.Rows[n]["prototalmoney"] != null && dt.Rows[n]["prototalmoney"].ToString() != "") { model.prototalmoney = decimal.Parse(dt.Rows[n]["prototalmoney"].ToString()); } modelList.Add(model); } } return modelList; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/GroupOrders.cs
C#
oos
44,669
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class ProductCategorys { /// <summary> /// 更新对像 /// </summary> public static int EditProductCategory(EnProductCategory model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_productcategory("); strSql.Append("title,letter,rewritetitle,parentid,lft,rgt,lev,depth,surface,thumb,bannel,descript,keywords,template,hits,sort,createmid,lastedid,lastedittime,linestatus)"); strSql.Append(" values ("); strSql.Append("@title,@letter,@rewritetitle,@parentid,@lft,@rgt,@lev,@depth,@surface,@thumb,@bannel,@descript,@keywords,@template,@hits,@sort,@createmid,@lastedid,@lastedittime,@linestatus)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@rewritetitle", SqlDbType.VarChar,20), new SqlParameter("@parentid", SqlDbType.Int,4), new SqlParameter("@lft", SqlDbType.Int,4), new SqlParameter("@rgt", SqlDbType.Int,4), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@depth", SqlDbType.VarChar,200), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@linestatus", SqlDbType.Int)}; parameters[0].Value = model.title; parameters[1].Value = model.letter; parameters[2].Value = model.rewritetitle; parameters[3].Value = model.parentid; parameters[4].Value = model.lft; parameters[5].Value = model.rgt; parameters[6].Value = model.lev; parameters[7].Value = model.depth; parameters[8].Value = model.surface; parameters[9].Value = model.thumb; parameters[10].Value = model.bannel; parameters[11].Value = model.descript; parameters[12].Value = model.keywords; parameters[13].Value = model.template; parameters[14].Value = model.hits; parameters[15].Value = model.sort; parameters[16].Value = model.createmid; parameters[17].Value = model.lastedid; parameters[18].Value = model.lastedittime; parameters[19].Value = model.linestatus; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_productcategory set "); strSql.Append("title=@title,"); strSql.Append("letter=@letter,"); strSql.Append("rewritetitle=@rewritetitle,"); strSql.Append("parentid=@parentid,"); strSql.Append("lft=@lft,"); strSql.Append("rgt=@rgt,"); strSql.Append("lev=@lev,"); strSql.Append("depth=@depth,"); strSql.Append("surface=@surface,"); strSql.Append("thumb=@thumb,"); strSql.Append("bannel=@bannel,"); strSql.Append("descript=@descript,"); strSql.Append("keywords=@keywords,"); strSql.Append("template=@template,"); strSql.Append("hits=@hits,"); strSql.Append("sort=@sort,"); strSql.Append("createmid=@createmid,"); strSql.Append("lastedid=@lastedid,"); strSql.Append("lastedittime=@lastedittime,"); strSql.Append("linestatus=@linestatus"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@rewritetitle", SqlDbType.VarChar,20), new SqlParameter("@parentid", SqlDbType.Int,4), new SqlParameter("@lft", SqlDbType.Int,4), new SqlParameter("@rgt", SqlDbType.Int,4), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@depth", SqlDbType.VarChar,200), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@linestatus", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.letter; parameters[2].Value = model.rewritetitle; parameters[3].Value = model.parentid; parameters[4].Value = model.lft; parameters[5].Value = model.rgt; parameters[6].Value = model.lev; parameters[7].Value = model.depth; parameters[8].Value = model.surface; parameters[9].Value = model.thumb; parameters[10].Value = model.bannel; parameters[11].Value = model.descript; parameters[12].Value = model.keywords; parameters[13].Value = model.template; parameters[14].Value = model.hits; parameters[15].Value = model.sort; parameters[16].Value = model.createmid; parameters[17].Value = model.lastedid; parameters[18].Value = model.lastedittime; parameters[19].Value = model.linestatus; parameters[20].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnProductCategory GetProductCategoryInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_ProductCategory "); strSql.Append(strWhere); EnProductCategory model = new EnProductCategory(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["rewritetitle"] != null && reader["rewritetitle"].ToString() != "") { model.rewritetitle = reader["rewritetitle"].ToString(); } if (reader["parentid"] != null && reader["parentid"].ToString() != "") { model.parentid = int.Parse(reader["parentid"].ToString()); } if (reader["lft"] != null && reader["lft"].ToString() != "") { model.lft = int.Parse(reader["lft"].ToString()); } if (reader["rgt"] != null && reader["rgt"].ToString() != "") { model.rgt = int.Parse(reader["rgt"].ToString()); } if (reader["lev"] != null && reader["lev"].ToString() != "") { model.lev = int.Parse(reader["lev"].ToString()); } if (reader["depth"] != null && reader["depth"].ToString() != "") { model.depth = reader["depth"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnProductCategory> GetProductCategoryList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnProductCategory> modelList = new List<EnProductCategory>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBProductCategory, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnProductCategory model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnProductCategory(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["rewritetitle"] != null && dt.Rows[n]["rewritetitle"].ToString() != "") { model.rewritetitle = dt.Rows[n]["rewritetitle"].ToString(); } if (dt.Rows[n]["parentid"] != null && dt.Rows[n]["parentid"].ToString() != "") { model.parentid = int.Parse(dt.Rows[n]["parentid"].ToString()); } if (dt.Rows[n]["lft"] != null && dt.Rows[n]["lft"].ToString() != "") { model.lft = int.Parse(dt.Rows[n]["lft"].ToString()); } if (dt.Rows[n]["rgt"] != null && dt.Rows[n]["rgt"].ToString() != "") { model.rgt = int.Parse(dt.Rows[n]["rgt"].ToString()); } if (dt.Rows[n]["lev"] != null && dt.Rows[n]["lev"].ToString() != "") { model.lev = int.Parse(dt.Rows[n]["lev"].ToString()); } if (dt.Rows[n]["depth"] != null && dt.Rows[n]["depth"].ToString() != "") { model.depth = dt.Rows[n]["depth"].ToString(); } if (dt.Rows[n]["surface"] != null && dt.Rows[n]["surface"].ToString() != "") { model.surface = dt.Rows[n]["surface"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["bannel"] != null && dt.Rows[n]["bannel"].ToString() != "") { model.bannel = dt.Rows[n]["bannel"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["keywords"] != null && dt.Rows[n]["keywords"].ToString() != "") { model.keywords = dt.Rows[n]["keywords"].ToString(); } if (dt.Rows[n]["template"] != null && dt.Rows[n]["template"].ToString() != "") { model.template = dt.Rows[n]["template"].ToString(); } if (dt.Rows[n]["hits"] != null && dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["createmid"] != null && dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } if (dt.Rows[n]["lastedid"] != null && dt.Rows[n]["lastedid"].ToString() != "") { model.lastedid = int.Parse(dt.Rows[n]["lastedid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["linestatus"] != null && dt.Rows[n]["linestatus"].ToString() != "") { model.linestatus = int.Parse(dt.Rows[n]["linestatus"].ToString()); } modelList.Add(model); } } return modelList; } /// <summary> /// 获得数据列表 /// </summary> public static List<EnProductCategory> GetProductCategoryList(string fields,string strWhere) { List<EnProductCategory> modelList = new List<EnProductCategory>(); DataTable dt = DataCommon.GetDataTable(TableName.TBProductCategory, fields, strWhere, " order by lft"); if (dt.Rows.Count > 0) { EnProductCategory model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnProductCategory(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["rewritetitle"] != null && dt.Rows[n]["rewritetitle"].ToString() != "") { model.rewritetitle = dt.Rows[n]["rewritetitle"].ToString(); } if (dt.Rows[n]["parentid"] != null && dt.Rows[n]["parentid"].ToString() != "") { model.parentid = int.Parse(dt.Rows[n]["parentid"].ToString()); } if (dt.Rows[n]["lft"] != null && dt.Rows[n]["lft"].ToString() != "") { model.lft = int.Parse(dt.Rows[n]["lft"].ToString()); } if (dt.Rows[n]["rgt"] != null && dt.Rows[n]["rgt"].ToString() != "") { model.rgt = int.Parse(dt.Rows[n]["rgt"].ToString()); } if (dt.Rows[n]["lev"] != null && dt.Rows[n]["lev"].ToString() != "") { model.lev = int.Parse(dt.Rows[n]["lev"].ToString()); } if (dt.Rows[n]["depth"] != null && dt.Rows[n]["depth"].ToString() != "") { model.depth = dt.Rows[n]["depth"].ToString(); } if (dt.Rows[n]["surface"] != null && dt.Rows[n]["surface"].ToString() != "") { model.surface = dt.Rows[n]["surface"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["bannel"] != null && dt.Rows[n]["bannel"].ToString() != "") { model.bannel = dt.Rows[n]["bannel"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["keywords"] != null && dt.Rows[n]["keywords"].ToString() != "") { model.keywords = dt.Rows[n]["keywords"].ToString(); } if (dt.Rows[n]["template"] != null && dt.Rows[n]["template"].ToString() != "") { model.template = dt.Rows[n]["template"].ToString(); } if (dt.Rows[n]["hits"] != null && dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["createmid"] != null && dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } if (dt.Rows[n]["lastedid"] != null && dt.Rows[n]["lastedid"].ToString() != "") { model.lastedid = int.Parse(dt.Rows[n]["lastedid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["linestatus"] != null && dt.Rows[n]["linestatus"].ToString() != "") { model.linestatus = int.Parse(dt.Rows[n]["linestatus"].ToString()); } modelList.Add(model); } } return modelList; } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/ProductCategorys.cs
C#
oos
23,385
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Members { #region 共公模块 /// <summary> /// 更新对像 /// </summary> public static int EditMember(EnMember model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_member("); strSql.Append("username,password,paypassword,passport,type,groupid,sound,tname,email,gender,mobile,phone,msn,qq,skype,ali,birthdate,areacode,address,department,career,sms,integral,money,bank,account,alipay,regip,regtime,loginip,logintime,logincount,auth,authvalue,authtime,vemail,vmobile,vname,vbank,vcompany,valipay,support,inviter,lastedittime,chat,message)"); strSql.Append(" values ("); strSql.Append("@username,@password,@paypassword,@passport,@type,@groupid,@sound,@tname,@email,@gender,@mobile,@phone,@msn,@qq,@skype,@ali,@birthdate,@areacode,@address,@department,@career,@sms,@integral,@money,@bank,@account,@alipay,@regip,@regtime,@loginip,@logintime,@logincount,@auth,@authvalue,@authtime,@vemail,@vmobile,@vname,@vbank,@vcompany,@valipay,@support,@inviter,@lastedittime,@chat,@message)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@username", SqlDbType.NVarChar,20), new SqlParameter("@password", SqlDbType.VarChar,50), new SqlParameter("@paypassword", SqlDbType.VarChar,40), new SqlParameter("@passport", SqlDbType.VarChar,16), new SqlParameter("@type", SqlDbType.Int,4), new SqlParameter("@groupid", SqlDbType.Int,4), new SqlParameter("@sound", SqlDbType.VarChar,120), new SqlParameter("@tname", SqlDbType.NVarChar,20), new SqlParameter("@email", SqlDbType.VarChar,50), new SqlParameter("@gender", SqlDbType.Int,4), new SqlParameter("@mobile", SqlDbType.VarChar,20), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@msn", SqlDbType.NVarChar,50), new SqlParameter("@qq", SqlDbType.NVarChar,50), new SqlParameter("@skype", SqlDbType.NVarChar,50), new SqlParameter("@ali", SqlDbType.NVarChar,50), new SqlParameter("@birthdate", SqlDbType.DateTime), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,120), new SqlParameter("@department", SqlDbType.NVarChar,20), new SqlParameter("@career", SqlDbType.NVarChar,20), new SqlParameter("@sms", SqlDbType.Decimal,9), new SqlParameter("@integral", SqlDbType.Decimal,9), new SqlParameter("@money", SqlDbType.Decimal,9), new SqlParameter("@bank", SqlDbType.NVarChar,50), new SqlParameter("@account", SqlDbType.NVarChar,50), new SqlParameter("@alipay", SqlDbType.NVarChar,50), new SqlParameter("@regip", SqlDbType.VarChar,50), new SqlParameter("@regtime", SqlDbType.DateTime), new SqlParameter("@loginip", SqlDbType.VarChar,50), new SqlParameter("@logintime", SqlDbType.DateTime), new SqlParameter("@logincount", SqlDbType.Int,4), new SqlParameter("@auth", SqlDbType.VarChar,32), new SqlParameter("@authvalue", SqlDbType.NVarChar,100), new SqlParameter("@authtime", SqlDbType.DateTime), new SqlParameter("@vemail", SqlDbType.Int,4), new SqlParameter("@vmobile", SqlDbType.Int,4), new SqlParameter("@vname", SqlDbType.Int,4), new SqlParameter("@vbank", SqlDbType.Int,4), new SqlParameter("@vcompany", SqlDbType.Int,4), new SqlParameter("@valipay", SqlDbType.Int,4), new SqlParameter("@support", SqlDbType.NVarChar,500), new SqlParameter("@inviter", SqlDbType.NVarChar,20), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@chat", SqlDbType.Int,4), new SqlParameter("@message", SqlDbType.Int,4)}; parameters[0].Value = model.username; parameters[1].Value = model.password; parameters[2].Value = model.paypassword; parameters[3].Value = model.passport; parameters[4].Value = model.type; parameters[5].Value = model.groupid; parameters[6].Value = model.sound; parameters[7].Value = model.tname; parameters[8].Value = model.email; parameters[9].Value = model.gender; parameters[10].Value = model.mobile; parameters[11].Value = model.phone; parameters[12].Value = model.msn; parameters[13].Value = model.qq; parameters[14].Value = model.skype; parameters[15].Value = model.ali; parameters[16].Value = model.birthdate; parameters[17].Value = model.areacode; parameters[18].Value = model.address; parameters[19].Value = model.department; parameters[20].Value = model.career; parameters[21].Value = model.sms; parameters[22].Value = model.integral; parameters[23].Value = model.money; parameters[24].Value = model.bank; parameters[25].Value = model.account; parameters[26].Value = model.alipay; parameters[27].Value = model.regip; parameters[28].Value = model.regtime; parameters[29].Value = model.loginip; parameters[30].Value = model.logintime; parameters[31].Value = model.logincount; parameters[32].Value = model.auth; parameters[33].Value = model.authvalue; parameters[34].Value = model.authtime; parameters[35].Value = model.vemail; parameters[36].Value = model.vmobile; parameters[37].Value = model.vname; parameters[38].Value = model.vbank; parameters[39].Value = model.vcompany; parameters[40].Value = model.valipay; parameters[41].Value = model.support; parameters[42].Value = model.inviter; parameters[43].Value = model.lastedittime; parameters[44].Value = model.chat; parameters[45].Value = model.message; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_member set "); strSql.Append("username=@username,"); strSql.Append("password=@password,"); strSql.Append("paypassword=@paypassword,"); strSql.Append("passport=@passport,"); strSql.Append("type=@type,"); strSql.Append("groupid=@groupid,"); strSql.Append("sound=@sound,"); strSql.Append("tname=@tname,"); strSql.Append("email=@email,"); strSql.Append("gender=@gender,"); strSql.Append("mobile=@mobile,"); strSql.Append("phone=@phone,"); strSql.Append("msn=@msn,"); strSql.Append("qq=@qq,"); strSql.Append("skype=@skype,"); strSql.Append("ali=@ali,"); strSql.Append("birthdate=@birthdate,"); strSql.Append("areacode=@areacode,"); strSql.Append("address=@address,"); strSql.Append("department=@department,"); strSql.Append("career=@career,"); strSql.Append("sms=@sms,"); strSql.Append("integral=@integral,"); strSql.Append("money=@money,"); strSql.Append("bank=@bank,"); strSql.Append("account=@account,"); strSql.Append("alipay=@alipay,"); strSql.Append("regip=@regip,"); strSql.Append("regtime=@regtime,"); strSql.Append("loginip=@loginip,"); strSql.Append("logintime=@logintime,"); strSql.Append("logincount=@logincount,"); strSql.Append("auth=@auth,"); strSql.Append("authvalue=@authvalue,"); strSql.Append("authtime=@authtime,"); strSql.Append("vemail=@vemail,"); strSql.Append("vmobile=@vmobile,"); strSql.Append("vname=@vname,"); strSql.Append("vbank=@vbank,"); strSql.Append("vcompany=@vcompany,"); strSql.Append("valipay=@valipay,"); strSql.Append("support=@support,"); strSql.Append("inviter=@inviter,"); strSql.Append("lastedittime=@lastedittime,"); strSql.Append("chat=@chat,"); strSql.Append("message=@message"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@username", SqlDbType.NVarChar,20), new SqlParameter("@password", SqlDbType.VarChar,50), new SqlParameter("@paypassword", SqlDbType.VarChar,40), new SqlParameter("@passport", SqlDbType.VarChar,16), new SqlParameter("@type", SqlDbType.Int,4), new SqlParameter("@groupid", SqlDbType.Int,4), new SqlParameter("@sound", SqlDbType.VarChar,120), new SqlParameter("@tname", SqlDbType.NVarChar,20), new SqlParameter("@email", SqlDbType.VarChar,50), new SqlParameter("@gender", SqlDbType.Int,4), new SqlParameter("@mobile", SqlDbType.VarChar,20), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@msn", SqlDbType.NVarChar,50), new SqlParameter("@qq", SqlDbType.NVarChar,50), new SqlParameter("@skype", SqlDbType.NVarChar,50), new SqlParameter("@ali", SqlDbType.NVarChar,50), new SqlParameter("@birthdate", SqlDbType.DateTime), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,120), new SqlParameter("@department", SqlDbType.NVarChar,20), new SqlParameter("@career", SqlDbType.NVarChar,20), new SqlParameter("@sms", SqlDbType.Decimal,9), new SqlParameter("@integral", SqlDbType.Decimal,9), new SqlParameter("@money", SqlDbType.Decimal,9), new SqlParameter("@bank", SqlDbType.NVarChar,50), new SqlParameter("@account", SqlDbType.NVarChar,50), new SqlParameter("@alipay", SqlDbType.NVarChar,50), new SqlParameter("@regip", SqlDbType.VarChar,50), new SqlParameter("@regtime", SqlDbType.DateTime), new SqlParameter("@loginip", SqlDbType.VarChar,50), new SqlParameter("@logintime", SqlDbType.DateTime), new SqlParameter("@logincount", SqlDbType.Int,4), new SqlParameter("@auth", SqlDbType.VarChar,32), new SqlParameter("@authvalue", SqlDbType.NVarChar,100), new SqlParameter("@authtime", SqlDbType.DateTime), new SqlParameter("@vemail", SqlDbType.Int,4), new SqlParameter("@vmobile", SqlDbType.Int,4), new SqlParameter("@vname", SqlDbType.Int,4), new SqlParameter("@vbank", SqlDbType.Int,4), new SqlParameter("@vcompany", SqlDbType.Int,4), new SqlParameter("@valipay", SqlDbType.Int,4), new SqlParameter("@support", SqlDbType.NVarChar,500), new SqlParameter("@inviter", SqlDbType.NVarChar,20), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@chat", SqlDbType.Int,4), new SqlParameter("@message", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.username; parameters[1].Value = model.password; parameters[2].Value = model.paypassword; parameters[3].Value = model.passport; parameters[4].Value = model.type; parameters[5].Value = model.groupid; parameters[6].Value = model.sound; parameters[7].Value = model.tname; parameters[8].Value = model.email; parameters[9].Value = model.gender; parameters[10].Value = model.mobile; parameters[11].Value = model.phone; parameters[12].Value = model.msn; parameters[13].Value = model.qq; parameters[14].Value = model.skype; parameters[15].Value = model.ali; parameters[16].Value = model.birthdate; parameters[17].Value = model.areacode; parameters[18].Value = model.address; parameters[19].Value = model.department; parameters[20].Value = model.career; parameters[21].Value = model.sms; parameters[22].Value = model.integral; parameters[23].Value = model.money; parameters[24].Value = model.bank; parameters[25].Value = model.account; parameters[26].Value = model.alipay; parameters[27].Value = model.regip; parameters[28].Value = model.regtime; parameters[29].Value = model.loginip; parameters[30].Value = model.logintime; parameters[31].Value = model.logincount; parameters[32].Value = model.auth; parameters[33].Value = model.authvalue; parameters[34].Value = model.authtime; parameters[35].Value = model.vemail; parameters[36].Value = model.vmobile; parameters[37].Value = model.vname; parameters[38].Value = model.vbank; parameters[39].Value = model.vcompany; parameters[40].Value = model.valipay; parameters[41].Value = model.support; parameters[42].Value = model.inviter; parameters[43].Value = model.lastedittime; parameters[44].Value = model.chat; parameters[45].Value = model.message; parameters[46].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnMember GetMemberInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_member "); strSql.Append(strWhere); EnMember model = new EnMember(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["username"] != null && reader["username"].ToString() != "") { model.username = reader["username"].ToString(); } if (reader["password"] != null && reader["password"].ToString() != "") { model.password = reader["password"].ToString(); } if (reader["paypassword"] != null && reader["paypassword"].ToString() != "") { model.paypassword = reader["paypassword"].ToString(); } if (reader["passport"] != null && reader["passport"].ToString() != "") { model.passport = reader["passport"].ToString(); } if (reader["type"] != null && reader["type"].ToString() != "") { model.type = int.Parse(reader["type"].ToString()); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["sound"] != null && reader["sound"].ToString() != "") { model.sound = reader["sound"].ToString(); } if (reader["tname"] != null && reader["tname"].ToString() != "") { model.tname = reader["tname"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["gender"] != null && reader["gender"].ToString() != "") { model.gender = int.Parse(reader["gender"].ToString()); } if (reader["mobile"] != null && reader["mobile"].ToString() != "") { model.mobile = reader["mobile"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["msn"] != null && reader["msn"].ToString() != "") { model.msn = reader["msn"].ToString(); } if (reader["qq"] != null && reader["qq"].ToString() != "") { model.qq = reader["qq"].ToString(); } if (reader["skype"] != null && reader["skype"].ToString() != "") { model.skype = reader["skype"].ToString(); } if (reader["ali"] != null && reader["ali"].ToString() != "") { model.ali = reader["ali"].ToString(); } if (reader["birthdate"] != null && reader["birthdate"].ToString() != "") { model.birthdate = DateTime.Parse(reader["birthdate"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["department"] != null && reader["department"].ToString() != "") { model.department = reader["department"].ToString(); } if (reader["career"] != null && reader["career"].ToString() != "") { model.career = reader["career"].ToString(); } if (reader["sms"] != null && reader["sms"].ToString() != "") { model.sms = decimal.Parse(reader["sms"].ToString()); } if (reader["integral"] != null && reader["integral"].ToString() != "") { model.integral = decimal.Parse(reader["integral"].ToString()); } if (reader["money"] != null && reader["money"].ToString() != "") { model.money = decimal.Parse(reader["money"].ToString()); } if (reader["bank"] != null && reader["bank"].ToString() != "") { model.bank = reader["bank"].ToString(); } if (reader["account"] != null && reader["account"].ToString() != "") { model.account = reader["account"].ToString(); } if (reader["alipay"] != null && reader["alipay"].ToString() != "") { model.alipay = reader["alipay"].ToString(); } if (reader["regip"] != null && reader["regip"].ToString() != "") { model.regip = reader["regip"].ToString(); } if (reader["regtime"] != null && reader["regtime"].ToString() != "") { model.regtime = DateTime.Parse(reader["regtime"].ToString()); } if (reader["loginip"] != null && reader["loginip"].ToString() != "") { model.loginip = reader["loginip"].ToString(); } if (reader["logintime"] != null && reader["logintime"].ToString() != "") { model.logintime = DateTime.Parse(reader["logintime"].ToString()); } if (reader["logincount"] != null && reader["logincount"].ToString() != "") { model.logincount = int.Parse(reader["logincount"].ToString()); } if (reader["auth"] != null && reader["auth"].ToString() != "") { model.auth = reader["auth"].ToString(); } if (reader["authvalue"] != null && reader["authvalue"].ToString() != "") { model.authvalue = reader["authvalue"].ToString(); } if (reader["authtime"] != null && reader["authtime"].ToString() != "") { model.authtime = DateTime.Parse(reader["authtime"].ToString()); } if (reader["vemail"] != null && reader["vemail"].ToString() != "") { model.vemail = int.Parse(reader["vemail"].ToString()); } if (reader["vmobile"] != null && reader["vmobile"].ToString() != "") { model.vmobile = int.Parse(reader["vmobile"].ToString()); } if (reader["vname"] != null && reader["vname"].ToString() != "") { model.vname = int.Parse(reader["vname"].ToString()); } if (reader["vbank"] != null && reader["vbank"].ToString() != "") { model.vbank = int.Parse(reader["vbank"].ToString()); } if (reader["vcompany"] != null && reader["vcompany"].ToString() != "") { model.vcompany = int.Parse(reader["vcompany"].ToString()); } if (reader["valipay"] != null && reader["valipay"].ToString() != "") { model.valipay = int.Parse(reader["valipay"].ToString()); } if (reader["support"] != null && reader["support"].ToString() != "") { model.support = reader["support"].ToString(); } if (reader["inviter"] != null && reader["inviter"].ToString() != "") { model.inviter = reader["inviter"].ToString(); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["chat"] != null && reader["chat"].ToString() != "") { model.chat = int.Parse(reader["chat"].ToString()); } if (reader["message"] != null && reader["message"].ToString() != "") { model.message = int.Parse(reader["message"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnMember> GetMemberList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnMember> modelList = new List<EnMember>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBMember, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnMember model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnMember(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["username"] != null && dt.Rows[n]["username"].ToString() != "") { model.username = dt.Rows[n]["username"].ToString(); } if (dt.Rows[n]["password"] != null && dt.Rows[n]["password"].ToString() != "") { model.password = dt.Rows[n]["password"].ToString(); } if (dt.Rows[n]["paypassword"] != null && dt.Rows[n]["paypassword"].ToString() != "") { model.paypassword = dt.Rows[n]["paypassword"].ToString(); } if (dt.Rows[n]["passport"] != null && dt.Rows[n]["passport"].ToString() != "") { model.passport = dt.Rows[n]["passport"].ToString(); } if (dt.Rows[n]["type"] != null && dt.Rows[n]["type"].ToString() != "") { model.type = int.Parse(dt.Rows[n]["type"].ToString()); } if (dt.Rows[n]["groupid"] != null && dt.Rows[n]["groupid"].ToString() != "") { model.groupid = int.Parse(dt.Rows[n]["groupid"].ToString()); } if (dt.Rows[n]["sound"] != null && dt.Rows[n]["sound"].ToString() != "") { model.sound = dt.Rows[n]["sound"].ToString(); } if (dt.Rows[n]["tname"] != null && dt.Rows[n]["tname"].ToString() != "") { model.tname = dt.Rows[n]["tname"].ToString(); } if (dt.Rows[n]["email"] != null && dt.Rows[n]["email"].ToString() != "") { model.email = dt.Rows[n]["email"].ToString(); } if (dt.Rows[n]["gender"] != null && dt.Rows[n]["gender"].ToString() != "") { model.gender = int.Parse(dt.Rows[n]["gender"].ToString()); } if (dt.Rows[n]["mobile"] != null && dt.Rows[n]["mobile"].ToString() != "") { model.mobile = dt.Rows[n]["mobile"].ToString(); } if (dt.Rows[n]["phone"] != null && dt.Rows[n]["phone"].ToString() != "") { model.phone = dt.Rows[n]["phone"].ToString(); } if (dt.Rows[n]["msn"] != null && dt.Rows[n]["msn"].ToString() != "") { model.msn = dt.Rows[n]["msn"].ToString(); } if (dt.Rows[n]["qq"] != null && dt.Rows[n]["qq"].ToString() != "") { model.qq = dt.Rows[n]["qq"].ToString(); } if (dt.Rows[n]["skype"] != null && dt.Rows[n]["skype"].ToString() != "") { model.skype = dt.Rows[n]["skype"].ToString(); } if (dt.Rows[n]["ali"] != null && dt.Rows[n]["ali"].ToString() != "") { model.ali = dt.Rows[n]["ali"].ToString(); } if (dt.Rows[n]["birthdate"] != null && dt.Rows[n]["birthdate"].ToString() != "") { model.birthdate = DateTime.Parse(dt.Rows[n]["birthdate"].ToString()); } if (dt.Rows[n]["areacode"] != null && dt.Rows[n]["areacode"].ToString() != "") { model.areacode = dt.Rows[n]["areacode"].ToString(); } if (dt.Rows[n]["address"] != null && dt.Rows[n]["address"].ToString() != "") { model.address = dt.Rows[n]["address"].ToString(); } if (dt.Rows[n]["department"] != null && dt.Rows[n]["department"].ToString() != "") { model.department = dt.Rows[n]["department"].ToString(); } if (dt.Rows[n]["career"] != null && dt.Rows[n]["career"].ToString() != "") { model.career = dt.Rows[n]["career"].ToString(); } if (dt.Rows[n]["sms"] != null && dt.Rows[n]["sms"].ToString() != "") { model.sms = decimal.Parse(dt.Rows[n]["sms"].ToString()); } if (dt.Rows[n]["integral"] != null && dt.Rows[n]["integral"].ToString() != "") { model.integral = decimal.Parse(dt.Rows[n]["integral"].ToString()); } if (dt.Rows[n]["money"] != null && dt.Rows[n]["money"].ToString() != "") { model.money = decimal.Parse(dt.Rows[n]["money"].ToString()); } if (dt.Rows[n]["bank"] != null && dt.Rows[n]["bank"].ToString() != "") { model.bank = dt.Rows[n]["bank"].ToString(); } if (dt.Rows[n]["account"] != null && dt.Rows[n]["account"].ToString() != "") { model.account = dt.Rows[n]["account"].ToString(); } if (dt.Rows[n]["alipay"] != null && dt.Rows[n]["alipay"].ToString() != "") { model.alipay = dt.Rows[n]["alipay"].ToString(); } if (dt.Rows[n]["regip"] != null && dt.Rows[n]["regip"].ToString() != "") { model.regip = dt.Rows[n]["regip"].ToString(); } if (dt.Rows[n]["regtime"] != null && dt.Rows[n]["regtime"].ToString() != "") { model.regtime = DateTime.Parse(dt.Rows[n]["regtime"].ToString()); } if (dt.Rows[n]["loginip"] != null && dt.Rows[n]["loginip"].ToString() != "") { model.loginip = dt.Rows[n]["loginip"].ToString(); } if (dt.Rows[n]["logintime"] != null && dt.Rows[n]["logintime"].ToString() != "") { model.logintime = DateTime.Parse(dt.Rows[n]["logintime"].ToString()); } if (dt.Rows[n]["logincount"] != null && dt.Rows[n]["logincount"].ToString() != "") { model.logincount = int.Parse(dt.Rows[n]["logincount"].ToString()); } if (dt.Rows[n]["auth"] != null && dt.Rows[n]["auth"].ToString() != "") { model.auth = dt.Rows[n]["auth"].ToString(); } if (dt.Rows[n]["authvalue"] != null && dt.Rows[n]["authvalue"].ToString() != "") { model.authvalue = dt.Rows[n]["authvalue"].ToString(); } if (dt.Rows[n]["authtime"] != null && dt.Rows[n]["authtime"].ToString() != "") { model.authtime = DateTime.Parse(dt.Rows[n]["authtime"].ToString()); } if (dt.Rows[n]["vemail"] != null && dt.Rows[n]["vemail"].ToString() != "") { model.vemail = int.Parse(dt.Rows[n]["vemail"].ToString()); } if (dt.Rows[n]["vmobile"] != null && dt.Rows[n]["vmobile"].ToString() != "") { model.vmobile = int.Parse(dt.Rows[n]["vmobile"].ToString()); } if (dt.Rows[n]["vname"] != null && dt.Rows[n]["vname"].ToString() != "") { model.vname = int.Parse(dt.Rows[n]["vname"].ToString()); } if (dt.Rows[n]["vbank"] != null && dt.Rows[n]["vbank"].ToString() != "") { model.vbank = int.Parse(dt.Rows[n]["vbank"].ToString()); } if (dt.Rows[n]["vcompany"] != null && dt.Rows[n]["vcompany"].ToString() != "") { model.vcompany = int.Parse(dt.Rows[n]["vcompany"].ToString()); } if (dt.Rows[n]["valipay"] != null && dt.Rows[n]["valipay"].ToString() != "") { model.valipay = int.Parse(dt.Rows[n]["valipay"].ToString()); } if (dt.Rows[n]["support"] != null && dt.Rows[n]["support"].ToString() != "") { model.support = dt.Rows[n]["support"].ToString(); } if (dt.Rows[n]["inviter"] != null && dt.Rows[n]["inviter"].ToString() != "") { model.inviter = dt.Rows[n]["inviter"].ToString(); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["chat"] != null && dt.Rows[n]["chat"].ToString() != "") { model.chat = int.Parse(dt.Rows[n]["chat"].ToString()); } if (dt.Rows[n]["message"] != null && dt.Rows[n]["message"].ToString() != "") { model.message = int.Parse(dt.Rows[n]["message"].ToString()); } modelList.Add(model); } } return modelList; } public static List<EnMember> GetMemberList(string filed,string strWhere,string sort) { List<EnMember> modelList = new List<EnMember>(); DataTable dt=DataCommon.GetDataTable(TableName.TBMember, filed, strWhere, sort); if (dt.Rows.Count > 0) { EnMember model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnMember(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["username"] != null && dt.Rows[n]["username"].ToString() != "") { model.username = dt.Rows[n]["username"].ToString(); } if (dt.Rows[n]["password"] != null && dt.Rows[n]["password"].ToString() != "") { model.password = dt.Rows[n]["password"].ToString(); } if (dt.Rows[n]["paypassword"] != null && dt.Rows[n]["paypassword"].ToString() != "") { model.paypassword = dt.Rows[n]["paypassword"].ToString(); } if (dt.Rows[n]["passport"] != null && dt.Rows[n]["passport"].ToString() != "") { model.passport = dt.Rows[n]["passport"].ToString(); } if (dt.Rows[n]["type"] != null && dt.Rows[n]["type"].ToString() != "") { model.type = int.Parse(dt.Rows[n]["type"].ToString()); } if (dt.Rows[n]["groupid"] != null && dt.Rows[n]["groupid"].ToString() != "") { model.groupid = int.Parse(dt.Rows[n]["groupid"].ToString()); } if (dt.Rows[n]["sound"] != null && dt.Rows[n]["sound"].ToString() != "") { model.sound = dt.Rows[n]["sound"].ToString(); } if (dt.Rows[n]["tname"] != null && dt.Rows[n]["tname"].ToString() != "") { model.tname = dt.Rows[n]["tname"].ToString(); } if (dt.Rows[n]["email"] != null && dt.Rows[n]["email"].ToString() != "") { model.email = dt.Rows[n]["email"].ToString(); } if (dt.Rows[n]["gender"] != null && dt.Rows[n]["gender"].ToString() != "") { model.gender = int.Parse(dt.Rows[n]["gender"].ToString()); } if (dt.Rows[n]["mobile"] != null && dt.Rows[n]["mobile"].ToString() != "") { model.mobile = dt.Rows[n]["mobile"].ToString(); } if (dt.Rows[n]["phone"] != null && dt.Rows[n]["phone"].ToString() != "") { model.phone = dt.Rows[n]["phone"].ToString(); } if (dt.Rows[n]["msn"] != null && dt.Rows[n]["msn"].ToString() != "") { model.msn = dt.Rows[n]["msn"].ToString(); } if (dt.Rows[n]["qq"] != null && dt.Rows[n]["qq"].ToString() != "") { model.qq = dt.Rows[n]["qq"].ToString(); } if (dt.Rows[n]["skype"] != null && dt.Rows[n]["skype"].ToString() != "") { model.skype = dt.Rows[n]["skype"].ToString(); } if (dt.Rows[n]["ali"] != null && dt.Rows[n]["ali"].ToString() != "") { model.ali = dt.Rows[n]["ali"].ToString(); } if (dt.Rows[n]["birthdate"] != null && dt.Rows[n]["birthdate"].ToString() != "") { model.birthdate = DateTime.Parse(dt.Rows[n]["birthdate"].ToString()); } if (dt.Rows[n]["areacode"] != null && dt.Rows[n]["areacode"].ToString() != "") { model.areacode = dt.Rows[n]["areacode"].ToString(); } if (dt.Rows[n]["address"] != null && dt.Rows[n]["address"].ToString() != "") { model.address = dt.Rows[n]["address"].ToString(); } if (dt.Rows[n]["department"] != null && dt.Rows[n]["department"].ToString() != "") { model.department = dt.Rows[n]["department"].ToString(); } if (dt.Rows[n]["career"] != null && dt.Rows[n]["career"].ToString() != "") { model.career = dt.Rows[n]["career"].ToString(); } if (dt.Rows[n]["sms"] != null && dt.Rows[n]["sms"].ToString() != "") { model.sms = decimal.Parse(dt.Rows[n]["sms"].ToString()); } if (dt.Rows[n]["integral"] != null && dt.Rows[n]["integral"].ToString() != "") { model.integral = decimal.Parse(dt.Rows[n]["integral"].ToString()); } if (dt.Rows[n]["money"] != null && dt.Rows[n]["money"].ToString() != "") { model.money = decimal.Parse(dt.Rows[n]["money"].ToString()); } if (dt.Rows[n]["bank"] != null && dt.Rows[n]["bank"].ToString() != "") { model.bank = dt.Rows[n]["bank"].ToString(); } if (dt.Rows[n]["account"] != null && dt.Rows[n]["account"].ToString() != "") { model.account = dt.Rows[n]["account"].ToString(); } if (dt.Rows[n]["alipay"] != null && dt.Rows[n]["alipay"].ToString() != "") { model.alipay = dt.Rows[n]["alipay"].ToString(); } if (dt.Rows[n]["regip"] != null && dt.Rows[n]["regip"].ToString() != "") { model.regip = dt.Rows[n]["regip"].ToString(); } if (dt.Rows[n]["regtime"] != null && dt.Rows[n]["regtime"].ToString() != "") { model.regtime = DateTime.Parse(dt.Rows[n]["regtime"].ToString()); } if (dt.Rows[n]["loginip"] != null && dt.Rows[n]["loginip"].ToString() != "") { model.loginip = dt.Rows[n]["loginip"].ToString(); } if (dt.Rows[n]["logintime"] != null && dt.Rows[n]["logintime"].ToString() != "") { model.logintime = DateTime.Parse(dt.Rows[n]["logintime"].ToString()); } if (dt.Rows[n]["logincount"] != null && dt.Rows[n]["logincount"].ToString() != "") { model.logincount = int.Parse(dt.Rows[n]["logincount"].ToString()); } if (dt.Rows[n]["auth"] != null && dt.Rows[n]["auth"].ToString() != "") { model.auth = dt.Rows[n]["auth"].ToString(); } if (dt.Rows[n]["authvalue"] != null && dt.Rows[n]["authvalue"].ToString() != "") { model.authvalue = dt.Rows[n]["authvalue"].ToString(); } if (dt.Rows[n]["authtime"] != null && dt.Rows[n]["authtime"].ToString() != "") { model.authtime = DateTime.Parse(dt.Rows[n]["authtime"].ToString()); } if (dt.Rows[n]["vemail"] != null && dt.Rows[n]["vemail"].ToString() != "") { model.vemail = int.Parse(dt.Rows[n]["vemail"].ToString()); } if (dt.Rows[n]["vmobile"] != null && dt.Rows[n]["vmobile"].ToString() != "") { model.vmobile = int.Parse(dt.Rows[n]["vmobile"].ToString()); } if (dt.Rows[n]["vname"] != null && dt.Rows[n]["vname"].ToString() != "") { model.vname = int.Parse(dt.Rows[n]["vname"].ToString()); } if (dt.Rows[n]["vbank"] != null && dt.Rows[n]["vbank"].ToString() != "") { model.vbank = int.Parse(dt.Rows[n]["vbank"].ToString()); } if (dt.Rows[n]["vcompany"] != null && dt.Rows[n]["vcompany"].ToString() != "") { model.vcompany = int.Parse(dt.Rows[n]["vcompany"].ToString()); } if (dt.Rows[n]["valipay"] != null && dt.Rows[n]["valipay"].ToString() != "") { model.valipay = int.Parse(dt.Rows[n]["valipay"].ToString()); } if (dt.Rows[n]["support"] != null && dt.Rows[n]["support"].ToString() != "") { model.support = dt.Rows[n]["support"].ToString(); } if (dt.Rows[n]["inviter"] != null && dt.Rows[n]["inviter"].ToString() != "") { model.inviter = dt.Rows[n]["inviter"].ToString(); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["chat"] != null && dt.Rows[n]["chat"].ToString() != "") { model.chat = int.Parse(dt.Rows[n]["chat"].ToString()); } if (dt.Rows[n]["message"] != null && dt.Rows[n]["message"].ToString() != "") { model.message = int.Parse(dt.Rows[n]["message"].ToString()); } modelList.Add(model); } } return modelList; } #endregion #region 共公模块-组 /// <summary> /// 更新对像 /// </summary> public static int EditMemberGroup(EnMemberGroup model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_membergroup("); strSql.Append("title,color,avatar,integral,money,permissions,lev,descript,sort)"); strSql.Append(" values ("); strSql.Append("@title,@color,@avatar,@integral,@money,@permissions,@lev,@descript,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@color", SqlDbType.Char,7), new SqlParameter("@avatar", SqlDbType.VarChar,40), new SqlParameter("@integral", SqlDbType.Decimal,9), new SqlParameter("@money", SqlDbType.Decimal,9), new SqlParameter("@permissions", SqlDbType.NText), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.color; parameters[2].Value = model.avatar; parameters[3].Value = model.integral; parameters[4].Value = model.money; parameters[5].Value = model.permissions; parameters[6].Value = model.lev; parameters[7].Value = model.descript; parameters[8].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_membergroup set "); strSql.Append("title=@title,"); strSql.Append("color=@color,"); strSql.Append("avatar=@avatar,"); strSql.Append("integral=@integral,"); strSql.Append("money=@money,"); strSql.Append("permissions=@permissions,"); strSql.Append("lev=@lev,"); strSql.Append("descript=@descript,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@color", SqlDbType.Char,7), new SqlParameter("@avatar", SqlDbType.VarChar,40), new SqlParameter("@integral", SqlDbType.Decimal,9), new SqlParameter("@money", SqlDbType.Decimal,9), new SqlParameter("@permissions", SqlDbType.NText), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.color; parameters[2].Value = model.avatar; parameters[3].Value = model.integral; parameters[4].Value = model.money; parameters[5].Value = model.permissions; parameters[6].Value = model.lev; parameters[7].Value = model.descript; parameters[8].Value = model.sort; parameters[9].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnMemberGroup GetMemberGroupInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_MemberGroup "); strSql.Append(strWhere); EnMemberGroup model = new EnMemberGroup(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["color"] != null && reader["color"].ToString() != "") { model.color = reader["color"].ToString(); } if (reader["avatar"] != null && reader["avatar"].ToString() != "") { model.avatar = reader["avatar"].ToString(); } if (reader["integral"] != null && reader["integral"].ToString() != "") { model.integral = decimal.Parse(reader["integral"].ToString()); } if (reader["money"] != null && reader["money"].ToString() != "") { model.money = decimal.Parse(reader["money"].ToString()); } if (reader["permissions"] != null && reader["permissions"].ToString() != "") { model.permissions = reader["permissions"].ToString(); } if (reader["lev"] != null && reader["lev"].ToString() != "") { model.lev = int.Parse(reader["lev"].ToString()); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnMemberGroup> GetMemberGroupList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnMemberGroup> modelList = new List<EnMemberGroup>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBMemberGroup, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnMemberGroup model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnMemberGroup(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["color"] != null && dt.Rows[n]["color"].ToString() != "") { model.color = dt.Rows[n]["color"].ToString(); } if (dt.Rows[n]["avatar"] != null && dt.Rows[n]["avatar"].ToString() != "") { model.avatar = dt.Rows[n]["avatar"].ToString(); } if (dt.Rows[n]["integral"] != null && dt.Rows[n]["integral"].ToString() != "") { model.integral = decimal.Parse(dt.Rows[n]["integral"].ToString()); } if (dt.Rows[n]["money"] != null && dt.Rows[n]["money"].ToString() != "") { model.money = decimal.Parse(dt.Rows[n]["money"].ToString()); } if (dt.Rows[n]["permissions"] != null && dt.Rows[n]["permissions"].ToString() != "") { model.permissions = dt.Rows[n]["permissions"].ToString(); } if (dt.Rows[n]["lev"] != null && dt.Rows[n]["lev"].ToString() != "") { model.lev = int.Parse(dt.Rows[n]["lev"].ToString()); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Members.cs
C#
oos
57,053
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Shops { public static int ExitShopTitle(string title) { SqlParameter[] parames = { new SqlParameter("@title", SqlDbType.VarChar, 30)}; parames[0].Value = title; return DataCommon.Exists(TableName.TBShop, " where title=@title", parames); } //店铺列表 public static EnWebShop GetWebShopInfo(string strWhere) { EnWebShop model = new EnWebShop(); IDataReader reader = DataCommon.GetDataIReader(TableName.TVShopList, "", strWhere, ""); while (reader.Read()) { if (reader["brandxml"] != null && reader["brandxml"].ToString() != "") { model.brandxml = reader["brandxml"].ToString(); } if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["productcount"] != null && reader["productcount"].ToString() != "") { model.productcount = int.Parse(reader["productcount"].ToString()); } if (reader["mid"] != null && reader["mid"].ToString() != "") { model.mid = int.Parse(reader["mid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["industry"] != null && reader["industry"].ToString() != "") { model.industry = reader["industry"].ToString(); } if (reader["productcategory"] != null && reader["productcategory"].ToString() != "") { model.productcategory = reader["productcategory"].ToString(); } if (reader["vip"] != null && reader["vip"].ToString() != "") { model.vip = int.Parse(reader["vip"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["mapapi"] != null && reader["mapapi"].ToString() != "") { model.mapapi = reader["mapapi"].ToString(); } if (reader["staffsize"] != null && reader["staffsize"].ToString() != "") { model.staffsize = int.Parse(reader["staffsize"].ToString()); } if (reader["regyear"] != null && reader["regyear"].ToString() != "") { model.regyear = reader["regyear"].ToString(); } if (reader["regcity"] != null && reader["regcity"].ToString() != "") { model.regcity = reader["regcity"].ToString(); } if (reader["buy"] != null && reader["buy"].ToString() != "") { model.buy = reader["buy"].ToString(); } if (reader["sell"] != null && reader["sell"].ToString() != "") { model.sell = reader["sell"].ToString(); } if (reader["linkman"] != null && reader["linkman"].ToString() != "") { model.linkman = reader["linkman"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["mphone"] != null && reader["mphone"].ToString() != "") { model.mphone = reader["mphone"].ToString(); } if (reader["fax"] != null && reader["fax"].ToString() != "") { model.fax = reader["fax"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["postcode"] != null && reader["postcode"].ToString() != "") { model.postcode = reader["postcode"].ToString(); } if (reader["homepage"] != null && reader["homepage"].ToString() != "") { model.homepage = reader["homepage"].ToString(); } if (reader["domain"] != null && reader["domain"].ToString() != "") { model.domain = reader["domain"].ToString(); } if (reader["domainip"] != null && reader["domainip"].ToString() != "") { model.domainip = reader["domainip"].ToString(); } if (reader["icp"] != null && reader["icp"].ToString() != "") { model.icp = reader["icp"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["marketid"] != null && reader["marketid"].ToString() != "") { model.marketid = int.Parse(reader["marketid"].ToString()); } if (reader["marketname"] != null && reader["marketname"].ToString() != "") { model.marketname = reader["marketname"].ToString(); } if (reader["cid"] != null && reader["cid"].ToString() != "") { model.cid = int.Parse(reader["cid"].ToString()); } if (reader["ctype"] != null && reader["ctype"].ToString() != "") { model.ctype = int.Parse(reader["ctype"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } } return model; } //店铺列表 public static List<EnWebShop> GetWebShopList(int PageIndex, int PageSize, string strWhere, string sortkey, string ordertype, out int pageCount) { List<EnWebShop> list = new List<EnWebShop>(); IDataReader reader = DataCommon.GetPageDataReader(TableName.TVShopList, PageIndex, PageSize, strWhere, sortkey, ordertype, out pageCount); while (reader.Read()) { EnWebShop model = new EnWebShop(); if (reader["brandxml"] != null && reader["brandxml"].ToString() != "") { model.brandxml = reader["brandxml"].ToString(); } if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["productcount"] != null && reader["productcount"].ToString() != "") { model.productcount = int.Parse(reader["productcount"].ToString()); } if (reader["mid"] != null && reader["mid"].ToString() != "") { model.mid = int.Parse(reader["mid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["industry"] != null && reader["industry"].ToString() != "") { model.industry = reader["industry"].ToString(); } if (reader["productcategory"] != null && reader["productcategory"].ToString() != "") { model.productcategory = reader["productcategory"].ToString(); } if (reader["vip"] != null && reader["vip"].ToString() != "") { model.vip = int.Parse(reader["vip"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["mapapi"] != null && reader["mapapi"].ToString() != "") { model.mapapi = reader["mapapi"].ToString(); } if (reader["staffsize"] != null && reader["staffsize"].ToString() != "") { model.staffsize = int.Parse(reader["staffsize"].ToString()); } if (reader["regyear"] != null && reader["regyear"].ToString() != "") { model.regyear = reader["regyear"].ToString(); } if (reader["regcity"] != null && reader["regcity"].ToString() != "") { model.regcity = reader["regcity"].ToString(); } if (reader["buy"] != null && reader["buy"].ToString() != "") { model.buy = reader["buy"].ToString(); } if (reader["sell"] != null && reader["sell"].ToString() != "") { model.sell = reader["sell"].ToString(); } if (reader["linkman"] != null && reader["linkman"].ToString() != "") { model.linkman = reader["linkman"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["mphone"] != null && reader["mphone"].ToString() != "") { model.mphone = reader["mphone"].ToString(); } if (reader["fax"] != null && reader["fax"].ToString() != "") { model.fax = reader["fax"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["postcode"] != null && reader["postcode"].ToString() != "") { model.postcode = reader["postcode"].ToString(); } if (reader["homepage"] != null && reader["homepage"].ToString() != "") { model.homepage = reader["homepage"].ToString(); } if (reader["domain"] != null && reader["domain"].ToString() != "") { model.domain = reader["domain"].ToString(); } if (reader["domainip"] != null && reader["domainip"].ToString() != "") { model.domainip = reader["domainip"].ToString(); } if (reader["icp"] != null && reader["icp"].ToString() != "") { model.icp = reader["icp"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["marketid"] != null && reader["marketid"].ToString() != "") { model.marketid = int.Parse(reader["marketid"].ToString()); } if (reader["marketname"] != null && reader["marketname"].ToString() != "") { model.marketname = reader["marketname"].ToString(); } if (reader["cid"] != null && reader["cid"].ToString() != "") { model.cid = int.Parse(reader["cid"].ToString()); } if (reader["ctype"] != null && reader["ctype"].ToString() != "") { model.ctype = int.Parse(reader["ctype"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } list.Add(model); } return list; } //品牌店铺 public static List<EnWebShopBrand> GetWebShopBrandList(int PageIndex, int PageSize, string strWhere,string sortkey,string ordertype, out int pageCount) { List<EnWebShopBrand> list = new List<EnWebShopBrand>(); IDataReader reader = DataCommon.GetPageDataReader(TableName.TVShopBrandList, PageIndex, PageSize, strWhere, sortkey, ordertype, out pageCount); while (reader.Read()) { EnWebShopBrand model = new EnWebShopBrand(); if (reader["shopxml"] != null && reader["shopxml"].ToString() != "") { model.shopxml = reader["shopxml"].ToString(); } if (reader["Promotionxml"] != null && reader["Promotionxml"].ToString() != "") { model.Promotionxml = reader["Promotionxml"].ToString(); } if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["companyid"] != null && reader["companyid"].ToString() != "") { model.companyid = int.Parse(reader["companyid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["productcategory"] != null && reader["productcategory"].ToString() != "") { model.productcategory = reader["productcategory"].ToString(); } if (reader["homepage"] != null && reader["homepage"].ToString() != "") { model.homepage = reader["homepage"].ToString(); } if (reader["productcount"] != null && reader["productcount"].ToString() != "") { model.productcount = int.Parse(reader["productcount"].ToString()); } if (reader["spread"] != null && reader["spread"].ToString() != "") { model.spread = reader["spread"].ToString(); } if (reader["material"] != null && reader["material"].ToString() != "") { model.material = reader["material"].ToString(); } if (reader["style"] != null && reader["style"].ToString() != "") { model.style = reader["style"].ToString(); } if (reader["color"] != null && reader["color"].ToString() != "") { model.color = reader["color"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lasteditid"] != null && reader["lasteditid"].ToString() != "") { model.lasteditid = int.Parse(reader["lasteditid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } list.Add(model); } return list; } //店铺搜索选项 public static List<EnSearchItem> GetShopSearchItem() { List<EnSearchItem> list = new List<EnSearchItem>(); IDataReader reader = DbHelper.ExecuteReader(" select * from " + TableName.TVShopSearchItem); while (reader.Read()) { EnSearchItem model = new EnSearchItem(); if (reader["t"] != null && reader["t"].ToString() != "") { model.type = reader["t"].ToString(); } if (reader["v"] != null && reader["v"].ToString() != "") { model.value = reader["v"].ToString(); } if (reader["n"] != null && reader["n"].ToString() != "") { model.title = reader["n"].ToString(); } if (reader["c"] != null && reader["c"].ToString() != "") { model.count = int.Parse(reader["c"].ToString()); } model.isCur = false; list.Add(model); } return list; } #region 店铺品牌 /// <summary> /// 更新对像 /// </summary> public static int EditShopBrand(List<EnShopBrand> list) { List<CommandInfo> cmdList=new List<CommandInfo>(); //更新前删除 CommandInfo delShopBrand=new CommandInfo(); delShopBrand.CommandText="delete from t_shopbrand where shopid="+list[0].shopid; delShopBrand.EffentNextType=EffentNextType.None; cmdList.Add(delShopBrand); foreach (EnShopBrand sb in list) { if (sb.brandid != 0) { CommandInfo model = new CommandInfo(); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_shopbrand("); strSql.Append("shopid,brandid)"); strSql.Append(" values ("); strSql.Append("@shopid,@brandid)"); SqlParameter[] parameters = { new SqlParameter("@shopid", SqlDbType.Int,4), new SqlParameter("@brandid", SqlDbType.Int,4)}; parameters[0].Value = sb.shopid; parameters[1].Value = sb.brandid; model.CommandText = strSql.ToString(); model.Parameters = parameters; model.EffentNextType = EffentNextType.ExcuteEffectRows; cmdList.Add(model); } } return DbHelper.ExecuteSqlTran(cmdList); } /// <summary> /// 获得数据列表 /// </summary> public static List<EnShopBrand> GetShopBrandList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnShopBrand> modelList = new List<EnShopBrand>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBShopBrand, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnShopBrand model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnShopBrand(); if (dt.Rows[n]["shopid"] != null && dt.Rows[n]["shopid"].ToString() != "") { model.shopid = int.Parse(dt.Rows[n]["shopid"].ToString()); } if (dt.Rows[n]["brandid"] != null && dt.Rows[n]["brandid"].ToString() != "") { model.brandid = int.Parse(dt.Rows[n]["brandid"].ToString()); } modelList.Add(model); } } return modelList; } /// <summary> /// 获得数据列表 /// </summary> public static List<EnShopBrand> GetShopBrandList( string strWhere) { List<EnShopBrand> modelList = new List<EnShopBrand>(); IDataReader reader = DbHelper.ExecuteReader(" select * from " + TableName.TBShopBrand + " " + strWhere); while (reader.Read()) { EnShopBrand model = new EnShopBrand(); if (reader["shopid"] != null && reader["shopid"].ToString() != "") { model.shopid = int.Parse(reader["shopid"].ToString()); } if (reader["brandid"] != null && reader["brandid"].ToString() != "") { model.brandid = int.Parse(reader["brandid"].ToString()); } modelList.Add(model); } return modelList; } #endregion #region 共公模块 /// <summary> /// 更新对像 /// </summary> public static int EditShop(EnShop model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_shop("); strSql.Append("mid,title,letter,groupid,attribute,industry,productcategory,vip,areacode,address,mapapi,staffsize,regyear,regcity,buy,sell,linkman,phone,mphone,fax,email,postcode,homepage,domain,domainip,icp,surface,logo,thumb,bannel,desimage,descript,keywords,template,hits,sort,marketid,cid,ctype,createmid,lastedid,lastedittime,auditstatus,linestatus)"); strSql.Append(" values ("); strSql.Append("@mid,@title,@letter,@groupid,@attribute,@industry,@productcategory,@vip,@areacode,@address,@mapapi,@staffsize,@regyear,@regcity,@buy,@sell,@linkman,@phone,@mphone,@fax,@email,@postcode,@homepage,@domain,@domainip,@icp,@surface,@logo,@thumb,@bannel,@desimage,@descript,@keywords,@template,@hits,@sort,@marketid,@cid,@ctype,@createmid,@lastedid,@lastedittime,@auditstatus,@linestatus)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@mid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@groupid", SqlDbType.Int,4), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@industry", SqlDbType.VarChar,50), new SqlParameter("@productcategory", SqlDbType.VarChar,50), new SqlParameter("@vip", SqlDbType.Int,4), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,60), new SqlParameter("@mapapi", SqlDbType.NVarChar,80), new SqlParameter("@staffsize", SqlDbType.Int,4), new SqlParameter("@regyear", SqlDbType.VarChar,7), new SqlParameter("@regcity", SqlDbType.VarChar,10), new SqlParameter("@buy", SqlDbType.NVarChar,300), new SqlParameter("@sell", SqlDbType.NVarChar,300), new SqlParameter("@linkman", SqlDbType.NVarChar,20), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@mphone", SqlDbType.VarChar,20), new SqlParameter("@fax", SqlDbType.VarChar,20), new SqlParameter("@email", SqlDbType.VarChar,50), new SqlParameter("@postcode", SqlDbType.VarChar,15), new SqlParameter("@homepage", SqlDbType.VarChar,50), new SqlParameter("@domain", SqlDbType.VarChar,50), new SqlParameter("@domainip", SqlDbType.VarChar,50), new SqlParameter("@icp", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@marketid", SqlDbType.Int,4), new SqlParameter("@cid", SqlDbType.Int,4), new SqlParameter("@ctype", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4)}; parameters[0].Value = model.mid; parameters[1].Value = model.title; parameters[2].Value = model.letter; parameters[3].Value = model.groupid; parameters[4].Value = model.attribute; parameters[5].Value = model.industry; parameters[6].Value = model.productcategory; parameters[7].Value = model.vip; parameters[8].Value = model.areacode; parameters[9].Value = model.address; parameters[10].Value = model.mapapi; parameters[11].Value = model.staffsize; parameters[12].Value = model.regyear; parameters[13].Value = model.regcity; parameters[14].Value = model.buy; parameters[15].Value = model.sell; parameters[16].Value = model.linkman; parameters[17].Value = model.phone; parameters[18].Value = model.mphone; parameters[19].Value = model.fax; parameters[20].Value = model.email; parameters[21].Value = model.postcode; parameters[22].Value = model.homepage; parameters[23].Value = model.domain; parameters[24].Value = model.domainip; parameters[25].Value = model.icp; parameters[26].Value = model.surface; parameters[27].Value = model.logo; parameters[28].Value = model.thumb; parameters[29].Value = model.bannel; parameters[30].Value = model.desimage; parameters[31].Value = model.descript; parameters[32].Value = model.keywords; parameters[33].Value = model.template; parameters[34].Value = model.hits; parameters[35].Value = model.sort; parameters[36].Value = model.marketid; parameters[37].Value = model.cid; parameters[38].Value = model.ctype; parameters[39].Value = model.createmid; parameters[40].Value = model.lastedid; parameters[41].Value = model.lastedittime; parameters[42].Value = model.auditstatus; parameters[43].Value = model.linestatus; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_shop set "); strSql.Append("mid=@mid,"); strSql.Append("title=@title,"); strSql.Append("letter=@letter,"); strSql.Append("groupid=@groupid,"); strSql.Append("attribute=@attribute,"); strSql.Append("industry=@industry,"); strSql.Append("productcategory=@productcategory,"); strSql.Append("vip=@vip,"); strSql.Append("areacode=@areacode,"); strSql.Append("address=@address,"); strSql.Append("mapapi=@mapapi,"); strSql.Append("staffsize=@staffsize,"); strSql.Append("regyear=@regyear,"); strSql.Append("regcity=@regcity,"); strSql.Append("buy=@buy,"); strSql.Append("sell=@sell,"); strSql.Append("linkman=@linkman,"); strSql.Append("phone=@phone,"); strSql.Append("mphone=@mphone,"); strSql.Append("fax=@fax,"); strSql.Append("email=@email,"); strSql.Append("postcode=@postcode,"); strSql.Append("homepage=@homepage,"); strSql.Append("domain=@domain,"); strSql.Append("domainip=@domainip,"); strSql.Append("icp=@icp,"); strSql.Append("surface=@surface,"); strSql.Append("logo=@logo,"); strSql.Append("thumb=@thumb,"); strSql.Append("bannel=@bannel,"); strSql.Append("desimage=@desimage,"); strSql.Append("descript=@descript,"); strSql.Append("keywords=@keywords,"); strSql.Append("template=@template,"); strSql.Append("hits=@hits,"); strSql.Append("sort=@sort,"); strSql.Append("marketid=@marketid,"); strSql.Append("cid=@cid,"); strSql.Append("ctype=@ctype,"); strSql.Append("createmid=@createmid,"); strSql.Append("lastedid=@lastedid,"); strSql.Append("lastedittime=@lastedittime,"); strSql.Append("auditstatus=@auditstatus,"); strSql.Append("linestatus=@linestatus"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@mid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@groupid", SqlDbType.Int,4), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@industry", SqlDbType.VarChar,50), new SqlParameter("@productcategory", SqlDbType.VarChar,50), new SqlParameter("@vip", SqlDbType.Int,4), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,60), new SqlParameter("@mapapi", SqlDbType.NVarChar,80), new SqlParameter("@staffsize", SqlDbType.Int,4), new SqlParameter("@regyear", SqlDbType.VarChar,7), new SqlParameter("@regcity", SqlDbType.VarChar,10), new SqlParameter("@buy", SqlDbType.NVarChar,300), new SqlParameter("@sell", SqlDbType.NVarChar,300), new SqlParameter("@linkman", SqlDbType.NVarChar,20), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@mphone", SqlDbType.VarChar,20), new SqlParameter("@fax", SqlDbType.VarChar,20), new SqlParameter("@email", SqlDbType.VarChar,50), new SqlParameter("@postcode", SqlDbType.VarChar,15), new SqlParameter("@homepage", SqlDbType.VarChar,50), new SqlParameter("@domain", SqlDbType.VarChar,50), new SqlParameter("@domainip", SqlDbType.VarChar,50), new SqlParameter("@icp", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@marketid", SqlDbType.Int,4), new SqlParameter("@cid", SqlDbType.Int,4), new SqlParameter("@ctype", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.mid; parameters[1].Value = model.title; parameters[2].Value = model.letter; parameters[3].Value = model.groupid; parameters[4].Value = model.attribute; parameters[5].Value = model.industry; parameters[6].Value = model.productcategory; parameters[7].Value = model.vip; parameters[8].Value = model.areacode; parameters[9].Value = model.address; parameters[10].Value = model.mapapi; parameters[11].Value = model.staffsize; parameters[12].Value = model.regyear; parameters[13].Value = model.regcity; parameters[14].Value = model.buy; parameters[15].Value = model.sell; parameters[16].Value = model.linkman; parameters[17].Value = model.phone; parameters[18].Value = model.mphone; parameters[19].Value = model.fax; parameters[20].Value = model.email; parameters[21].Value = model.postcode; parameters[22].Value = model.homepage; parameters[23].Value = model.domain; parameters[24].Value = model.domainip; parameters[25].Value = model.icp; parameters[26].Value = model.surface; parameters[27].Value = model.logo; parameters[28].Value = model.thumb; parameters[29].Value = model.bannel; parameters[30].Value = model.desimage; parameters[31].Value = model.descript; parameters[32].Value = model.keywords; parameters[33].Value = model.template; parameters[34].Value = model.hits; parameters[35].Value = model.sort; parameters[36].Value = model.marketid; parameters[37].Value = model.cid; parameters[38].Value = model.ctype; parameters[39].Value = model.createmid; parameters[40].Value = model.lastedid; parameters[41].Value = model.lastedittime; parameters[42].Value = model.auditstatus; parameters[43].Value = model.linestatus; parameters[44].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnShop GetShopInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Shop "); strSql.Append(strWhere); EnShop model = new EnShop(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["mid"] != null && reader["mid"].ToString() != "") { model.mid = int.Parse(reader["mid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["industry"] != null && reader["industry"].ToString() != "") { model.industry = reader["industry"].ToString(); } if (reader["productcategory"] != null && reader["productcategory"].ToString() != "") { model.productcategory = reader["productcategory"].ToString(); } if (reader["vip"] != null && reader["vip"].ToString() != "") { model.vip = int.Parse(reader["vip"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["mapapi"] != null && reader["mapapi"].ToString() != "") { model.mapapi = reader["mapapi"].ToString(); } if (reader["staffsize"] != null && reader["staffsize"].ToString() != "") { model.staffsize = int.Parse(reader["staffsize"].ToString()); } if (reader["regyear"] != null && reader["regyear"].ToString() != "") { model.regyear = reader["regyear"].ToString(); } if (reader["regcity"] != null && reader["regcity"].ToString() != "") { model.regcity = reader["regcity"].ToString(); } if (reader["buy"] != null && reader["buy"].ToString() != "") { model.buy = reader["buy"].ToString(); } if (reader["sell"] != null && reader["sell"].ToString() != "") { model.sell = reader["sell"].ToString(); } if (reader["linkman"] != null && reader["linkman"].ToString() != "") { model.linkman = reader["linkman"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["mphone"] != null && reader["mphone"].ToString() != "") { model.mphone = reader["mphone"].ToString(); } if (reader["fax"] != null && reader["fax"].ToString() != "") { model.fax = reader["fax"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["postcode"] != null && reader["postcode"].ToString() != "") { model.postcode = reader["postcode"].ToString(); } if (reader["homepage"] != null && reader["homepage"].ToString() != "") { model.homepage = reader["homepage"].ToString(); } if (reader["domain"] != null && reader["domain"].ToString() != "") { model.domain = reader["domain"].ToString(); } if (reader["domainip"] != null && reader["domainip"].ToString() != "") { model.domainip = reader["domainip"].ToString(); } if (reader["icp"] != null && reader["icp"].ToString() != "") { model.icp = reader["icp"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["marketid"] != null && reader["marketid"].ToString() != "") { model.marketid = int.Parse(reader["marketid"].ToString()); } if (reader["cid"] != null && reader["cid"].ToString() != "") { model.cid = int.Parse(reader["cid"].ToString()); } if (reader["ctype"] != null && reader["ctype"].ToString() != "") { model.ctype = int.Parse(reader["ctype"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnShop> GetShopList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnShop> modelList = new List<EnShop>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBShop, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnShop model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnShop(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["mid"] != null && dt.Rows[n]["mid"].ToString() != "") { model.mid = int.Parse(dt.Rows[n]["mid"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["groupid"] != null && dt.Rows[n]["groupid"].ToString() != "") { model.groupid = int.Parse(dt.Rows[n]["groupid"].ToString()); } if (dt.Rows[n]["attribute"] != null && dt.Rows[n]["attribute"].ToString() != "") { model.attribute = dt.Rows[n]["attribute"].ToString(); } if (dt.Rows[n]["industry"] != null && dt.Rows[n]["industry"].ToString() != "") { model.industry = dt.Rows[n]["industry"].ToString(); } if (dt.Rows[n]["productcategory"] != null && dt.Rows[n]["productcategory"].ToString() != "") { model.productcategory = dt.Rows[n]["productcategory"].ToString(); } if (dt.Rows[n]["vip"] != null && dt.Rows[n]["vip"].ToString() != "") { model.vip = int.Parse(dt.Rows[n]["vip"].ToString()); } if (dt.Rows[n]["areacode"] != null && dt.Rows[n]["areacode"].ToString() != "") { model.areacode = dt.Rows[n]["areacode"].ToString(); } if (dt.Rows[n]["address"] != null && dt.Rows[n]["address"].ToString() != "") { model.address = dt.Rows[n]["address"].ToString(); } if (dt.Rows[n]["mapapi"] != null && dt.Rows[n]["mapapi"].ToString() != "") { model.mapapi = dt.Rows[n]["mapapi"].ToString(); } if (dt.Rows[n]["staffsize"] != null && dt.Rows[n]["staffsize"].ToString() != "") { model.staffsize = int.Parse(dt.Rows[n]["staffsize"].ToString()); } if (dt.Rows[n]["regyear"] != null && dt.Rows[n]["regyear"].ToString() != "") { model.regyear = dt.Rows[n]["regyear"].ToString(); } if (dt.Rows[n]["regcity"] != null && dt.Rows[n]["regcity"].ToString() != "") { model.regcity = dt.Rows[n]["regcity"].ToString(); } if (dt.Rows[n]["buy"] != null && dt.Rows[n]["buy"].ToString() != "") { model.buy = dt.Rows[n]["buy"].ToString(); } if (dt.Rows[n]["sell"] != null && dt.Rows[n]["sell"].ToString() != "") { model.sell = dt.Rows[n]["sell"].ToString(); } if (dt.Rows[n]["linkman"] != null && dt.Rows[n]["linkman"].ToString() != "") { model.linkman = dt.Rows[n]["linkman"].ToString(); } if (dt.Rows[n]["phone"] != null && dt.Rows[n]["phone"].ToString() != "") { model.phone = dt.Rows[n]["phone"].ToString(); } if (dt.Rows[n]["mphone"] != null && dt.Rows[n]["mphone"].ToString() != "") { model.mphone = dt.Rows[n]["mphone"].ToString(); } if (dt.Rows[n]["fax"] != null && dt.Rows[n]["fax"].ToString() != "") { model.fax = dt.Rows[n]["fax"].ToString(); } if (dt.Rows[n]["email"] != null && dt.Rows[n]["email"].ToString() != "") { model.email = dt.Rows[n]["email"].ToString(); } if (dt.Rows[n]["postcode"] != null && dt.Rows[n]["postcode"].ToString() != "") { model.postcode = dt.Rows[n]["postcode"].ToString(); } if (dt.Rows[n]["homepage"] != null && dt.Rows[n]["homepage"].ToString() != "") { model.homepage = dt.Rows[n]["homepage"].ToString(); } if (dt.Rows[n]["domain"] != null && dt.Rows[n]["domain"].ToString() != "") { model.domain = dt.Rows[n]["domain"].ToString(); } if (dt.Rows[n]["domainip"] != null && dt.Rows[n]["domainip"].ToString() != "") { model.domainip = dt.Rows[n]["domainip"].ToString(); } if (dt.Rows[n]["icp"] != null && dt.Rows[n]["icp"].ToString() != "") { model.icp = dt.Rows[n]["icp"].ToString(); } if (dt.Rows[n]["surface"] != null && dt.Rows[n]["surface"].ToString() != "") { model.surface = dt.Rows[n]["surface"].ToString(); } if (dt.Rows[n]["logo"] != null && dt.Rows[n]["logo"].ToString() != "") { model.logo = dt.Rows[n]["logo"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["bannel"] != null && dt.Rows[n]["bannel"].ToString() != "") { model.bannel = dt.Rows[n]["bannel"].ToString(); } if (dt.Rows[n]["desimage"] != null && dt.Rows[n]["desimage"].ToString() != "") { model.desimage = dt.Rows[n]["desimage"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["keywords"] != null && dt.Rows[n]["keywords"].ToString() != "") { model.keywords = dt.Rows[n]["keywords"].ToString(); } if (dt.Rows[n]["template"] != null && dt.Rows[n]["template"].ToString() != "") { model.template = dt.Rows[n]["template"].ToString(); } if (dt.Rows[n]["hits"] != null && dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["marketid"] != null && dt.Rows[n]["marketid"].ToString() != "") { model.marketid = int.Parse(dt.Rows[n]["marketid"].ToString()); } if (dt.Rows[n]["cid"] != null && dt.Rows[n]["cid"].ToString() != "") { model.cid = int.Parse(dt.Rows[n]["cid"].ToString()); } if (dt.Rows[n]["ctype"] != null && dt.Rows[n]["ctype"].ToString() != "") { model.ctype = int.Parse(dt.Rows[n]["ctype"].ToString()); } if (dt.Rows[n]["createmid"] != null && dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } if (dt.Rows[n]["lastedid"] != null && dt.Rows[n]["lastedid"].ToString() != "") { model.lastedid = int.Parse(dt.Rows[n]["lastedid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["auditstatus"] != null && dt.Rows[n]["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(dt.Rows[n]["auditstatus"].ToString()); } if (dt.Rows[n]["linestatus"] != null && dt.Rows[n]["linestatus"].ToString() != "") { model.linestatus = int.Parse(dt.Rows[n]["linestatus"].ToString()); } modelList.Add(model); } } return modelList; } #endregion #region 共公模块-组 /// <summary> /// 更新对像 /// </summary> public static int EditShopGroup(EnShopGroup model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_shopgroup("); strSql.Append("title,color,avatar,integral,money,adcount,marketpcount,brandcount,promotioncount,productcount,adrecommend,marketrecommend,brandrecommend,promotionrecommend,productrecommend,permissions,lev,descript,sort)"); strSql.Append(" values ("); strSql.Append("@title,@color,@avatar,@integral,@money,@adcount,@marketpcount,@brandcount,@promotioncount,@productcount,@adrecommend,@marketrecommend,@brandrecommend,@promotionrecommend,@productrecommend,@permissions,@lev,@descript,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@color", SqlDbType.Char,7), new SqlParameter("@avatar", SqlDbType.VarChar,40), new SqlParameter("@integral", SqlDbType.Decimal,9), new SqlParameter("@money", SqlDbType.Decimal,9), new SqlParameter("@adcount", SqlDbType.Int,4), new SqlParameter("@marketpcount", SqlDbType.Int,4), new SqlParameter("@brandcount", SqlDbType.Int,4), new SqlParameter("@promotioncount", SqlDbType.Int,4), new SqlParameter("@productcount", SqlDbType.Int,4), new SqlParameter("@adrecommend", SqlDbType.Int,4), new SqlParameter("@marketrecommend", SqlDbType.Int,4), new SqlParameter("@brandrecommend", SqlDbType.Int,4), new SqlParameter("@promotionrecommend", SqlDbType.Int,4), new SqlParameter("@productrecommend", SqlDbType.Int,4), new SqlParameter("@permissions", SqlDbType.NText), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.color; parameters[2].Value = model.avatar; parameters[3].Value = model.integral; parameters[4].Value = model.money; parameters[5].Value = model.adcount; parameters[6].Value = model.marketpcount; parameters[7].Value = model.brandcount; parameters[8].Value = model.promotioncount; parameters[9].Value = model.productcount; parameters[10].Value = model.adrecommend; parameters[11].Value = model.marketrecommend; parameters[12].Value = model.brandrecommend; parameters[13].Value = model.promotionrecommend; parameters[14].Value = model.productrecommend; parameters[15].Value = model.permissions; parameters[16].Value = model.lev; parameters[17].Value = model.descript; parameters[18].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_shopgroup set "); strSql.Append("title=@title,"); strSql.Append("color=@color,"); strSql.Append("avatar=@avatar,"); strSql.Append("integral=@integral,"); strSql.Append("money=@money,"); strSql.Append("adcount=@adcount,"); strSql.Append("marketpcount=@marketpcount,"); strSql.Append("brandcount=@brandcount,"); strSql.Append("promotioncount=@promotioncount,"); strSql.Append("productcount=@productcount,"); strSql.Append("adrecommend=@adrecommend,"); strSql.Append("marketrecommend=@marketrecommend,"); strSql.Append("brandrecommend=@brandrecommend,"); strSql.Append("promotionrecommend=@promotionrecommend,"); strSql.Append("productrecommend=@productrecommend,"); strSql.Append("permissions=@permissions,"); strSql.Append("lev=@lev,"); strSql.Append("descript=@descript,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@color", SqlDbType.Char,7), new SqlParameter("@avatar", SqlDbType.VarChar,40), new SqlParameter("@integral", SqlDbType.Decimal,9), new SqlParameter("@money", SqlDbType.Decimal,9), new SqlParameter("@adcount", SqlDbType.Int,4), new SqlParameter("@marketpcount", SqlDbType.Int,4), new SqlParameter("@brandcount", SqlDbType.Int,4), new SqlParameter("@promotioncount", SqlDbType.Int,4), new SqlParameter("@productcount", SqlDbType.Int,4), new SqlParameter("@adrecommend", SqlDbType.Int,4), new SqlParameter("@marketrecommend", SqlDbType.Int,4), new SqlParameter("@brandrecommend", SqlDbType.Int,4), new SqlParameter("@promotionrecommend", SqlDbType.Int,4), new SqlParameter("@productrecommend", SqlDbType.Int,4), new SqlParameter("@permissions", SqlDbType.NText), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.color; parameters[2].Value = model.avatar; parameters[3].Value = model.integral; parameters[4].Value = model.money; parameters[5].Value = model.adcount; parameters[6].Value = model.marketpcount; parameters[7].Value = model.brandcount; parameters[8].Value = model.promotioncount; parameters[9].Value = model.productcount; parameters[10].Value = model.adrecommend; parameters[11].Value = model.marketrecommend; parameters[12].Value = model.brandrecommend; parameters[13].Value = model.promotionrecommend; parameters[14].Value = model.productrecommend; parameters[15].Value = model.permissions; parameters[16].Value = model.lev; parameters[17].Value = model.descript; parameters[18].Value = model.sort; parameters[19].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnShopGroup GetShopGroupInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_ShopGroup "); strSql.Append(strWhere); EnShopGroup model = new EnShopGroup(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["color"] != null && reader["color"].ToString() != "") { model.color = reader["color"].ToString(); } if (reader["avatar"] != null && reader["avatar"].ToString() != "") { model.avatar = reader["avatar"].ToString(); } if (reader["integral"] != null && reader["integral"].ToString() != "") { model.integral = decimal.Parse(reader["integral"].ToString()); } if (reader["money"] != null && reader["money"].ToString() != "") { model.money = decimal.Parse(reader["money"].ToString()); } if (reader["adcount"] != null && reader["adcount"].ToString() != "") { model.adcount = int.Parse(reader["adcount"].ToString()); } if (reader["marketpcount"] != null && reader["marketpcount"].ToString() != "") { model.marketpcount = int.Parse(reader["marketpcount"].ToString()); } if (reader["brandcount"] != null && reader["brandcount"].ToString() != "") { model.brandcount = int.Parse(reader["brandcount"].ToString()); } if (reader["promotioncount"] != null && reader["promotioncount"].ToString() != "") { model.promotioncount = int.Parse(reader["promotioncount"].ToString()); } if (reader["productcount"] != null && reader["productcount"].ToString() != "") { model.productcount = int.Parse(reader["productcount"].ToString()); } if (reader["adrecommend"] != null && reader["adrecommend"].ToString() != "") { model.adrecommend = int.Parse(reader["adrecommend"].ToString()); } if (reader["marketrecommend"] != null && reader["marketrecommend"].ToString() != "") { model.marketrecommend = int.Parse(reader["marketrecommend"].ToString()); } if (reader["brandrecommend"] != null && reader["brandrecommend"].ToString() != "") { model.brandrecommend = int.Parse(reader["brandrecommend"].ToString()); } if (reader["promotionrecommend"] != null && reader["promotionrecommend"].ToString() != "") { model.promotionrecommend = int.Parse(reader["promotionrecommend"].ToString()); } if (reader["productrecommend"] != null && reader["productrecommend"].ToString() != "") { model.productrecommend = int.Parse(reader["productrecommend"].ToString()); } if (reader["permissions"] != null && reader["permissions"].ToString() != "") { model.permissions = reader["permissions"].ToString(); } if (reader["lev"] != null && reader["lev"].ToString() != "") { model.lev = int.Parse(reader["lev"].ToString()); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnShopGroup> GetShopGroupList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnShopGroup> modelList = new List<EnShopGroup>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBShopGroup, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnShopGroup model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnShopGroup(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["color"] != null && dt.Rows[n]["color"].ToString() != "") { model.color = dt.Rows[n]["color"].ToString(); } if (dt.Rows[n]["avatar"] != null && dt.Rows[n]["avatar"].ToString() != "") { model.avatar = dt.Rows[n]["avatar"].ToString(); } if (dt.Rows[n]["integral"] != null && dt.Rows[n]["integral"].ToString() != "") { model.integral = decimal.Parse(dt.Rows[n]["integral"].ToString()); } if (dt.Rows[n]["money"] != null && dt.Rows[n]["money"].ToString() != "") { model.money = decimal.Parse(dt.Rows[n]["money"].ToString()); } if (dt.Rows[n]["adcount"] != null && dt.Rows[n]["adcount"].ToString() != "") { model.adcount = int.Parse(dt.Rows[n]["adcount"].ToString()); } if (dt.Rows[n]["marketpcount"] != null && dt.Rows[n]["marketpcount"].ToString() != "") { model.marketpcount = int.Parse(dt.Rows[n]["marketpcount"].ToString()); } if (dt.Rows[n]["brandcount"] != null && dt.Rows[n]["brandcount"].ToString() != "") { model.brandcount = int.Parse(dt.Rows[n]["brandcount"].ToString()); } if (dt.Rows[n]["promotioncount"] != null && dt.Rows[n]["promotioncount"].ToString() != "") { model.promotioncount = int.Parse(dt.Rows[n]["promotioncount"].ToString()); } if (dt.Rows[n]["productcount"] != null && dt.Rows[n]["productcount"].ToString() != "") { model.productcount = int.Parse(dt.Rows[n]["productcount"].ToString()); } if (dt.Rows[n]["adrecommend"] != null && dt.Rows[n]["adrecommend"].ToString() != "") { model.adrecommend = int.Parse(dt.Rows[n]["adrecommend"].ToString()); } if (dt.Rows[n]["marketrecommend"] != null && dt.Rows[n]["marketrecommend"].ToString() != "") { model.marketrecommend = int.Parse(dt.Rows[n]["marketrecommend"].ToString()); } if (dt.Rows[n]["brandrecommend"] != null && dt.Rows[n]["brandrecommend"].ToString() != "") { model.brandrecommend = int.Parse(dt.Rows[n]["brandrecommend"].ToString()); } if (dt.Rows[n]["promotionrecommend"] != null && dt.Rows[n]["promotionrecommend"].ToString() != "") { model.promotionrecommend = int.Parse(dt.Rows[n]["promotionrecommend"].ToString()); } if (dt.Rows[n]["productrecommend"] != null && dt.Rows[n]["productrecommend"].ToString() != "") { model.productrecommend = int.Parse(dt.Rows[n]["productrecommend"].ToString()); } if (dt.Rows[n]["permissions"] != null && dt.Rows[n]["permissions"].ToString() != "") { model.permissions = dt.Rows[n]["permissions"].ToString(); } if (dt.Rows[n]["lev"] != null && dt.Rows[n]["lev"].ToString() != "") { model.lev = int.Parse(dt.Rows[n]["lev"].ToString()); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Shops.cs
C#
oos
84,056
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Menus { #region 共公模块 /// <summary> /// 更新对像 /// </summary> public static int EditMenu(EnMenu model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_menu("); strSql.Append("title,type,mark,parent,lev,path,url,module,action,descript,sort)"); strSql.Append(" values ("); strSql.Append("@title,@type,@mark,@parent,@lev,@path,@url,@module,@action,@descript,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,50), new SqlParameter("@type", SqlDbType.VarChar,50), new SqlParameter("@mark", SqlDbType.VarChar,50), new SqlParameter("@parent", SqlDbType.Int,4), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@path", SqlDbType.VarChar,50), new SqlParameter("@url", SqlDbType.VarChar,400), new SqlParameter("@module", SqlDbType.Int,4), new SqlParameter("@action", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,800), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.type; parameters[2].Value = model.mark; parameters[3].Value = model.parent; parameters[4].Value = model.lev; parameters[5].Value = model.path; parameters[6].Value = model.url; parameters[7].Value = model.module; parameters[8].Value = model.action; parameters[9].Value = model.descript; parameters[10].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_menu set "); strSql.Append("title=@title,"); strSql.Append("type=@type,"); strSql.Append("mark=@mark,"); strSql.Append("parent=@parent,"); strSql.Append("lev=@lev,"); strSql.Append("path=@path,"); strSql.Append("url=@url,"); strSql.Append("module=@module,"); strSql.Append("action=@action,"); strSql.Append("descript=@descript,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,50), new SqlParameter("@type", SqlDbType.VarChar,50), new SqlParameter("@mark", SqlDbType.VarChar,50), new SqlParameter("@parent", SqlDbType.Int,4), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@path", SqlDbType.VarChar,50), new SqlParameter("@url", SqlDbType.VarChar,400), new SqlParameter("@module", SqlDbType.Int,4), new SqlParameter("@action", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,800), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.type; parameters[2].Value = model.mark; parameters[3].Value = model.parent; parameters[4].Value = model.lev; parameters[5].Value = model.path; parameters[6].Value = model.url; parameters[7].Value = model.module; parameters[8].Value = model.action; parameters[9].Value = model.descript; parameters[10].Value = model.sort; parameters[11].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnMenu GetMenuInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Menu "); strSql.Append(strWhere); EnMenu model = new EnMenu(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["type"] != null && reader["type"].ToString() != "") { model.type = reader["type"].ToString(); } if (reader["mark"] != null && reader["mark"].ToString() != "") { model.mark = reader["mark"].ToString(); } if (reader["parent"] != null && reader["parent"].ToString() != "") { model.parent = int.Parse(reader["parent"].ToString()); } if (reader["lev"] != null && reader["lev"].ToString() != "") { model.lev = int.Parse(reader["lev"].ToString()); } if (reader["path"] != null && reader["path"].ToString() != "") { model.path = reader["path"].ToString(); } if (reader["url"] != null && reader["url"].ToString() != "") { model.url = reader["url"].ToString(); } if (reader["module"] != null && reader["module"].ToString() != "") { model.module = int.Parse(reader["module"].ToString()); } if (reader["action"] != null && reader["action"].ToString() != "") { model.action = int.Parse(reader["action"].ToString()); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnMenu> GetMenuList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnMenu> modelList = new List<EnMenu>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBMenu, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnMenu model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnMenu(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["type"] != null && dt.Rows[n]["type"].ToString() != "") { model.type = dt.Rows[n]["type"].ToString(); } if (dt.Rows[n]["mark"] != null && dt.Rows[n]["mark"].ToString() != "") { model.mark = dt.Rows[n]["mark"].ToString(); } if (dt.Rows[n]["parent"] != null && dt.Rows[n]["parent"].ToString() != "") { model.parent = int.Parse(dt.Rows[n]["parent"].ToString()); } if (dt.Rows[n]["lev"] != null && dt.Rows[n]["lev"].ToString() != "") { model.lev = int.Parse(dt.Rows[n]["lev"].ToString()); } if (dt.Rows[n]["path"] != null && dt.Rows[n]["path"].ToString() != "") { model.path = dt.Rows[n]["path"].ToString(); } if (dt.Rows[n]["url"] != null && dt.Rows[n]["url"].ToString() != "") { model.url = dt.Rows[n]["url"].ToString(); } if (dt.Rows[n]["module"] != null && dt.Rows[n]["module"].ToString() != "") { model.module = int.Parse(dt.Rows[n]["module"].ToString()); } if (dt.Rows[n]["action"] != null && dt.Rows[n]["action"].ToString() != "") { model.action = int.Parse(dt.Rows[n]["action"].ToString()); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } /// <summary> /// 获得数据列表 /// </summary> public static List<EnMenu> GetMenuList(string filed,string strWhere,string sort) { List<EnMenu> modelList = new List<EnMenu>(); DataTable dt = DataCommon.GetDataTable(TableName.TBMenu, "", strWhere, sort); if (dt.Rows.Count > 0) { EnMenu model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnMenu(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["type"] != null && dt.Rows[n]["type"].ToString() != "") { model.type = dt.Rows[n]["type"].ToString(); } if (dt.Rows[n]["mark"] != null && dt.Rows[n]["mark"].ToString() != "") { model.mark = dt.Rows[n]["mark"].ToString(); } if (dt.Rows[n]["parent"] != null && dt.Rows[n]["parent"].ToString() != "") { model.parent = int.Parse(dt.Rows[n]["parent"].ToString()); } if (dt.Rows[n]["lev"] != null && dt.Rows[n]["lev"].ToString() != "") { model.lev = int.Parse(dt.Rows[n]["lev"].ToString()); } if (dt.Rows[n]["path"] != null && dt.Rows[n]["path"].ToString() != "") { model.path = dt.Rows[n]["path"].ToString(); } if (dt.Rows[n]["url"] != null && dt.Rows[n]["url"].ToString() != "") { model.url = dt.Rows[n]["url"].ToString(); } if (dt.Rows[n]["module"] != null && dt.Rows[n]["module"].ToString() != "") { model.module = int.Parse(dt.Rows[n]["module"].ToString()); } if (dt.Rows[n]["action"] != null && dt.Rows[n]["action"].ToString() != "") { model.action = int.Parse(dt.Rows[n]["action"].ToString()); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Menus.cs
C#
oos
14,342
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Aggregations { //聚合信息 public static List<EnWebAggregation> GetWebAggregationList(int PageIndex, int PageSize, string strWhere,string sortkey,string orderby, out int pageCount) { List<EnWebAggregation> list = new List<EnWebAggregation>(); IDataReader reader = DataCommon.GetPageDataReader(TableName.TVAggregation, PageIndex, PageSize, strWhere, sortkey, orderby, out pageCount); while (reader.Read()) { EnWebAggregation model = new EnWebAggregation(); if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["typethumb"] != null && reader["typethumb"].ToString() != "") { model.typethumb = reader["typethumb"].ToString(); } if (reader["typeurl"] != null && reader["typeurl"].ToString() != "") { model.typeurl = reader["typeurl"].ToString(); } if (reader["typetitle"] != null && reader["typetitle"].ToString() != "") { model.typetitle = reader["typetitle"].ToString(); } if (reader["parent"] != null && reader["parent"].ToString() != "") { model.parent = int.Parse(reader["parent"].ToString()); } if (reader["type"] != null && reader["type"].ToString() != "") { model.type = int.Parse(reader["type"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["title1"] != null && reader["title1"].ToString() != "") { model.title1 = reader["title1"].ToString(); } if (reader["title2"] != null && reader["title2"].ToString() != "") { model.title2 = reader["title2"].ToString(); } if (reader["title3"] != null && reader["title3"].ToString() != "") { model.title3 = reader["title3"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["thumbw"] != null && reader["thumbw"].ToString() != "") { model.thumbw = int.Parse(reader["thumbw"].ToString()); } if (reader["thumbh"] != null && reader["thumbh"].ToString() != "") { model.thumbh = int.Parse(reader["thumbh"].ToString()); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["url"] != null && reader["url"].ToString() != "") { model.url = reader["url"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } list.Add(model); } return list; } /// <summary> /// 更新对像 /// </summary> public static int EditAggregation(EnAggregation model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_aggregation("); strSql.Append("type,title,title1,title2,title3,thumb,thumbw,thumbh,bannel,url,url1,url2,descript,sort,hits,lastedittime,createmid)"); strSql.Append(" values ("); strSql.Append("@type,@title,@title1,@title2,@title3,@thumb,@thumbw,@thumbh,@bannel,@url,@url1,@url2,@descript,@sort,@hits,@lastedittime,@createmid)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@type", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,120), new SqlParameter("@title1", SqlDbType.NVarChar,50), new SqlParameter("@title2", SqlDbType.NVarChar,50), new SqlParameter("@title3", SqlDbType.NVarChar,50), new SqlParameter("@thumb", SqlDbType.VarChar,50), new SqlParameter("@thumbw", SqlDbType.Int,4), new SqlParameter("@thumbh", SqlDbType.Int,4), new SqlParameter("@bannel", SqlDbType.VarChar,400), new SqlParameter("@url", SqlDbType.VarChar,50), new SqlParameter("@url1", SqlDbType.VarChar,50), new SqlParameter("@url2", SqlDbType.VarChar,50), new SqlParameter("@descript", SqlDbType.NVarChar,250), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@createmid", SqlDbType.Int,4)}; parameters[0].Value = model.type; parameters[1].Value = model.title; parameters[2].Value = model.title1; parameters[3].Value = model.title2; parameters[4].Value = model.title3; parameters[5].Value = model.thumb; parameters[6].Value = model.thumbw; parameters[7].Value = model.thumbh; parameters[8].Value = model.bannel; parameters[9].Value = model.url; parameters[10].Value = model.url1; parameters[11].Value = model.url2; parameters[12].Value = model.descript; parameters[13].Value = model.sort; parameters[14].Value = model.hits; parameters[15].Value = model.lastedittime; parameters[16].Value = model.createmid; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_aggregation set "); strSql.Append("type=@type,"); strSql.Append("title=@title,"); strSql.Append("title1=@title1,"); strSql.Append("title2=@title2,"); strSql.Append("title3=@title3,"); strSql.Append("thumb=@thumb,"); strSql.Append("thumbw=@thumbw,"); strSql.Append("thumbh=@thumbh,"); strSql.Append("bannel=@bannel,"); strSql.Append("url=@url,"); strSql.Append("url1=@url1,"); strSql.Append("url2=@url2,"); strSql.Append("descript=@descript,"); strSql.Append("sort=@sort,"); strSql.Append("hits=@hits,"); strSql.Append("lastedittime=@lastedittime,"); strSql.Append("createmid=@createmid"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@type", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,120), new SqlParameter("@title1", SqlDbType.NVarChar,50), new SqlParameter("@title2", SqlDbType.NVarChar,50), new SqlParameter("@title3", SqlDbType.NVarChar,50), new SqlParameter("@thumb", SqlDbType.VarChar,50), new SqlParameter("@thumbw", SqlDbType.Int,4), new SqlParameter("@thumbh", SqlDbType.Int,4), new SqlParameter("@bannel", SqlDbType.VarChar,400), new SqlParameter("@url", SqlDbType.VarChar,50), new SqlParameter("@url1", SqlDbType.VarChar,50), new SqlParameter("@url2", SqlDbType.VarChar,50), new SqlParameter("@descript", SqlDbType.NVarChar,250), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.type; parameters[1].Value = model.title; parameters[2].Value = model.title1; parameters[3].Value = model.title2; parameters[4].Value = model.title3; parameters[5].Value = model.thumb; parameters[6].Value = model.thumbw; parameters[7].Value = model.thumbh; parameters[8].Value = model.bannel; parameters[9].Value = model.url; parameters[10].Value = model.url1; parameters[11].Value = model.url2; parameters[12].Value = model.descript; parameters[13].Value = model.sort; parameters[14].Value = model.hits; parameters[15].Value = model.lastedittime; parameters[16].Value = model.createmid; parameters[17].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnAggregation GetAggregationInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Aggregation "); strSql.Append(strWhere); EnAggregation model = new EnAggregation(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["type"] != null && reader["type"].ToString() != "") { model.type = int.Parse(reader["type"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["title1"] != null && reader["title1"].ToString() != "") { model.title1 = reader["title1"].ToString(); } if (reader["title2"] != null && reader["title2"].ToString() != "") { model.title2 = reader["title2"].ToString(); } if (reader["title3"] != null && reader["title3"].ToString() != "") { model.title3 = reader["title3"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["thumbw"] != null && reader["thumbw"].ToString() != "") { model.thumbw = int.Parse(reader["thumbw"].ToString()); } if (reader["thumbh"] != null && reader["thumbh"].ToString() != "") { model.thumbh = int.Parse(reader["thumbh"].ToString()); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["url"] != null && reader["url"].ToString() != "") { model.url = reader["url"].ToString(); } if (reader["url1"] != null && reader["url1"].ToString() != "") { model.url1 = reader["url1"].ToString(); } if (reader["url2"] != null && reader["url2"].ToString() != "") { model.url2 = reader["url2"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnAggregation> GetAggregationList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnAggregation> modelList = new List<EnAggregation>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBAggregation, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnAggregation model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnAggregation(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["type"] != null && dt.Rows[n]["type"].ToString() != "") { model.type = int.Parse(dt.Rows[n]["type"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["title1"] != null && dt.Rows[n]["title1"].ToString() != "") { model.title1 = dt.Rows[n]["title1"].ToString(); } if (dt.Rows[n]["title2"] != null && dt.Rows[n]["title2"].ToString() != "") { model.title2 = dt.Rows[n]["title2"].ToString(); } if (dt.Rows[n]["title3"] != null && dt.Rows[n]["title3"].ToString() != "") { model.title3 = dt.Rows[n]["title3"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["thumbw"] != null && dt.Rows[n]["thumbw"].ToString() != "") { model.thumbw = int.Parse(dt.Rows[n]["thumbw"].ToString()); } if (dt.Rows[n]["thumbh"] != null && dt.Rows[n]["thumbh"].ToString() != "") { model.thumbh = int.Parse(dt.Rows[n]["thumbh"].ToString()); } if (dt.Rows[n]["bannel"] != null && dt.Rows[n]["bannel"].ToString() != "") { model.bannel = dt.Rows[n]["bannel"].ToString(); } if (dt.Rows[n]["url"] != null && dt.Rows[n]["url"].ToString() != "") { model.url = dt.Rows[n]["url"].ToString(); } if (dt.Rows[n]["url1"] != null && dt.Rows[n]["url1"].ToString() != "") { model.url1 = dt.Rows[n]["url1"].ToString(); } if (dt.Rows[n]["url2"] != null && dt.Rows[n]["url2"].ToString() != "") { model.url2 = dt.Rows[n]["url2"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["hits"] != null && dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["createmid"] != null && dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } modelList.Add(model); } } return modelList; } /// <summary> /// 更新对像 /// </summary> public static int EditAggregationType(EnAggregationType model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_aggregationtype("); strSql.Append("parentid,title,title1,thumb,url,sort)"); strSql.Append(" values ("); strSql.Append("@parentid,@title,@title1,@thumb,@url,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@parentid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,120), new SqlParameter("@title1", SqlDbType.NVarChar,50), new SqlParameter("@thumb", SqlDbType.VarChar,400), new SqlParameter("@url", SqlDbType.VarChar,100), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.parentid; parameters[1].Value = model.title; parameters[2].Value = model.title1; parameters[3].Value = model.thumb; parameters[4].Value = model.url; parameters[5].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_aggregationtype set "); strSql.Append("parentid=@parentid,"); strSql.Append("title=@title,"); strSql.Append("title1=@title1,"); strSql.Append("thumb=@thumb,"); strSql.Append("url=@url,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@parentid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,120), new SqlParameter("@title1", SqlDbType.NVarChar,50), new SqlParameter("@thumb", SqlDbType.VarChar,400), new SqlParameter("@url", SqlDbType.VarChar,100), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.parentid; parameters[1].Value = model.title; parameters[2].Value = model.title1; parameters[3].Value = model.thumb; parameters[4].Value = model.url; parameters[5].Value = model.sort; parameters[6].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnAggregationType GetAggregationTypeInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_AggregationType "); strSql.Append(strWhere); EnAggregationType model = new EnAggregationType(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["parentid"] != null && reader["parentid"].ToString() != "") { model.parentid = int.Parse(reader["parentid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["title1"] != null && reader["title1"].ToString() != "") { model.title1 = reader["title1"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["url"] != null && reader["url"].ToString() != "") { model.url = reader["url"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnAggregationType> GetAggregationTypeList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnAggregationType> modelList = new List<EnAggregationType>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBAggregationType, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnAggregationType model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnAggregationType(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["parentid"] != null && dt.Rows[n]["parentid"].ToString() != "") { model.parentid = int.Parse(dt.Rows[n]["parentid"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["title1"] != null && dt.Rows[n]["title1"].ToString() != "") { model.title1 = dt.Rows[n]["title1"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["url"] != null && dt.Rows[n]["url"].ToString() != "") { model.url = dt.Rows[n]["url"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Aggregations.cs
C#
oos
27,634
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Logs { /// <summary> /// 更新对像 /// </summary> public static int EditLog(EnLog model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_log("); strSql.Append("modeule,action,operateid,operatename,title,lastedittime)"); strSql.Append(" values ("); strSql.Append("@modeule,@action,@operateid,@operatename,@title,@lastedittime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@modeule", SqlDbType.Int,4), new SqlParameter("@action", SqlDbType.Int,4), new SqlParameter("@operateid", SqlDbType.Int,4), new SqlParameter("@operatename", SqlDbType.NVarChar,60), new SqlParameter("@title", SqlDbType.NVarChar,380), new SqlParameter("@lastedittime", SqlDbType.DateTime)}; parameters[0].Value = model.modeule; parameters[1].Value = model.action; parameters[2].Value = model.operateid; parameters[3].Value = model.operatename; parameters[4].Value = model.title; parameters[5].Value = model.lastedittime; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_log set "); strSql.Append("modeule=@modeule,"); strSql.Append("action=@action,"); strSql.Append("operateid=@operateid,"); strSql.Append("operatename=@operatename,"); strSql.Append("title=@title,"); strSql.Append("lastedittime=@lastedittime"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@modeule", SqlDbType.Int,4), new SqlParameter("@action", SqlDbType.Int,4), new SqlParameter("@operateid", SqlDbType.Int,4), new SqlParameter("@operatename", SqlDbType.NVarChar,60), new SqlParameter("@title", SqlDbType.NVarChar,380), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.modeule; parameters[1].Value = model.action; parameters[2].Value = model.operateid; parameters[3].Value = model.operatename; parameters[4].Value = model.title; parameters[5].Value = model.lastedittime; parameters[6].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnLog GetLogInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Log "); strSql.Append(strWhere); EnLog model = new EnLog(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["modeule"] != null && reader["modeule"].ToString() != "") { model.modeule = int.Parse(reader["modeule"].ToString()); } if (reader["action"] != null && reader["action"].ToString() != "") { model.action = int.Parse(reader["action"].ToString()); } if (reader["operateid"] != null && reader["operateid"].ToString() != "") { model.operateid = int.Parse(reader["operateid"].ToString()); } if (reader["operatename"] != null && reader["operatename"].ToString() != "") { model.operatename = reader["operatename"].ToString(); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnLog> GetLogList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnLog> modelList = new List<EnLog>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBLog, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnLog model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnLog(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["modeule"] != null && dt.Rows[n]["modeule"].ToString() != "") { model.modeule = int.Parse(dt.Rows[n]["modeule"].ToString()); } if (dt.Rows[n]["action"] != null && dt.Rows[n]["action"].ToString() != "") { model.action = int.Parse(dt.Rows[n]["action"].ToString()); } if (dt.Rows[n]["operateid"] != null && dt.Rows[n]["operateid"].ToString() != "") { model.operateid = int.Parse(dt.Rows[n]["operateid"].ToString()); } if (dt.Rows[n]["operatename"] != null && dt.Rows[n]["operatename"].ToString() != "") { model.operatename = dt.Rows[n]["operatename"].ToString(); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } modelList.Add(model); } } return modelList; } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Logs.cs
C#
oos
8,033
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Administrators { #region 共公模块 /// <summary> /// 更新对像 /// </summary> public static int EditAdmin(EnAdmin model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_admin("); strSql.Append("name,password,displayname,question,answer,email,phone,areacode,address,logincount,islock,lastmodule,createdate,lastactivitydate)"); strSql.Append(" values ("); strSql.Append("@name,@password,@displayname,@question,@answer,@email,@phone,@areacode,@address,@logincount,@islock,@lastmodule,@createdate,@lastactivitydate)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@name", SqlDbType.NVarChar,20), new SqlParameter("@password", SqlDbType.Char,32), new SqlParameter("@displayname", SqlDbType.NVarChar,25), new SqlParameter("@question", SqlDbType.NVarChar,30), new SqlParameter("@answer", SqlDbType.NVarChar,30), new SqlParameter("@email", SqlDbType.VarChar,30), new SqlParameter("@phone", SqlDbType.VarChar,30), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,50), new SqlParameter("@logincount", SqlDbType.Int,4), new SqlParameter("@islock", SqlDbType.Int,4), new SqlParameter("@lastmodule", SqlDbType.NVarChar,50), new SqlParameter("@createdate", SqlDbType.DateTime), new SqlParameter("@lastactivitydate", SqlDbType.DateTime)}; parameters[0].Value = model.name; parameters[1].Value = model.password; parameters[2].Value = model.displayname; parameters[3].Value = model.question; parameters[4].Value = model.answer; parameters[5].Value = model.email; parameters[6].Value = model.phone; parameters[7].Value = model.areacode; parameters[8].Value = model.address; parameters[9].Value = model.logincount; parameters[10].Value = model.islock; parameters[11].Value = model.lastmodule; parameters[12].Value = model.createdate; parameters[13].Value = model.lastactivitydate; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_admin set "); strSql.Append("name=@name,"); strSql.Append("password=@password,"); strSql.Append("displayname=@displayname,"); strSql.Append("question=@question,"); strSql.Append("answer=@answer,"); strSql.Append("email=@email,"); strSql.Append("phone=@phone,"); strSql.Append("areacode=@areacode,"); strSql.Append("address=@address,"); strSql.Append("logincount=@logincount,"); strSql.Append("islock=@islock,"); strSql.Append("lastmodule=@lastmodule,"); strSql.Append("createdate=@createdate,"); strSql.Append("lastactivitydate=@lastactivitydate"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@name", SqlDbType.NVarChar,20), new SqlParameter("@password", SqlDbType.Char,32), new SqlParameter("@displayname", SqlDbType.NVarChar,25), new SqlParameter("@question", SqlDbType.NVarChar,30), new SqlParameter("@answer", SqlDbType.NVarChar,30), new SqlParameter("@email", SqlDbType.VarChar,30), new SqlParameter("@phone", SqlDbType.VarChar,30), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,50), new SqlParameter("@logincount", SqlDbType.Int,4), new SqlParameter("@islock", SqlDbType.Int,4), new SqlParameter("@lastmodule", SqlDbType.NVarChar,50), new SqlParameter("@createdate", SqlDbType.DateTime), new SqlParameter("@lastactivitydate", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.name; parameters[1].Value = model.password; parameters[2].Value = model.displayname; parameters[3].Value = model.question; parameters[4].Value = model.answer; parameters[5].Value = model.email; parameters[6].Value = model.phone; parameters[7].Value = model.areacode; parameters[8].Value = model.address; parameters[9].Value = model.logincount; parameters[10].Value = model.islock; parameters[11].Value = model.lastmodule; parameters[12].Value = model.createdate; parameters[13].Value = model.lastactivitydate; parameters[14].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnAdmin GetAdminInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_admin "); strSql.Append(strWhere); EnAdmin model = new EnAdmin(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["name"] != null && reader["name"].ToString() != "") { model.name = reader["name"].ToString(); } if (reader["password"] != null && reader["password"].ToString() != "") { model.password = reader["password"].ToString(); } if (reader["displayname"] != null && reader["displayname"].ToString() != "") { model.displayname = reader["displayname"].ToString(); } if (reader["question"] != null && reader["question"].ToString() != "") { model.question = reader["question"].ToString(); } if (reader["answer"] != null && reader["answer"].ToString() != "") { model.answer = reader["answer"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["logincount"] != null && reader["logincount"].ToString() != "") { model.logincount = int.Parse(reader["logincount"].ToString()); } if (reader["islock"] != null && reader["islock"].ToString() != "") { model.islock = int.Parse(reader["islock"].ToString()); } if (reader["lastmodule"] != null && reader["lastmodule"].ToString() != "") { model.lastmodule = reader["lastmodule"].ToString(); } if (reader["createdate"] != null && reader["createdate"].ToString() != "") { model.createdate = DateTime.Parse(reader["createdate"].ToString()); } if (reader["lastactivitydate"] != null && reader["lastactivitydate"].ToString() != "") { model.lastactivitydate = DateTime.Parse(reader["lastactivitydate"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnAdmin> GetAdminList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnAdmin> modelList = new List<EnAdmin>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBAdmin, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnAdmin model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnAdmin(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["name"] != null && dt.Rows[n]["name"].ToString() != "") { model.name = dt.Rows[n]["name"].ToString(); } if (dt.Rows[n]["password"] != null && dt.Rows[n]["password"].ToString() != "") { model.password = dt.Rows[n]["password"].ToString(); } if (dt.Rows[n]["displayname"] != null && dt.Rows[n]["displayname"].ToString() != "") { model.displayname = dt.Rows[n]["displayname"].ToString(); } if (dt.Rows[n]["question"] != null && dt.Rows[n]["question"].ToString() != "") { model.question = dt.Rows[n]["question"].ToString(); } if (dt.Rows[n]["answer"] != null && dt.Rows[n]["answer"].ToString() != "") { model.answer = dt.Rows[n]["answer"].ToString(); } if (dt.Rows[n]["email"] != null && dt.Rows[n]["email"].ToString() != "") { model.email = dt.Rows[n]["email"].ToString(); } if (dt.Rows[n]["phone"] != null && dt.Rows[n]["phone"].ToString() != "") { model.phone = dt.Rows[n]["phone"].ToString(); } if (dt.Rows[n]["areacode"] != null && dt.Rows[n]["areacode"].ToString() != "") { model.areacode = dt.Rows[n]["areacode"].ToString(); } if (dt.Rows[n]["address"] != null && dt.Rows[n]["address"].ToString() != "") { model.address = dt.Rows[n]["address"].ToString(); } if (dt.Rows[n]["logincount"] != null && dt.Rows[n]["logincount"].ToString() != "") { model.logincount = int.Parse(dt.Rows[n]["logincount"].ToString()); } if (dt.Rows[n]["islock"] != null && dt.Rows[n]["islock"].ToString() != "") { model.islock = int.Parse(dt.Rows[n]["islock"].ToString()); } if (dt.Rows[n]["lastmodule"] != null && dt.Rows[n]["lastmodule"].ToString() != "") { model.lastmodule = dt.Rows[n]["lastmodule"].ToString(); } if (dt.Rows[n]["createdate"] != null && dt.Rows[n]["createdate"].ToString() != "") { model.createdate = DateTime.Parse(dt.Rows[n]["createdate"].ToString()); } if (dt.Rows[n]["lastactivitydate"] != null && dt.Rows[n]["lastactivitydate"].ToString() != "") { model.lastactivitydate = DateTime.Parse(dt.Rows[n]["lastactivitydate"].ToString()); } modelList.Add(model); } } return modelList; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Administrators.cs
C#
oos
13,910
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class ProductAttributes { /// <summary> /// 更新对像 /// </summary> public static int EditProductAttribute(EnProductAttribute model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_productattribute("); strSql.Append("productid,productno,productsku,typevalue,typename,productstyle,productmaterial,productcolorimg,productcolortitle,productcolorvalue,productwidth,productheight,productlength,productcbm,buyprice,markprice,saleprice,otherinfo,storage,sort,isdefault)"); strSql.Append(" values ("); strSql.Append("@productid,@productno,@productsku,@typevalue,@typename,@productstyle,@productmaterial,@productcolorimg,@productcolortitle,@productcolorvalue,@productwidth,@productheight,@productlength,@productcbm,@buyprice,@markprice,@saleprice,@otherinfo,@storage,@sort,@isdefault)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@productid", SqlDbType.Int,4), new SqlParameter("@productno", SqlDbType.VarChar,50), new SqlParameter("@productsku", SqlDbType.VarChar,50), new SqlParameter("@typevalue", SqlDbType.NVarChar,50), new SqlParameter("@typename", SqlDbType.NVarChar,50), new SqlParameter("@productstyle", SqlDbType.NVarChar,50), new SqlParameter("@productmaterial", SqlDbType.NVarChar,50), new SqlParameter("@productcolorimg", SqlDbType.VarChar,60), new SqlParameter("@productcolortitle", SqlDbType.NVarChar,50), new SqlParameter("@productcolorvalue", SqlDbType.NVarChar,50), new SqlParameter("@productwidth", SqlDbType.Decimal,9), new SqlParameter("@productheight", SqlDbType.Decimal,9), new SqlParameter("@productlength", SqlDbType.Decimal,9), new SqlParameter("@productcbm", SqlDbType.Decimal,9), new SqlParameter("@buyprice", SqlDbType.Decimal,9), new SqlParameter("@markprice", SqlDbType.Decimal,9), new SqlParameter("@saleprice", SqlDbType.Decimal,9), new SqlParameter("@otherinfo", SqlDbType.NText), new SqlParameter("@storage", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@isdefault", SqlDbType.Int,4)}; parameters[0].Value = model.productid; parameters[1].Value = model.productno; parameters[2].Value = model.productsku; parameters[3].Value = model.typevalue; parameters[4].Value = model.typename; parameters[5].Value = model.productstyle; parameters[6].Value = model.productmaterial; parameters[7].Value = model.productcolorimg; parameters[8].Value = model.productcolortitle; parameters[9].Value = model.productcolorvalue; parameters[10].Value = model.productwidth; parameters[11].Value = model.productheight; parameters[12].Value = model.productlength; parameters[13].Value = model.productcbm; parameters[14].Value = model.buyprice; parameters[15].Value = model.markprice; parameters[16].Value = model.saleprice; parameters[17].Value = model.otherinfo; parameters[18].Value = model.storage; parameters[19].Value = model.sort; parameters[20].Value = model.isdefault; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_productattribute set "); strSql.Append("productid=@productid,"); strSql.Append("productno=@productno,"); strSql.Append("productsku=@productsku,"); strSql.Append("typevalue=@typevalue,"); strSql.Append("typename=@typename,"); strSql.Append("productstyle=@productstyle,"); strSql.Append("productmaterial=@productmaterial,"); strSql.Append("productcolorimg=@productcolorimg,"); strSql.Append("productcolortitle=@productcolortitle,"); strSql.Append("productcolorvalue=@productcolorvalue,"); strSql.Append("productwidth=@productwidth,"); strSql.Append("productheight=@productheight,"); strSql.Append("productlength=@productlength,"); strSql.Append("productcbm=@productcbm,"); strSql.Append("buyprice=@buyprice,"); strSql.Append("markprice=@markprice,"); strSql.Append("saleprice=@saleprice,"); strSql.Append("otherinfo=@otherinfo,"); strSql.Append("storage=@storage,"); strSql.Append("sort=@sort,"); strSql.Append("isdefault=@isdefault"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@productid", SqlDbType.Int,4), new SqlParameter("@productno", SqlDbType.VarChar,50), new SqlParameter("@productsku", SqlDbType.VarChar,50), new SqlParameter("@typevalue", SqlDbType.NVarChar,50), new SqlParameter("@typename", SqlDbType.NVarChar,50), new SqlParameter("@productstyle", SqlDbType.NVarChar,50), new SqlParameter("@productmaterial", SqlDbType.NVarChar,50), new SqlParameter("@productcolorimg", SqlDbType.VarChar,60), new SqlParameter("@productcolortitle", SqlDbType.NVarChar,50), new SqlParameter("@productcolorvalue", SqlDbType.NVarChar,50), new SqlParameter("@productwidth", SqlDbType.Decimal,9), new SqlParameter("@productheight", SqlDbType.Decimal,9), new SqlParameter("@productlength", SqlDbType.Decimal,9), new SqlParameter("@productcbm", SqlDbType.Decimal,9), new SqlParameter("@buyprice", SqlDbType.Decimal,9), new SqlParameter("@markprice", SqlDbType.Decimal,9), new SqlParameter("@saleprice", SqlDbType.Decimal,9), new SqlParameter("@otherinfo", SqlDbType.NText), new SqlParameter("@storage", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@isdefault", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.productid; parameters[1].Value = model.productno; parameters[2].Value = model.productsku; parameters[3].Value = model.typevalue; parameters[4].Value = model.typename; parameters[5].Value = model.productstyle; parameters[6].Value = model.productmaterial; parameters[7].Value = model.productcolorimg; parameters[8].Value = model.productcolortitle; parameters[9].Value = model.productcolorvalue; parameters[10].Value = model.productwidth; parameters[11].Value = model.productheight; parameters[12].Value = model.productlength; parameters[13].Value = model.productcbm; parameters[14].Value = model.buyprice; parameters[15].Value = model.markprice; parameters[16].Value = model.saleprice; parameters[17].Value = model.otherinfo; parameters[18].Value = model.storage; parameters[19].Value = model.sort; parameters[20].Value = model.isdefault; parameters[21].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnProductAttribute GetProductAttributeInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_ProductAttribute "); strSql.Append(strWhere); EnProductAttribute model = new EnProductAttribute(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["productid"] != null && reader["productid"].ToString() != "") { model.productid = int.Parse(reader["productid"].ToString()); } if (reader["productno"] != null && reader["productno"].ToString() != "") { model.productno = reader["productno"].ToString(); } if (reader["productsku"] != null && reader["productsku"].ToString() != "") { model.productsku = reader["productsku"].ToString(); } if (reader["typevalue"] != null && reader["typevalue"].ToString() != "") { model.typevalue = reader["typevalue"].ToString(); } if (reader["typename"] != null && reader["typename"].ToString() != "") { model.typename = reader["typename"].ToString(); } if (reader["productstyle"] != null && reader["productstyle"].ToString() != "") { model.productstyle = reader["productstyle"].ToString(); } if (reader["productmaterial"] != null && reader["productmaterial"].ToString() != "") { model.productmaterial = reader["productmaterial"].ToString(); } if (reader["productcolorimg"] != null && reader["productcolorimg"].ToString() != "") { model.productcolorimg = reader["productcolorimg"].ToString(); } if (reader["productcolortitle"] != null && reader["productcolortitle"].ToString() != "") { model.productcolortitle = reader["productcolortitle"].ToString(); } if (reader["productcolorvalue"] != null && reader["productcolorvalue"].ToString() != "") { model.productcolorvalue = reader["productcolorvalue"].ToString(); } if (reader["productwidth"] != null && reader["productwidth"].ToString() != "") { model.productwidth = decimal.Parse(reader["productwidth"].ToString()); } if (reader["productheight"] != null && reader["productheight"].ToString() != "") { model.productheight = decimal.Parse(reader["productheight"].ToString()); } if (reader["productlength"] != null && reader["productlength"].ToString() != "") { model.productlength = decimal.Parse(reader["productlength"].ToString()); } if (reader["productcbm"] != null && reader["productcbm"].ToString() != "") { model.productcbm = decimal.Parse(reader["productcbm"].ToString()); } if (reader["buyprice"] != null && reader["buyprice"].ToString() != "") { model.buyprice = decimal.Parse(reader["buyprice"].ToString()); } if (reader["markprice"] != null && reader["markprice"].ToString() != "") { model.markprice = decimal.Parse(reader["markprice"].ToString()); } if (reader["saleprice"] != null && reader["saleprice"].ToString() != "") { model.saleprice = decimal.Parse(reader["saleprice"].ToString()); } if (reader["otherinfo"] != null && reader["otherinfo"].ToString() != "") { model.otherinfo = reader["otherinfo"].ToString(); } if (reader["storage"] != null && reader["storage"].ToString() != "") { model.storage = int.Parse(reader["storage"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["isdefault"] != null && reader["isdefault"].ToString() != "") { model.isdefault = int.Parse(reader["isdefault"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnProductAttribute> GetProductAttributeList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnProductAttribute> modelList = new List<EnProductAttribute>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBProductAttribute, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnProductAttribute model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnProductAttribute(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["productid"] != null && dt.Rows[n]["productid"].ToString() != "") { model.productid = int.Parse(dt.Rows[n]["productid"].ToString()); } if (dt.Rows[n]["productno"] != null && dt.Rows[n]["productno"].ToString() != "") { model.productno = dt.Rows[n]["productno"].ToString(); } if (dt.Rows[n]["productsku"] != null && dt.Rows[n]["productsku"].ToString() != "") { model.productsku = dt.Rows[n]["productsku"].ToString(); } if (dt.Rows[n]["typevalue"] != null && dt.Rows[n]["typevalue"].ToString() != "") { model.typevalue = dt.Rows[n]["typevalue"].ToString(); } if (dt.Rows[n]["typename"] != null && dt.Rows[n]["typename"].ToString() != "") { model.typename = dt.Rows[n]["typename"].ToString(); } if (dt.Rows[n]["productstyle"] != null && dt.Rows[n]["productstyle"].ToString() != "") { model.productstyle = dt.Rows[n]["productstyle"].ToString(); } if (dt.Rows[n]["productmaterial"] != null && dt.Rows[n]["productmaterial"].ToString() != "") { model.productmaterial = dt.Rows[n]["productmaterial"].ToString(); } if (dt.Rows[n]["productcolorimg"] != null && dt.Rows[n]["productcolorimg"].ToString() != "") { model.productcolorimg = dt.Rows[n]["productcolorimg"].ToString(); } if (dt.Rows[n]["productcolortitle"] != null && dt.Rows[n]["productcolortitle"].ToString() != "") { model.productcolortitle = dt.Rows[n]["productcolortitle"].ToString(); } if (dt.Rows[n]["productcolorvalue"] != null && dt.Rows[n]["productcolorvalue"].ToString() != "") { model.productcolorvalue = dt.Rows[n]["productcolorvalue"].ToString(); } if (dt.Rows[n]["productwidth"] != null && dt.Rows[n]["productwidth"].ToString() != "") { model.productwidth = decimal.Parse(dt.Rows[n]["productwidth"].ToString()); } if (dt.Rows[n]["productheight"] != null && dt.Rows[n]["productheight"].ToString() != "") { model.productheight = decimal.Parse(dt.Rows[n]["productheight"].ToString()); } if (dt.Rows[n]["productlength"] != null && dt.Rows[n]["productlength"].ToString() != "") { model.productlength = decimal.Parse(dt.Rows[n]["productlength"].ToString()); } if (dt.Rows[n]["productcbm"] != null && dt.Rows[n]["productcbm"].ToString() != "") { model.productcbm = decimal.Parse(dt.Rows[n]["productcbm"].ToString()); } if (dt.Rows[n]["buyprice"] != null && dt.Rows[n]["buyprice"].ToString() != "") { model.buyprice = decimal.Parse(dt.Rows[n]["buyprice"].ToString()); } if (dt.Rows[n]["markprice"] != null && dt.Rows[n]["markprice"].ToString() != "") { model.markprice = decimal.Parse(dt.Rows[n]["markprice"].ToString()); } if (dt.Rows[n]["saleprice"] != null && dt.Rows[n]["saleprice"].ToString() != "") { model.saleprice = decimal.Parse(dt.Rows[n]["saleprice"].ToString()); } if (dt.Rows[n]["otherinfo"] != null && dt.Rows[n]["otherinfo"].ToString() != "") { model.otherinfo = dt.Rows[n]["otherinfo"].ToString(); } if (dt.Rows[n]["storage"] != null && dt.Rows[n]["storage"].ToString() != "") { model.storage = int.Parse(dt.Rows[n]["storage"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["isdefault"] != null && dt.Rows[n]["isdefault"].ToString() != "") { model.isdefault = int.Parse(dt.Rows[n]["isdefault"].ToString()); } modelList.Add(model); } } return modelList; } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/ProductAttributes.cs
C#
oos
20,117
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Companys { public static int ExitComapny(string title) { SqlParameter[] parames = { new SqlParameter("@title", SqlDbType.NVarChar, 30)}; parames[0].Value = title; return DataCommon.Exists(TableName.TBCompany, " where title=@title", parames); } public static EnWebCompany GetWebCompanyInfo(string strWhere) { EnWebCompany model = new EnWebCompany(); IDataReader reader = DataCommon.GetDataIReader(TableName.TVCompanyList, "", strWhere, ""); while (reader.Read()) { if (reader["brandxml"] != null && reader["brandxml"].ToString() != "") { model.brandxml = reader["brandxml"].ToString(); } if (reader["shopxml"] != null && reader["shopxml"].ToString() != "") { model.shopxml = reader["shopxml"].ToString(); } if (reader["productxml"] != null && reader["productxml"].ToString() != "") { model.productxml = reader["productxml"].ToString(); } if (reader["certifyxml"] != null && reader["certifyxml"].ToString() != "") { model.certifyxml = reader["certifyxml"].ToString(); } if (reader["productcount"] != null && reader["productcount"].ToString() != "") { model.productcount = int.Parse(reader["productcount"].ToString()); } if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["mid"] != null && reader["mid"].ToString() != "") { model.mid = int.Parse(reader["mid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["industry"] != null && reader["industry"].ToString() != "") { model.industry = reader["industry"].ToString(); } if (reader["productcategory"] != null && reader["productcategory"].ToString() != "") { model.productcategory = reader["productcategory"].ToString(); } if (reader["vip"] != null && reader["vip"].ToString() != "") { model.vip = int.Parse(reader["vip"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["mapapi"] != null && reader["mapapi"].ToString() != "") { model.mapapi = reader["mapapi"].ToString(); } if (reader["staffsize"] != null && reader["staffsize"].ToString() != "") { model.staffsize = int.Parse(reader["staffsize"].ToString()); } if (reader["regyear"] != null && reader["regyear"].ToString() != "") { model.regyear = reader["regyear"].ToString(); } if (reader["regcity"] != null && reader["regcity"].ToString() != "") { model.regcity = reader["regcity"].ToString(); } if (reader["buy"] != null && reader["buy"].ToString() != "") { model.buy = reader["buy"].ToString(); } if (reader["sell"] != null && reader["sell"].ToString() != "") { model.sell = reader["sell"].ToString(); } if (reader["linkman"] != null && reader["linkman"].ToString() != "") { model.linkman = reader["linkman"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["mphone"] != null && reader["mphone"].ToString() != "") { model.mphone = reader["mphone"].ToString(); } if (reader["fax"] != null && reader["fax"].ToString() != "") { model.fax = reader["fax"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["postcode"] != null && reader["postcode"].ToString() != "") { model.postcode = reader["postcode"].ToString(); } if (reader["homepage"] != null && reader["homepage"].ToString() != "") { model.homepage = reader["homepage"].ToString(); } if (reader["domain"] != null && reader["domain"].ToString() != "") { model.domain = reader["domain"].ToString(); } if (reader["domainip"] != null && reader["domainip"].ToString() != "") { model.domainip = reader["domainip"].ToString(); } if (reader["icp"] != null && reader["icp"].ToString() != "") { model.icp = reader["icp"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } } return model; } //企业+品牌 public static List<EnWebCompany> GetWebCompanyList(int PageIndex, int PageSize, string strWhere,string sortkey,string orderType, out int pageCount) { List<EnWebCompany> list = new List<EnWebCompany>(); IDataReader reader = DataCommon.GetPageDataReader(TableName.TVCompanyList, PageIndex, PageSize, strWhere, sortkey, orderType, out pageCount); while (reader.Read()) { EnWebCompany model = new EnWebCompany(); if (reader["brandxml"] != null && reader["brandxml"].ToString() != "") { model.brandxml = reader["brandxml"].ToString(); } if (reader["shopxml"] != null && reader["shopxml"].ToString() != "") { model.shopxml = reader["shopxml"].ToString(); } if (reader["productxml"] != null && reader["productxml"].ToString() != "") { model.productxml = reader["productxml"].ToString(); } if (reader["certifyxml"] != null && reader["certifyxml"].ToString() != "") { model.certifyxml = reader["certifyxml"].ToString(); } if (reader["productcount"] != null && reader["productcount"].ToString() != "") { model.productcount = int.Parse(reader["productcount"].ToString()); } if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["mid"] != null && reader["mid"].ToString() != "") { model.mid = int.Parse(reader["mid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["industry"] != null && reader["industry"].ToString() != "") { model.industry = reader["industry"].ToString(); } if (reader["productcategory"] != null && reader["productcategory"].ToString() != "") { model.productcategory = reader["productcategory"].ToString(); } if (reader["vip"] != null && reader["vip"].ToString() != "") { model.vip = int.Parse(reader["vip"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["mapapi"] != null && reader["mapapi"].ToString() != "") { model.mapapi = reader["mapapi"].ToString(); } if (reader["staffsize"] != null && reader["staffsize"].ToString() != "") { model.staffsize = int.Parse(reader["staffsize"].ToString()); } if (reader["regyear"] != null && reader["regyear"].ToString() != "") { model.regyear = reader["regyear"].ToString(); } if (reader["regcity"] != null && reader["regcity"].ToString() != "") { model.regcity = reader["regcity"].ToString(); } if (reader["buy"] != null && reader["buy"].ToString() != "") { model.buy = reader["buy"].ToString(); } if (reader["sell"] != null && reader["sell"].ToString() != "") { model.sell = reader["sell"].ToString(); } if (reader["linkman"] != null && reader["linkman"].ToString() != "") { model.linkman = reader["linkman"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["mphone"] != null && reader["mphone"].ToString() != "") { model.mphone = reader["mphone"].ToString(); } if (reader["fax"] != null && reader["fax"].ToString() != "") { model.fax = reader["fax"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["postcode"] != null && reader["postcode"].ToString() != "") { model.postcode = reader["postcode"].ToString(); } if (reader["homepage"] != null && reader["homepage"].ToString() != "") { model.homepage = reader["homepage"].ToString(); } if (reader["domain"] != null && reader["domain"].ToString() != "") { model.domain = reader["domain"].ToString(); } if (reader["domainip"] != null && reader["domainip"].ToString() != "") { model.domainip = reader["domainip"].ToString(); } if (reader["icp"] != null && reader["icp"].ToString() != "") { model.icp = reader["icp"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } list.Add(model); } return list; } //品牌+企业 public static List<EnWebCompanyBrand> GetWebCompanyBrandList(int PageIndex, int PageSize, string strWhere,string sortkey, string ordertype, out int pageCount) { List<EnWebCompanyBrand> list = new List<EnWebCompanyBrand>(); IDataReader reader = DataCommon.GetPageDataReader(TableName.TVCompanyBrandList, PageIndex, PageSize, strWhere, sortkey, ordertype, out pageCount); while (reader.Read()) { EnWebCompanyBrand model = new EnWebCompanyBrand(); if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["mid"] != null && reader["mid"].ToString() != "") { model.mid = int.Parse(reader["mid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["industry"] != null && reader["industry"].ToString() != "") { model.industry = reader["industry"].ToString(); } if (reader["productcategory"] != null && reader["productcategory"].ToString() != "") { model.productcategory = reader["productcategory"].ToString(); } if (reader["vip"] != null && reader["vip"].ToString() != "") { model.vip = int.Parse(reader["vip"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["mapapi"] != null && reader["mapapi"].ToString() != "") { model.mapapi = reader["mapapi"].ToString(); } if (reader["staffsize"] != null && reader["staffsize"].ToString() != "") { model.staffsize = int.Parse(reader["staffsize"].ToString()); } if (reader["regyear"] != null && reader["regyear"].ToString() != "") { model.regyear = reader["regyear"].ToString(); } if (reader["regcity"] != null && reader["regcity"].ToString() != "") { model.regcity = reader["regcity"].ToString(); } if (reader["buy"] != null && reader["buy"].ToString() != "") { model.buy = reader["buy"].ToString(); } if (reader["sell"] != null && reader["sell"].ToString() != "") { model.sell = reader["sell"].ToString(); } if (reader["linkman"] != null && reader["linkman"].ToString() != "") { model.linkman = reader["linkman"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["mphone"] != null && reader["mphone"].ToString() != "") { model.mphone = reader["mphone"].ToString(); } if (reader["fax"] != null && reader["fax"].ToString() != "") { model.fax = reader["fax"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["postcode"] != null && reader["postcode"].ToString() != "") { model.postcode = reader["postcode"].ToString(); } if (reader["homepage"] != null && reader["homepage"].ToString() != "") { model.homepage = reader["homepage"].ToString(); } if (reader["domain"] != null && reader["domain"].ToString() != "") { model.domain = reader["domain"].ToString(); } if (reader["domainip"] != null && reader["domainip"].ToString() != "") { model.domainip = reader["domainip"].ToString(); } if (reader["icp"] != null && reader["icp"].ToString() != "") { model.icp = reader["icp"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } if (reader["brandid"] != null && reader["brandid"].ToString() != "") { model.brandid = int.Parse(reader["brandid"].ToString()); } if (reader["brandtitle"] != null && reader["brandtitle"].ToString() != "") { model.brandtitle = reader["brandtitle"].ToString(); } if (reader["brandthumb"] != null && reader["brandthumb"].ToString() != "") { model.brandthumb = reader["brandthumb"].ToString(); } if (reader["stylevalue"] != null && reader["stylevalue"].ToString() != "") { model.stylevalue = reader["stylevalue"].ToString(); } if (reader["materialvalue"] != null && reader["materialvalue"].ToString() != "") { model.materialvalue = reader["materialvalue"].ToString(); } if (reader["spreadvalue"] != null && reader["spreadvalue"].ToString() != "") { model.spreadvalue = reader["spreadvalue"].ToString(); } if (reader["brandlinestatus"] != null && reader["brandlinestatus"].ToString() != "") { model.brandlinestatus = int.Parse(reader["brandlinestatus"].ToString()); } list.Add(model); } return list; } //企业搜索选项 public static List<EnSearchItem> GetCompanySearchItem() { List<EnSearchItem> list = new List<EnSearchItem>(); IDataReader reader = DbHelper.ExecuteReader(" select * from "+TableName.TVCompanySearchItem); while (reader.Read()) { EnSearchItem model = new EnSearchItem(); if (reader["t"] != null && reader["t"].ToString() != "") { model.type = reader["t"].ToString(); } if (reader["v"] != null && reader["v"].ToString() != "") { model.value = reader["v"].ToString(); } if (reader["n"] != null && reader["n"].ToString() != "") { model.title = reader["n"].ToString(); } if (reader["c"] != null && reader["c"].ToString() != "") { model.count = int.Parse(reader["c"].ToString()); } model.isCur = false; list.Add(model); } return list; } #region 共公模块 /// <summary> /// 更新对像 /// </summary> public static int EditCompany(EnCompany model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_company("); strSql.Append("mid,title,letter,groupid,attribute,industry,productcategory,vip,areacode,address,mapapi,staffsize,regyear,regcity,buy,sell,linkman,phone,mphone,fax,email,postcode,homepage,domain,domainip,icp,surface,logo,thumb,bannel,desimage,descript,keywords,template,hits,sort,createmid,lastedid,lastedittime,auditstatus,linestatus)"); strSql.Append(" values ("); strSql.Append("@mid,@title,@letter,@groupid,@attribute,@industry,@productcategory,@vip,@areacode,@address,@mapapi,@staffsize,@regyear,@regcity,@buy,@sell,@linkman,@phone,@mphone,@fax,@email,@postcode,@homepage,@domain,@domainip,@icp,@surface,@logo,@thumb,@bannel,@desimage,@descript,@keywords,@template,@hits,@sort,@createmid,@lastedid,@lastedittime,@auditstatus,@linestatus)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@mid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@groupid", SqlDbType.Int,4), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@industry", SqlDbType.VarChar,50), new SqlParameter("@productcategory", SqlDbType.VarChar,50), new SqlParameter("@vip", SqlDbType.Int,4), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,60), new SqlParameter("@mapapi", SqlDbType.NVarChar,80), new SqlParameter("@staffsize", SqlDbType.Int,4), new SqlParameter("@regyear", SqlDbType.VarChar,7), new SqlParameter("@regcity", SqlDbType.VarChar,10), new SqlParameter("@buy", SqlDbType.NVarChar,300), new SqlParameter("@sell", SqlDbType.NVarChar,300), new SqlParameter("@linkman", SqlDbType.NVarChar,20), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@mphone", SqlDbType.VarChar,20), new SqlParameter("@fax", SqlDbType.VarChar,20), new SqlParameter("@email", SqlDbType.VarChar,50), new SqlParameter("@postcode", SqlDbType.VarChar,15), new SqlParameter("@homepage", SqlDbType.VarChar,50), new SqlParameter("@domain", SqlDbType.VarChar,50), new SqlParameter("@domainip", SqlDbType.VarChar,50), new SqlParameter("@icp", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4)}; parameters[0].Value = model.mid; parameters[1].Value = model.title; parameters[2].Value = model.letter; parameters[3].Value = model.groupid; parameters[4].Value = model.attribute; parameters[5].Value = model.industry; parameters[6].Value = model.productcategory; parameters[7].Value = model.vip; parameters[8].Value = model.areacode; parameters[9].Value = model.address; parameters[10].Value = model.mapapi; parameters[11].Value = model.staffsize; parameters[12].Value = model.regyear; parameters[13].Value = model.regcity; parameters[14].Value = model.buy; parameters[15].Value = model.sell; parameters[16].Value = model.linkman; parameters[17].Value = model.phone; parameters[18].Value = model.mphone; parameters[19].Value = model.fax; parameters[20].Value = model.email; parameters[21].Value = model.postcode; parameters[22].Value = model.homepage; parameters[23].Value = model.domain; parameters[24].Value = model.domainip; parameters[25].Value = model.icp; parameters[26].Value = model.surface; parameters[27].Value = model.logo; parameters[28].Value = model.thumb; parameters[29].Value = model.bannel; parameters[30].Value = model.desimage; parameters[31].Value = model.descript; parameters[32].Value = model.keywords; parameters[33].Value = model.template; parameters[34].Value = model.hits; parameters[35].Value = model.sort; parameters[36].Value = model.createmid; parameters[37].Value = model.lastedid; parameters[38].Value = model.lastedittime; parameters[39].Value = model.auditstatus; parameters[40].Value = model.linestatus; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_company set "); strSql.Append("mid=@mid,"); strSql.Append("title=@title,"); strSql.Append("letter=@letter,"); strSql.Append("groupid=@groupid,"); strSql.Append("attribute=@attribute,"); strSql.Append("industry=@industry,"); strSql.Append("productcategory=@productcategory,"); strSql.Append("vip=@vip,"); strSql.Append("areacode=@areacode,"); strSql.Append("address=@address,"); strSql.Append("mapapi=@mapapi,"); strSql.Append("staffsize=@staffsize,"); strSql.Append("regyear=@regyear,"); strSql.Append("regcity=@regcity,"); strSql.Append("buy=@buy,"); strSql.Append("sell=@sell,"); strSql.Append("linkman=@linkman,"); strSql.Append("phone=@phone,"); strSql.Append("mphone=@mphone,"); strSql.Append("fax=@fax,"); strSql.Append("email=@email,"); strSql.Append("postcode=@postcode,"); strSql.Append("homepage=@homepage,"); strSql.Append("domain=@domain,"); strSql.Append("domainip=@domainip,"); strSql.Append("icp=@icp,"); strSql.Append("surface=@surface,"); strSql.Append("logo=@logo,"); strSql.Append("thumb=@thumb,"); strSql.Append("bannel=@bannel,"); strSql.Append("desimage=@desimage,"); strSql.Append("descript=@descript,"); strSql.Append("keywords=@keywords,"); strSql.Append("template=@template,"); strSql.Append("hits=@hits,"); strSql.Append("sort=@sort,"); strSql.Append("createmid=@createmid,"); strSql.Append("lastedid=@lastedid,"); strSql.Append("lastedittime=@lastedittime,"); strSql.Append("auditstatus=@auditstatus,"); strSql.Append("linestatus=@linestatus"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@mid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@groupid", SqlDbType.Int,4), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@industry", SqlDbType.VarChar,50), new SqlParameter("@productcategory", SqlDbType.VarChar,50), new SqlParameter("@vip", SqlDbType.Int,4), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,60), new SqlParameter("@mapapi", SqlDbType.NVarChar,80), new SqlParameter("@staffsize", SqlDbType.Int,4), new SqlParameter("@regyear", SqlDbType.VarChar,7), new SqlParameter("@regcity", SqlDbType.VarChar,10), new SqlParameter("@buy", SqlDbType.NVarChar,300), new SqlParameter("@sell", SqlDbType.NVarChar,300), new SqlParameter("@linkman", SqlDbType.NVarChar,20), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@mphone", SqlDbType.VarChar,20), new SqlParameter("@fax", SqlDbType.VarChar,20), new SqlParameter("@email", SqlDbType.VarChar,50), new SqlParameter("@postcode", SqlDbType.VarChar,15), new SqlParameter("@homepage", SqlDbType.VarChar,50), new SqlParameter("@domain", SqlDbType.VarChar,50), new SqlParameter("@domainip", SqlDbType.VarChar,50), new SqlParameter("@icp", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.mid; parameters[1].Value = model.title; parameters[2].Value = model.letter; parameters[3].Value = model.groupid; parameters[4].Value = model.attribute; parameters[5].Value = model.industry; parameters[6].Value = model.productcategory; parameters[7].Value = model.vip; parameters[8].Value = model.areacode; parameters[9].Value = model.address; parameters[10].Value = model.mapapi; parameters[11].Value = model.staffsize; parameters[12].Value = model.regyear; parameters[13].Value = model.regcity; parameters[14].Value = model.buy; parameters[15].Value = model.sell; parameters[16].Value = model.linkman; parameters[17].Value = model.phone; parameters[18].Value = model.mphone; parameters[19].Value = model.fax; parameters[20].Value = model.email; parameters[21].Value = model.postcode; parameters[22].Value = model.homepage; parameters[23].Value = model.domain; parameters[24].Value = model.domainip; parameters[25].Value = model.icp; parameters[26].Value = model.surface; parameters[27].Value = model.logo; parameters[28].Value = model.thumb; parameters[29].Value = model.bannel; parameters[30].Value = model.desimage; parameters[31].Value = model.descript; parameters[32].Value = model.keywords; parameters[33].Value = model.template; parameters[34].Value = model.hits; parameters[35].Value = model.sort; parameters[36].Value = model.createmid; parameters[37].Value = model.lastedid; parameters[38].Value = model.lastedittime; parameters[39].Value = model.auditstatus; parameters[40].Value = model.linestatus; parameters[41].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnCompany GetCompanyInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Company "); strSql.Append(strWhere); EnCompany model = new EnCompany(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["mid"] != null && reader["mid"].ToString() != "") { model.mid = int.Parse(reader["mid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["industry"] != null && reader["industry"].ToString() != "") { model.industry = reader["industry"].ToString(); } if (reader["productcategory"] != null && reader["productcategory"].ToString() != "") { model.productcategory = reader["productcategory"].ToString(); } if (reader["vip"] != null && reader["vip"].ToString() != "") { model.vip = int.Parse(reader["vip"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["mapapi"] != null && reader["mapapi"].ToString() != "") { model.mapapi = reader["mapapi"].ToString(); } if (reader["staffsize"] != null && reader["staffsize"].ToString() != "") { model.staffsize = int.Parse(reader["staffsize"].ToString()); } if (reader["regyear"] != null && reader["regyear"].ToString() != "") { model.regyear = reader["regyear"].ToString(); } if (reader["regcity"] != null && reader["regcity"].ToString() != "") { model.regcity = reader["regcity"].ToString(); } if (reader["buy"] != null && reader["buy"].ToString() != "") { model.buy = reader["buy"].ToString(); } if (reader["sell"] != null && reader["sell"].ToString() != "") { model.sell = reader["sell"].ToString(); } if (reader["linkman"] != null && reader["linkman"].ToString() != "") { model.linkman = reader["linkman"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["mphone"] != null && reader["mphone"].ToString() != "") { model.mphone = reader["mphone"].ToString(); } if (reader["fax"] != null && reader["fax"].ToString() != "") { model.fax = reader["fax"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["postcode"] != null && reader["postcode"].ToString() != "") { model.postcode = reader["postcode"].ToString(); } if (reader["homepage"] != null && reader["homepage"].ToString() != "") { model.homepage = reader["homepage"].ToString(); } if (reader["domain"] != null && reader["domain"].ToString() != "") { model.domain = reader["domain"].ToString(); } if (reader["domainip"] != null && reader["domainip"].ToString() != "") { model.domainip = reader["domainip"].ToString(); } if (reader["icp"] != null && reader["icp"].ToString() != "") { model.icp = reader["icp"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnCompany> GetCompanyList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnCompany> modelList = new List<EnCompany>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBCompany, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnCompany model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnCompany(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["mid"] != null && dt.Rows[n]["mid"].ToString() != "") { model.mid = int.Parse(dt.Rows[n]["mid"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["groupid"] != null && dt.Rows[n]["groupid"].ToString() != "") { model.groupid = int.Parse(dt.Rows[n]["groupid"].ToString()); } if (dt.Rows[n]["attribute"] != null && dt.Rows[n]["attribute"].ToString() != "") { model.attribute = dt.Rows[n]["attribute"].ToString(); } if (dt.Rows[n]["industry"] != null && dt.Rows[n]["industry"].ToString() != "") { model.industry = dt.Rows[n]["industry"].ToString(); } if (dt.Rows[n]["productcategory"] != null && dt.Rows[n]["productcategory"].ToString() != "") { model.productcategory = dt.Rows[n]["productcategory"].ToString(); } if (dt.Rows[n]["vip"] != null && dt.Rows[n]["vip"].ToString() != "") { model.vip = int.Parse(dt.Rows[n]["vip"].ToString()); } if (dt.Rows[n]["areacode"] != null && dt.Rows[n]["areacode"].ToString() != "") { model.areacode = dt.Rows[n]["areacode"].ToString(); } if (dt.Rows[n]["address"] != null && dt.Rows[n]["address"].ToString() != "") { model.address = dt.Rows[n]["address"].ToString(); } if (dt.Rows[n]["mapapi"] != null && dt.Rows[n]["mapapi"].ToString() != "") { model.mapapi = dt.Rows[n]["mapapi"].ToString(); } if (dt.Rows[n]["staffsize"] != null && dt.Rows[n]["staffsize"].ToString() != "") { model.staffsize = int.Parse(dt.Rows[n]["staffsize"].ToString()); } if (dt.Rows[n]["regyear"] != null && dt.Rows[n]["regyear"].ToString() != "") { model.regyear = dt.Rows[n]["regyear"].ToString(); } if (dt.Rows[n]["regcity"] != null && dt.Rows[n]["regcity"].ToString() != "") { model.regcity = dt.Rows[n]["regcity"].ToString(); } if (dt.Rows[n]["buy"] != null && dt.Rows[n]["buy"].ToString() != "") { model.buy = dt.Rows[n]["buy"].ToString(); } if (dt.Rows[n]["sell"] != null && dt.Rows[n]["sell"].ToString() != "") { model.sell = dt.Rows[n]["sell"].ToString(); } if (dt.Rows[n]["linkman"] != null && dt.Rows[n]["linkman"].ToString() != "") { model.linkman = dt.Rows[n]["linkman"].ToString(); } if (dt.Rows[n]["phone"] != null && dt.Rows[n]["phone"].ToString() != "") { model.phone = dt.Rows[n]["phone"].ToString(); } if (dt.Rows[n]["mphone"] != null && dt.Rows[n]["mphone"].ToString() != "") { model.mphone = dt.Rows[n]["mphone"].ToString(); } if (dt.Rows[n]["fax"] != null && dt.Rows[n]["fax"].ToString() != "") { model.fax = dt.Rows[n]["fax"].ToString(); } if (dt.Rows[n]["email"] != null && dt.Rows[n]["email"].ToString() != "") { model.email = dt.Rows[n]["email"].ToString(); } if (dt.Rows[n]["postcode"] != null && dt.Rows[n]["postcode"].ToString() != "") { model.postcode = dt.Rows[n]["postcode"].ToString(); } if (dt.Rows[n]["homepage"] != null && dt.Rows[n]["homepage"].ToString() != "") { model.homepage = dt.Rows[n]["homepage"].ToString(); } if (dt.Rows[n]["domain"] != null && dt.Rows[n]["domain"].ToString() != "") { model.domain = dt.Rows[n]["domain"].ToString(); } if (dt.Rows[n]["domainip"] != null && dt.Rows[n]["domainip"].ToString() != "") { model.domainip = dt.Rows[n]["domainip"].ToString(); } if (dt.Rows[n]["icp"] != null && dt.Rows[n]["icp"].ToString() != "") { model.icp = dt.Rows[n]["icp"].ToString(); } if (dt.Rows[n]["surface"] != null && dt.Rows[n]["surface"].ToString() != "") { model.surface = dt.Rows[n]["surface"].ToString(); } if (dt.Rows[n]["logo"] != null && dt.Rows[n]["logo"].ToString() != "") { model.logo = dt.Rows[n]["logo"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["bannel"] != null && dt.Rows[n]["bannel"].ToString() != "") { model.bannel = dt.Rows[n]["bannel"].ToString(); } if (dt.Rows[n]["desimage"] != null && dt.Rows[n]["desimage"].ToString() != "") { model.desimage = dt.Rows[n]["desimage"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["keywords"] != null && dt.Rows[n]["keywords"].ToString() != "") { model.keywords = dt.Rows[n]["keywords"].ToString(); } if (dt.Rows[n]["template"] != null && dt.Rows[n]["template"].ToString() != "") { model.template = dt.Rows[n]["template"].ToString(); } if (dt.Rows[n]["hits"] != null && dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["createmid"] != null && dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } if (dt.Rows[n]["lastedid"] != null && dt.Rows[n]["lastedid"].ToString() != "") { model.lastedid = int.Parse(dt.Rows[n]["lastedid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["auditstatus"] != null && dt.Rows[n]["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(dt.Rows[n]["auditstatus"].ToString()); } if (dt.Rows[n]["linestatus"] != null && dt.Rows[n]["linestatus"].ToString() != "") { model.linestatus = int.Parse(dt.Rows[n]["linestatus"].ToString()); } modelList.Add(model); } } return modelList; } #endregion #region 共公模块-组 /// <summary> /// 更新对像 /// </summary> public static int EditCompanyGroup(EnCompanyGroup model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_companygroup("); strSql.Append("title,color,avatar,integral,money,adcount,shopcount,brandcount,promotioncount,adrecommend,shoprecommend,brandrecommend,promotionrecommend,permissions,lev,descript,sort)"); strSql.Append(" values ("); strSql.Append("@title,@color,@avatar,@integral,@money,@adcount,@shopcount,@brandcount,@promotioncount,@adrecommend,@shoprecommend,@brandrecommend,@promotionrecommend,@permissions,@lev,@descript,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@color", SqlDbType.Char,7), new SqlParameter("@avatar", SqlDbType.VarChar,40), new SqlParameter("@integral", SqlDbType.Decimal,9), new SqlParameter("@money", SqlDbType.Decimal,9), new SqlParameter("@adcount", SqlDbType.Int,4), new SqlParameter("@shopcount", SqlDbType.Int,4), new SqlParameter("@brandcount", SqlDbType.Int,4), new SqlParameter("@promotioncount", SqlDbType.Int,4), new SqlParameter("@adrecommend", SqlDbType.Int,4), new SqlParameter("@shoprecommend", SqlDbType.Int,4), new SqlParameter("@brandrecommend", SqlDbType.Int,4), new SqlParameter("@promotionrecommend", SqlDbType.Int,4), new SqlParameter("@permissions", SqlDbType.NText), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.color; parameters[2].Value = model.avatar; parameters[3].Value = model.integral; parameters[4].Value = model.money; parameters[5].Value = model.adcount; parameters[6].Value = model.shopcount; parameters[7].Value = model.brandcount; parameters[8].Value = model.promotioncount; parameters[9].Value = model.adrecommend; parameters[10].Value = model.shoprecommend; parameters[11].Value = model.brandrecommend; parameters[12].Value = model.promotionrecommend; parameters[13].Value = model.permissions; parameters[14].Value = model.lev; parameters[15].Value = model.descript; parameters[16].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_companygroup set "); strSql.Append("title=@title,"); strSql.Append("color=@color,"); strSql.Append("avatar=@avatar,"); strSql.Append("integral=@integral,"); strSql.Append("money=@money,"); strSql.Append("adcount=@adcount,"); strSql.Append("shopcount=@shopcount,"); strSql.Append("brandcount=@brandcount,"); strSql.Append("promotioncount=@promotioncount,"); strSql.Append("adrecommend=@adrecommend,"); strSql.Append("shoprecommend=@shoprecommend,"); strSql.Append("brandrecommend=@brandrecommend,"); strSql.Append("promotionrecommend=@promotionrecommend,"); strSql.Append("permissions=@permissions,"); strSql.Append("lev=@lev,"); strSql.Append("descript=@descript,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@color", SqlDbType.Char,7), new SqlParameter("@avatar", SqlDbType.VarChar,40), new SqlParameter("@integral", SqlDbType.Decimal,9), new SqlParameter("@money", SqlDbType.Decimal,9), new SqlParameter("@adcount", SqlDbType.Int,4), new SqlParameter("@shopcount", SqlDbType.Int,4), new SqlParameter("@brandcount", SqlDbType.Int,4), new SqlParameter("@promotioncount", SqlDbType.Int,4), new SqlParameter("@adrecommend", SqlDbType.Int,4), new SqlParameter("@shoprecommend", SqlDbType.Int,4), new SqlParameter("@brandrecommend", SqlDbType.Int,4), new SqlParameter("@promotionrecommend", SqlDbType.Int,4), new SqlParameter("@permissions", SqlDbType.NText), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.color; parameters[2].Value = model.avatar; parameters[3].Value = model.integral; parameters[4].Value = model.money; parameters[5].Value = model.adcount; parameters[6].Value = model.shopcount; parameters[7].Value = model.brandcount; parameters[8].Value = model.promotioncount; parameters[9].Value = model.adrecommend; parameters[10].Value = model.shoprecommend; parameters[11].Value = model.brandrecommend; parameters[12].Value = model.promotionrecommend; parameters[13].Value = model.permissions; parameters[14].Value = model.lev; parameters[15].Value = model.descript; parameters[16].Value = model.sort; parameters[17].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnCompanyGroup GetCompanyGroupInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_CompanyGroup "); strSql.Append(strWhere); EnCompanyGroup model = new EnCompanyGroup(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["color"] != null && reader["color"].ToString() != "") { model.color = reader["color"].ToString(); } if (reader["avatar"] != null && reader["avatar"].ToString() != "") { model.avatar = reader["avatar"].ToString(); } if (reader["integral"] != null && reader["integral"].ToString() != "") { model.integral = decimal.Parse(reader["integral"].ToString()); } if (reader["money"] != null && reader["money"].ToString() != "") { model.money = decimal.Parse(reader["money"].ToString()); } if (reader["adcount"] != null && reader["adcount"].ToString() != "") { model.adcount = int.Parse(reader["adcount"].ToString()); } if (reader["shopcount"] != null && reader["shopcount"].ToString() != "") { model.shopcount = int.Parse(reader["shopcount"].ToString()); } if (reader["brandcount"] != null && reader["brandcount"].ToString() != "") { model.brandcount = int.Parse(reader["brandcount"].ToString()); } if (reader["promotioncount"] != null && reader["promotioncount"].ToString() != "") { model.promotioncount = int.Parse(reader["promotioncount"].ToString()); } if (reader["adrecommend"] != null && reader["adrecommend"].ToString() != "") { model.adrecommend = int.Parse(reader["adrecommend"].ToString()); } if (reader["shoprecommend"] != null && reader["shoprecommend"].ToString() != "") { model.shoprecommend = int.Parse(reader["shoprecommend"].ToString()); } if (reader["brandrecommend"] != null && reader["brandrecommend"].ToString() != "") { model.brandrecommend = int.Parse(reader["brandrecommend"].ToString()); } if (reader["promotionrecommend"] != null && reader["promotionrecommend"].ToString() != "") { model.promotionrecommend = int.Parse(reader["promotionrecommend"].ToString()); } if (reader["permissions"] != null && reader["permissions"].ToString() != "") { model.permissions = reader["permissions"].ToString(); } if (reader["lev"] != null && reader["lev"].ToString() != "") { model.lev = int.Parse(reader["lev"].ToString()); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnCompanyGroup> GetCompanyGroupList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnCompanyGroup> modelList = new List<EnCompanyGroup>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBCompanyGroup, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnCompanyGroup model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnCompanyGroup(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["color"] != null && dt.Rows[n]["color"].ToString() != "") { model.color = dt.Rows[n]["color"].ToString(); } if (dt.Rows[n]["avatar"] != null && dt.Rows[n]["avatar"].ToString() != "") { model.avatar = dt.Rows[n]["avatar"].ToString(); } if (dt.Rows[n]["integral"] != null && dt.Rows[n]["integral"].ToString() != "") { model.integral = decimal.Parse(dt.Rows[n]["integral"].ToString()); } if (dt.Rows[n]["money"] != null && dt.Rows[n]["money"].ToString() != "") { model.money = decimal.Parse(dt.Rows[n]["money"].ToString()); } if (dt.Rows[n]["adcount"] != null && dt.Rows[n]["adcount"].ToString() != "") { model.adcount = int.Parse(dt.Rows[n]["adcount"].ToString()); } if (dt.Rows[n]["shopcount"] != null && dt.Rows[n]["shopcount"].ToString() != "") { model.shopcount = int.Parse(dt.Rows[n]["shopcount"].ToString()); } if (dt.Rows[n]["brandcount"] != null && dt.Rows[n]["brandcount"].ToString() != "") { model.brandcount = int.Parse(dt.Rows[n]["brandcount"].ToString()); } if (dt.Rows[n]["promotioncount"] != null && dt.Rows[n]["promotioncount"].ToString() != "") { model.promotioncount = int.Parse(dt.Rows[n]["promotioncount"].ToString()); } if (dt.Rows[n]["adrecommend"] != null && dt.Rows[n]["adrecommend"].ToString() != "") { model.adrecommend = int.Parse(dt.Rows[n]["adrecommend"].ToString()); } if (dt.Rows[n]["shoprecommend"] != null && dt.Rows[n]["shoprecommend"].ToString() != "") { model.shoprecommend = int.Parse(dt.Rows[n]["shoprecommend"].ToString()); } if (dt.Rows[n]["brandrecommend"] != null && dt.Rows[n]["brandrecommend"].ToString() != "") { model.brandrecommend = int.Parse(dt.Rows[n]["brandrecommend"].ToString()); } if (dt.Rows[n]["promotionrecommend"] != null && dt.Rows[n]["promotionrecommend"].ToString() != "") { model.promotionrecommend = int.Parse(dt.Rows[n]["promotionrecommend"].ToString()); } if (dt.Rows[n]["permissions"] != null && dt.Rows[n]["permissions"].ToString() != "") { model.permissions = dt.Rows[n]["permissions"].ToString(); } if (dt.Rows[n]["lev"] != null && dt.Rows[n]["lev"].ToString() != "") { model.lev = int.Parse(dt.Rows[n]["lev"].ToString()); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Companys.cs
C#
oos
79,853
using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Permissions { #region 共公模块 /// <summary> /// 更新对像 /// </summary> public static int EditModule(EnModule model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_sys_module("); strSql.Append("title,mark,type,descript,sort)"); strSql.Append(" values ("); strSql.Append("@title,@mark,@type,@descript,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@mark", SqlDbType.VarChar,20), new SqlParameter("@type", SqlDbType.VarChar,50), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.mark; parameters[2].Value = model.type; parameters[3].Value = model.descript; parameters[4].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_sys_module set "); strSql.Append("title=@title,"); strSql.Append("mark=@mark,"); strSql.Append("descript=@descript,"); strSql.Append("sort=@sort,"); strSql.Append("type=@type"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@mark", SqlDbType.VarChar,20), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@type", SqlDbType.VarChar,50), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.mark; parameters[2].Value = model.descript; parameters[3].Value = model.sort; parameters[4].Value = model.type; parameters[5].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnModule GetModuleInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from t_sys_module "); strSql.Append(strWhere); EnModule model = new EnModule(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["mark"] != null && reader["mark"].ToString() != "") { model.mark = reader["mark"].ToString(); } if (reader["type"] != null && reader["type"].ToString() != "") { model.type = reader["type"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnModule> GetModuleList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnModule> modelList = new List<EnModule>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBSystemModule, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnModule model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnModule(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["mark"] != null && dt.Rows[n]["mark"].ToString() != "") { model.mark = dt.Rows[n]["mark"].ToString(); } if (dt.Rows[n]["type"] != null && dt.Rows[n]["type"].ToString() != "") { model.type = dt.Rows[n]["type"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } #endregion #region 共公模块连接 /// <summary> /// 更新对像 /// </summary> public static int EditModuleLink(EnModuleLink model) { DbHelper.ExecuteNonQuery(CommandType.Text, " delete from t_sys_module where mid=" + model.ModuleId); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_sys_module_link("); strSql.Append("mid,title,icourl,linkurl)"); strSql.Append(" values ("); strSql.Append("@mid,@title,@icourl,@linkurl)"); SqlParameter[] parameters = { new SqlParameter("@mid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@icourl", SqlDbType.VarChar,40), new SqlParameter("@linkurl", SqlDbType.VarChar,40)}; parameters[0].Value = model.ModuleId; parameters[1].Value = model.title; parameters[2].Value = model.icourl; parameters[3].Value = model.linkurl; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } return 0; } /// <summary> /// 获得数据列表 /// </summary> public static List<EnModuleLink> GetModuleLinkList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnModuleLink> modelList = new List<EnModuleLink>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBSystemModuleLink, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnModuleLink model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnModuleLink(); if (dt.Rows[n]["mid"] != null && dt.Rows[n]["mid"].ToString() != "") { model.ModuleId = int.Parse(dt.Rows[n]["mid"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["icourl"] != null && dt.Rows[n]["icourl"].ToString() != "") { model.icourl = dt.Rows[n]["icourl"].ToString(); } if (dt.Rows[n]["linkurl"] != null && dt.Rows[n]["linkurl"].ToString() != "") { model.linkurl = dt.Rows[n]["linkurl"].ToString(); } modelList.Add(model); } } return modelList; } #endregion #region 共公动作 /// <summary> /// 更新对像 /// </summary> public static int EditAction(EnAction model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_sys_action("); strSql.Append("title,mark,mid,actype,descript,sort)"); strSql.Append(" values ("); strSql.Append("@title,@mark,@mid,@actype,@descript,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@mark", SqlDbType.VarChar,30), new SqlParameter("@mid", SqlDbType.Int,4), new SqlParameter("@actype", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.mark; parameters[2].Value = model.mid; parameters[3].Value = model.actype; parameters[4].Value = model.descript; parameters[5].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_sys_action set "); strSql.Append("title=@title,"); strSql.Append("mark=@mark,"); strSql.Append("mid=@mid,"); strSql.Append("actype=@actype,"); strSql.Append("descript=@descript,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@mark", SqlDbType.VarChar,30), new SqlParameter("@mid", SqlDbType.Int,4), new SqlParameter("@actype", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.mark; parameters[2].Value = model.mid; parameters[3].Value = model.actype; parameters[4].Value = model.descript; parameters[5].Value = model.sort; parameters[6].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnAction GetActionInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from " + TableName.TBSystemAction + " "); strSql.Append(strWhere); EnAction model = new EnAction(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["mark"] != null && reader["mark"].ToString() != "") { model.mark = reader["mark"].ToString(); } if (reader["mid"] != null && reader["mid"].ToString() != "") { model.mid = int.Parse(reader["mid"].ToString()); } if (reader["actype"] != null && reader["actype"].ToString() != "") { model.actype = int.Parse(reader["actype"].ToString()); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnAction> GetActionList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnAction> modelList = new List<EnAction>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBSystemAction, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnAction model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnAction(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["mark"] != null && dt.Rows[n]["mark"].ToString() != "") { model.mark = dt.Rows[n]["mark"].ToString(); } if (dt.Rows[n]["mid"] != null && dt.Rows[n]["mid"].ToString() != "") { model.mid = int.Parse(dt.Rows[n]["mid"].ToString()); } if (dt.Rows[n]["actype"] != null && dt.Rows[n]["actype"].ToString() != "") { model.actype = int.Parse(dt.Rows[n]["actype"].ToString()); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } #endregion #region 共公角色 /// <summary> /// 更新对像 /// </summary> public static int EditRole(EnRole model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_sys_role("); strSql.Append("parentid,title,mark,descript,sort)"); strSql.Append(" values ("); strSql.Append("@parentid,@title,@mark,@descript,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@parentid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@mark", SqlDbType.VarChar,20), new SqlParameter("@descript", SqlDbType.NVarChar,200), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.parentid; parameters[1].Value = model.title; parameters[2].Value = model.mark; parameters[3].Value = model.descript; parameters[4].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_sys_role set "); strSql.Append("parentid=@parentid,"); strSql.Append("title=@title,"); strSql.Append("mark=@mark,"); strSql.Append("descript=@descript,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@parentid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@mark", SqlDbType.VarChar,20), new SqlParameter("@descript", SqlDbType.NVarChar,200), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.parentid; parameters[1].Value = model.title; parameters[2].Value = model.mark; parameters[3].Value = model.descript; parameters[4].Value = model.sort; parameters[5].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnRole GetRoleInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from " + TableName.TBSystemRole + " "); strSql.Append(strWhere); EnRole model = new EnRole(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["parentid"] != null && reader["parentid"].ToString() != "") { model.parentid = int.Parse(reader["parentid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["mark"] != null && reader["mark"].ToString() != "") { model.mark = reader["mark"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnRole> GetRoleList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnRole> modelList = new List<EnRole>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBSystemRole, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnRole model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnRole(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["parentid"] != null && dt.Rows[n]["parentid"].ToString() != "") { model.parentid = int.Parse(dt.Rows[n]["parentid"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["mark"] != null && dt.Rows[n]["mark"].ToString() != "") { model.mark = dt.Rows[n]["mark"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } #endregion #region 共公角色动作关联信息 /// <summary> /// 更新对像 /// </summary> public static int EditRoleActionDef(EnRoleActionDef model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into t_sys_roleactiondef("); strSql.Append("actionid,moduleid,roleid)"); strSql.Append(" values ("); strSql.Append("@actionid,@moduleid,@roleid)"); SqlParameter[] parameters = { new SqlParameter("@actionid", SqlDbType.Int,4), new SqlParameter("@moduleid", SqlDbType.Int,4), new SqlParameter("@roleid", SqlDbType.Int,4)}; parameters[0].Value = model.actionid; parameters[1].Value = model.moduleid; parameters[2].Value = model.roleid; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } return 0; } public static List<EnRoleActionDef> GetRoleActionDefList(string strWhere) { List<EnRoleActionDef> modelList = new List<EnRoleActionDef>(); DataTable dt = DataCommon.GetDataTable(TableName.TBRoleActionDef, "", strWhere, ""); if (dt.Rows.Count > 0) { EnRoleActionDef model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnRoleActionDef(); if (dt.Rows[n]["actionid"] != null && dt.Rows[n]["actionid"].ToString() != "") { model.actionid = int.Parse(dt.Rows[n]["actionid"].ToString()); } if (dt.Rows[n]["moduleid"] != null && dt.Rows[n]["moduleid"].ToString() != "") { model.moduleid = int.Parse(dt.Rows[n]["moduleid"].ToString()); } if (dt.Rows[n]["roleid"] != null && dt.Rows[n]["roleid"].ToString() != "") { model.roleid = int.Parse(dt.Rows[n]["roleid"].ToString()); } modelList.Add(model); } } return modelList; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Permissions.cs
C#
oos
26,980
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Articles { #region article /// <summary> /// 更新对像 /// </summary> public static int EditArticle(EnArticle model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_article("); strSql.Append("attribute,title,subtitle,letter,categoryid,subcategoryid,ico,thumb,banner,keyword,descript,context,othercon,source,autho,linkurl,clickcount,sort,createtime,createid,edittime,editid)"); strSql.Append(" values ("); strSql.Append("@attribute,@title,@subtitle,@letter,@categoryid,@subcategoryid,@ico,@thumb,@banner,@keyword,@descript,@context,@othercon,@source,@autho,@linkurl,@clickcount,@sort,@createtime,@createid,@edittime,@editid)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@attribute", SqlDbType.VarChar,30), new SqlParameter("@title", SqlDbType.NVarChar,60), new SqlParameter("@subtitle", SqlDbType.NVarChar,30), new SqlParameter("@letter", SqlDbType.VarChar,50), new SqlParameter("@categoryid", SqlDbType.Int,4), new SqlParameter("@subcategoryid", SqlDbType.VarChar,50), new SqlParameter("@ico", SqlDbType.VarChar,30), new SqlParameter("@thumb", SqlDbType.VarChar,30), new SqlParameter("@banner", SqlDbType.VarChar,300), new SqlParameter("@keyword", SqlDbType.NVarChar,100), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@context", SqlDbType.Text), new SqlParameter("@othercon", SqlDbType.VarChar,600), new SqlParameter("@source", SqlDbType.NVarChar,30), new SqlParameter("@autho", SqlDbType.NVarChar,30), new SqlParameter("@linkurl", SqlDbType.VarChar,200), new SqlParameter("@clickcount", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createtime", SqlDbType.DateTime), new SqlParameter("@createid", SqlDbType.Int,4), new SqlParameter("@edittime", SqlDbType.DateTime), new SqlParameter("@editid", SqlDbType.Int,4)}; parameters[0].Value = model.attribute; parameters[1].Value = model.title; parameters[2].Value = model.subtitle; parameters[3].Value = model.letter; parameters[4].Value = model.categoryid; parameters[5].Value = model.subcategoryid; parameters[6].Value = model.ico; parameters[7].Value = model.thumb; parameters[8].Value = model.banner; parameters[9].Value = model.keyword; parameters[10].Value = model.descript; parameters[11].Value = model.context; parameters[12].Value = model.othercon; parameters[13].Value = model.source; parameters[14].Value = model.autho; parameters[15].Value = model.linkurl; parameters[16].Value = model.clickcount; parameters[17].Value = model.sort; parameters[18].Value = model.createtime; parameters[19].Value = model.createid; parameters[20].Value = model.edittime; parameters[21].Value = model.editid; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_article set "); strSql.Append("attribute=@attribute,"); strSql.Append("title=@title,"); strSql.Append("subtitle=@subtitle,"); strSql.Append("letter=@letter,"); strSql.Append("categoryid=@categoryid,"); strSql.Append("subcategoryid=@subcategoryid,"); strSql.Append("ico=@ico,"); strSql.Append("thumb=@thumb,"); strSql.Append("banner=@banner,"); strSql.Append("keyword=@keyword,"); strSql.Append("descript=@descript,"); strSql.Append("context=@context,"); strSql.Append("othercon=@othercon,"); strSql.Append("source=@source,"); strSql.Append("autho=@autho,"); strSql.Append("linkurl=@linkurl,"); strSql.Append("clickcount=@clickcount,"); strSql.Append("sort=@sort,"); strSql.Append("createtime=@createtime,"); strSql.Append("createid=@createid,"); strSql.Append("edittime=@edittime,"); strSql.Append("editid=@editid"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@attribute", SqlDbType.VarChar,30), new SqlParameter("@title", SqlDbType.NVarChar,60), new SqlParameter("@subtitle", SqlDbType.NVarChar,30), new SqlParameter("@letter", SqlDbType.VarChar,50), new SqlParameter("@categoryid", SqlDbType.Int,4), new SqlParameter("@subcategoryid", SqlDbType.VarChar,50), new SqlParameter("@ico", SqlDbType.VarChar,30), new SqlParameter("@thumb", SqlDbType.VarChar,30), new SqlParameter("@banner", SqlDbType.VarChar,300), new SqlParameter("@keyword", SqlDbType.NVarChar,100), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@context", SqlDbType.Text), new SqlParameter("@othercon", SqlDbType.VarChar,600), new SqlParameter("@source", SqlDbType.NVarChar,30), new SqlParameter("@autho", SqlDbType.NVarChar,30), new SqlParameter("@linkurl", SqlDbType.VarChar,200), new SqlParameter("@clickcount", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createtime", SqlDbType.DateTime), new SqlParameter("@createid", SqlDbType.Int,4), new SqlParameter("@edittime", SqlDbType.DateTime), new SqlParameter("@editid", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.attribute; parameters[1].Value = model.title; parameters[2].Value = model.subtitle; parameters[3].Value = model.letter; parameters[4].Value = model.categoryid; parameters[5].Value = model.subcategoryid; parameters[6].Value = model.ico; parameters[7].Value = model.thumb; parameters[8].Value = model.banner; parameters[9].Value = model.keyword; parameters[10].Value = model.descript; parameters[11].Value = model.context; parameters[12].Value = model.othercon; parameters[13].Value = model.source; parameters[14].Value = model.autho; parameters[15].Value = model.linkurl; parameters[16].Value = model.clickcount; parameters[17].Value = model.sort; parameters[18].Value = model.createtime; parameters[19].Value = model.createid; parameters[20].Value = model.edittime; parameters[21].Value = model.editid; parameters[22].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnArticle GetArticleInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Article "); strSql.Append(strWhere); EnArticle model = new EnArticle(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["subtitle"] != null && reader["subtitle"].ToString() != "") { model.subtitle = reader["subtitle"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["categoryid"] != null && reader["categoryid"].ToString() != "") { model.categoryid = int.Parse(reader["categoryid"].ToString()); } if (reader["subcategoryid"] != null && reader["subcategoryid"].ToString() != "") { model.subcategoryid = reader["subcategoryid"].ToString(); } if (reader["ico"] != null && reader["ico"].ToString() != "") { model.ico = reader["ico"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["banner"] != null && reader["banner"].ToString() != "") { model.banner = reader["banner"].ToString(); } if (reader["keyword"] != null && reader["keyword"].ToString() != "") { model.keyword = reader["keyword"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["context"] != null && reader["context"].ToString() != "") { model.context = reader["context"].ToString(); } if (reader["othercon"] != null && reader["othercon"].ToString() != "") { model.othercon = reader["othercon"].ToString(); } if (reader["source"] != null && reader["source"].ToString() != "") { model.source = reader["source"].ToString(); } if (reader["autho"] != null && reader["autho"].ToString() != "") { model.autho = reader["autho"].ToString(); } if (reader["linkurl"] != null && reader["linkurl"].ToString() != "") { model.linkurl = reader["linkurl"].ToString(); } if (reader["clickcount"] != null && reader["clickcount"].ToString() != "") { model.clickcount = int.Parse(reader["clickcount"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createtime"] != null && reader["createtime"].ToString() != "") { model.createtime = DateTime.Parse(reader["createtime"].ToString()); } if (reader["createid"] != null && reader["createid"].ToString() != "") { model.createid = int.Parse(reader["createid"].ToString()); } if (reader["edittime"] != null && reader["edittime"].ToString() != "") { model.edittime = DateTime.Parse(reader["edittime"].ToString()); } if (reader["editid"] != null && reader["editid"].ToString() != "") { model.editid = int.Parse(reader["editid"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnArticle> GetArticleList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnArticle> modelList = new List<EnArticle>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TVArticle, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnArticle model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnArticle(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["attribute"] != null && dt.Rows[n]["attribute"].ToString() != "") { model.attribute = dt.Rows[n]["attribute"].ToString(); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["subtitle"] != null && dt.Rows[n]["subtitle"].ToString() != "") { model.subtitle = dt.Rows[n]["subtitle"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["categoryid"] != null && dt.Rows[n]["categoryid"].ToString() != "") { model.categoryid = int.Parse(dt.Rows[n]["categoryid"].ToString()); } if (dt.Rows[n]["subcategoryid"] != null && dt.Rows[n]["subcategoryid"].ToString() != "") { model.subcategoryid = dt.Rows[n]["subcategoryid"].ToString(); } if (dt.Rows[n]["ico"] != null && dt.Rows[n]["ico"].ToString() != "") { model.ico = dt.Rows[n]["ico"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["banner"] != null && dt.Rows[n]["banner"].ToString() != "") { model.banner = dt.Rows[n]["banner"].ToString(); } if (dt.Rows[n]["keyword"] != null && dt.Rows[n]["keyword"].ToString() != "") { model.keyword = dt.Rows[n]["keyword"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["context"] != null && dt.Rows[n]["context"].ToString() != "") { model.context = dt.Rows[n]["context"].ToString(); } if (dt.Rows[n]["othercon"] != null && dt.Rows[n]["othercon"].ToString() != "") { model.othercon = dt.Rows[n]["othercon"].ToString(); } if (dt.Rows[n]["source"] != null && dt.Rows[n]["source"].ToString() != "") { model.source = dt.Rows[n]["source"].ToString(); } if (dt.Rows[n]["autho"] != null && dt.Rows[n]["autho"].ToString() != "") { model.autho = dt.Rows[n]["autho"].ToString(); } if (dt.Rows[n]["linkurl"] != null && dt.Rows[n]["linkurl"].ToString() != "") { model.linkurl = dt.Rows[n]["linkurl"].ToString(); } if (dt.Rows[n]["clickcount"] != null && dt.Rows[n]["clickcount"].ToString() != "") { model.clickcount = int.Parse(dt.Rows[n]["clickcount"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["createtime"] != null && dt.Rows[n]["createtime"].ToString() != "") { model.createtime = DateTime.Parse(dt.Rows[n]["createtime"].ToString()); } if (dt.Rows[n]["createid"] != null && dt.Rows[n]["createid"].ToString() != "") { model.createid = int.Parse(dt.Rows[n]["createid"].ToString()); } if (dt.Rows[n]["edittime"] != null && dt.Rows[n]["edittime"].ToString() != "") { model.edittime = DateTime.Parse(dt.Rows[n]["edittime"].ToString()); } if (dt.Rows[n]["editid"] != null && dt.Rows[n]["editid"].ToString() != "") { model.editid = int.Parse(dt.Rows[n]["editid"].ToString()); } if (dt.Rows[n]["cletter"] != null && dt.Rows[n]["cletter"].ToString() != "") { model.cletter = dt.Rows[n]["cletter"].ToString(); } modelList.Add(model); } } return modelList; } ///获取数据列表 public static List<EnArticle> GetArticleList(int pageIndex, int pagesSize, string strWhere, string field, string sortkey, string orderByType, out int pageCount) { IDataReader reader = DataCommon.GetPageDataReader(TableName.TVArticle, pageIndex, pagesSize, strWhere, sortkey, orderByType, out pageCount); List<EnArticle> list = new List<EnArticle>(); while (reader.Read()) { EnArticle model = new EnArticle(); if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["subtitle"] != null && reader["subtitle"].ToString() != "") { model.subtitle = reader["subtitle"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["categoryid"] != null && reader["categoryid"].ToString() != "") { model.categoryid = int.Parse(reader["categoryid"].ToString()); } if (reader["subcategoryid"] != null && reader["subcategoryid"].ToString() != "") { model.subcategoryid = reader["subcategoryid"].ToString(); } if (reader["ico"] != null && reader["ico"].ToString() != "") { model.ico = reader["ico"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["banner"] != null && reader["banner"].ToString() != "") { model.banner = reader["banner"].ToString(); } if (reader["keyword"] != null && reader["keyword"].ToString() != "") { model.keyword = reader["keyword"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["context"] != null && reader["context"].ToString() != "") { model.context = reader["context"].ToString(); } if (reader["othercon"] != null && reader["othercon"].ToString() != "") { model.othercon = reader["othercon"].ToString(); } if (reader["source"] != null && reader["source"].ToString() != "") { model.source = reader["source"].ToString(); } if (reader["autho"] != null && reader["autho"].ToString() != "") { model.autho = reader["autho"].ToString(); } if (reader["linkurl"] != null && reader["linkurl"].ToString() != "") { model.linkurl = reader["linkurl"].ToString(); } if (reader["clickcount"] != null && reader["clickcount"].ToString() != "") { model.clickcount = int.Parse(reader["clickcount"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createtime"] != null && reader["createtime"].ToString() != "") { model.createtime = DateTime.Parse(reader["createtime"].ToString()); } if (reader["createid"] != null && reader["createid"].ToString() != "") { model.createid = int.Parse(reader["createid"].ToString()); } if (reader["edittime"] != null && reader["edittime"].ToString() != "") { model.edittime = DateTime.Parse(reader["edittime"].ToString()); } if (reader["editid"] != null && reader["editid"].ToString() != "") { model.editid = int.Parse(reader["editid"].ToString()); } if (reader["cletter"] != null && reader["cletter"].ToString() != "") { model.cletter = reader["cletter"].ToString(); } list.Add(model); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return list; } #endregion #region articlecategory /// <summary> /// 更新对像 /// </summary> public static int EditArticleCategory(EnArticleCategory model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_articlecategory("); strSql.Append("attribute,title,subtitle,letter,ico,thumb,banner,keyword,descript,context,othercon,linktype,linkurl,parentid,lft,rgt,depth,lev,indextemplate,listtemplate,contemplate,sort,createtime,createid,edittime,editid)"); strSql.Append(" values ("); strSql.Append("@attribute,@title,@subtitle,@letter,@ico,@thumb,@banner,@keyword,@descript,@context,@othercon,@linktype,@linkurl,@parentid,@lft,@rgt,@depth,@lev,@indextemplate,@listtemplate,@contemplate,@sort,@createtime,@createid,@edittime,@editid)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@attribute", SqlDbType.VarChar,30), new SqlParameter("@title", SqlDbType.NVarChar,60), new SqlParameter("@subtitle", SqlDbType.NVarChar,30), new SqlParameter("@letter", SqlDbType.VarChar,50), new SqlParameter("@ico", SqlDbType.VarChar,30), new SqlParameter("@thumb", SqlDbType.VarChar,30), new SqlParameter("@banner", SqlDbType.VarChar,300), new SqlParameter("@keyword", SqlDbType.NVarChar,100), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@context", SqlDbType.NText), new SqlParameter("@othercon", SqlDbType.VarChar,600), new SqlParameter("@linktype", SqlDbType.Int,4), new SqlParameter("@linkurl", SqlDbType.VarChar,200), new SqlParameter("@parentid", SqlDbType.Int,4), new SqlParameter("@lft", SqlDbType.Int,4), new SqlParameter("@rgt", SqlDbType.Int,4), new SqlParameter("@depth", SqlDbType.VarChar,500), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@indextemplate", SqlDbType.VarChar,60), new SqlParameter("@listtemplate", SqlDbType.VarChar,60), new SqlParameter("@contemplate", SqlDbType.VarChar,60), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createtime", SqlDbType.DateTime), new SqlParameter("@createid", SqlDbType.Int,4), new SqlParameter("@edittime", SqlDbType.DateTime), new SqlParameter("@editid", SqlDbType.Int,4)}; parameters[0].Value = model.attribute; parameters[1].Value = model.title; parameters[2].Value = model.subtitle; parameters[3].Value = model.letter; parameters[4].Value = model.ico; parameters[5].Value = model.thumb; parameters[6].Value = model.banner; parameters[7].Value = model.keyword; parameters[8].Value = model.descript; parameters[9].Value = model.context; parameters[10].Value = model.othercon; parameters[11].Value = model.linktype; parameters[12].Value = model.linkurl; parameters[13].Value = model.parentid; parameters[14].Value = model.lft; parameters[15].Value = model.rgt; parameters[16].Value = model.depth; parameters[17].Value = model.lev; parameters[18].Value = model.indextemplate; parameters[19].Value = model.listtemplate; parameters[20].Value = model.contemplate; parameters[21].Value = model.sort; parameters[22].Value = model.createtime; parameters[23].Value = model.createid; parameters[24].Value = model.edittime; parameters[25].Value = model.editid; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_articlecategory set "); strSql.Append("attribute=@attribute,"); strSql.Append("title=@title,"); strSql.Append("subtitle=@subtitle,"); strSql.Append("letter=@letter,"); strSql.Append("ico=@ico,"); strSql.Append("thumb=@thumb,"); strSql.Append("banner=@banner,"); strSql.Append("keyword=@keyword,"); strSql.Append("descript=@descript,"); strSql.Append("context=@context,"); strSql.Append("othercon=@othercon,"); strSql.Append("linktype=@linktype,"); strSql.Append("linkurl=@linkurl,"); strSql.Append("parentid=@parentid,"); strSql.Append("lft=@lft,"); strSql.Append("rgt=@rgt,"); strSql.Append("depth=@depth,"); strSql.Append("lev=@lev,"); strSql.Append("indextemplate=@indextemplate,"); strSql.Append("listtemplate=@listtemplate,"); strSql.Append("contemplate=@contemplate,"); strSql.Append("sort=@sort,"); strSql.Append("createtime=@createtime,"); strSql.Append("createid=@createid,"); strSql.Append("edittime=@edittime,"); strSql.Append("editid=@editid"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@attribute", SqlDbType.VarChar,30), new SqlParameter("@title", SqlDbType.NVarChar,60), new SqlParameter("@subtitle", SqlDbType.NVarChar,30), new SqlParameter("@letter", SqlDbType.VarChar,50), new SqlParameter("@ico", SqlDbType.VarChar,30), new SqlParameter("@thumb", SqlDbType.VarChar,30), new SqlParameter("@banner", SqlDbType.VarChar,300), new SqlParameter("@keyword", SqlDbType.NVarChar,100), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@context", SqlDbType.NText), new SqlParameter("@othercon", SqlDbType.VarChar,600), new SqlParameter("@linktype", SqlDbType.Int,4), new SqlParameter("@linkurl", SqlDbType.VarChar,200), new SqlParameter("@parentid", SqlDbType.Int,4), new SqlParameter("@lft", SqlDbType.Int,4), new SqlParameter("@rgt", SqlDbType.Int,4), new SqlParameter("@depth", SqlDbType.VarChar,500), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@indextemplate", SqlDbType.VarChar,60), new SqlParameter("@listtemplate", SqlDbType.VarChar,60), new SqlParameter("@contemplate", SqlDbType.VarChar,60), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createtime", SqlDbType.DateTime), new SqlParameter("@createid", SqlDbType.Int,4), new SqlParameter("@edittime", SqlDbType.DateTime), new SqlParameter("@editid", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.attribute; parameters[1].Value = model.title; parameters[2].Value = model.subtitle; parameters[3].Value = model.letter; parameters[4].Value = model.ico; parameters[5].Value = model.thumb; parameters[6].Value = model.banner; parameters[7].Value = model.keyword; parameters[8].Value = model.descript; parameters[9].Value = model.context; parameters[10].Value = model.othercon; parameters[11].Value = model.linktype; parameters[12].Value = model.linkurl; parameters[13].Value = model.parentid; parameters[14].Value = model.lft; parameters[15].Value = model.rgt; parameters[16].Value = model.depth; parameters[17].Value = model.lev; parameters[18].Value = model.indextemplate; parameters[19].Value = model.listtemplate; parameters[20].Value = model.contemplate; parameters[21].Value = model.sort; parameters[22].Value = model.createtime; parameters[23].Value = model.createid; parameters[24].Value = model.edittime; parameters[25].Value = model.editid; parameters[26].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnArticleCategory GetArticleCategoryInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from t_ArticleCategory "); strSql.Append(strWhere); EnArticleCategory model = new EnArticleCategory(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["subtitle"] != null && reader["subtitle"].ToString() != "") { model.subtitle = reader["subtitle"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["ico"] != null && reader["ico"].ToString() != "") { model.ico = reader["ico"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["banner"] != null && reader["banner"].ToString() != "") { model.banner = reader["banner"].ToString(); } if (reader["keyword"] != null && reader["keyword"].ToString() != "") { model.keyword = reader["keyword"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["context"] != null && reader["context"].ToString() != "") { model.context = reader["context"].ToString(); } if (reader["othercon"] != null && reader["othercon"].ToString() != "") { model.othercon = reader["othercon"].ToString(); } if (reader["linktype"] != null && reader["linktype"].ToString() != "") { model.linktype = int.Parse(reader["linktype"].ToString()); } if (reader["linkurl"] != null && reader["linkurl"].ToString() != "") { model.linkurl = reader["linkurl"].ToString(); } if (reader["parentid"] != null && reader["parentid"].ToString() != "") { model.parentid = int.Parse(reader["parentid"].ToString()); } if (reader["lft"] != null && reader["lft"].ToString() != "") { model.lft = int.Parse(reader["lft"].ToString()); } if (reader["rgt"] != null && reader["rgt"].ToString() != "") { model.rgt = int.Parse(reader["rgt"].ToString()); } if (reader["depth"] != null && reader["depth"].ToString() != "") { model.depth = reader["depth"].ToString(); } if (reader["lev"] != null && reader["lev"].ToString() != "") { model.lev = int.Parse(reader["lev"].ToString()); } if (reader["indextemplate"] != null && reader["indextemplate"].ToString() != "") { model.indextemplate = reader["indextemplate"].ToString(); } if (reader["listtemplate"] != null && reader["listtemplate"].ToString() != "") { model.listtemplate = reader["listtemplate"].ToString(); } if (reader["contemplate"] != null && reader["contemplate"].ToString() != "") { model.contemplate = reader["contemplate"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createtime"] != null && reader["createtime"].ToString() != "") { model.createtime = DateTime.Parse(reader["createtime"].ToString()); } if (reader["createid"] != null && reader["createid"].ToString() != "") { model.createid = int.Parse(reader["createid"].ToString()); } if (reader["edittime"] != null && reader["edittime"].ToString() != "") { model.edittime = DateTime.Parse(reader["edittime"].ToString()); } if (reader["editid"] != null && reader["editid"].ToString() != "") { model.editid = int.Parse(reader["editid"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnArticleCategory> GetArticleCategoryList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnArticleCategory> modelList = new List<EnArticleCategory>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBArticleCategory, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnArticleCategory model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnArticleCategory(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["attribute"] != null && dt.Rows[n]["attribute"].ToString() != "") { model.attribute = dt.Rows[n]["attribute"].ToString(); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["subtitle"] != null && dt.Rows[n]["subtitle"].ToString() != "") { model.subtitle = dt.Rows[n]["subtitle"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["ico"] != null && dt.Rows[n]["ico"].ToString() != "") { model.ico = dt.Rows[n]["ico"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["banner"] != null && dt.Rows[n]["banner"].ToString() != "") { model.banner = dt.Rows[n]["banner"].ToString(); } if (dt.Rows[n]["keyword"] != null && dt.Rows[n]["keyword"].ToString() != "") { model.keyword = dt.Rows[n]["keyword"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["context"] != null && dt.Rows[n]["context"].ToString() != "") { model.context = dt.Rows[n]["context"].ToString(); } if (dt.Rows[n]["othercon"] != null && dt.Rows[n]["othercon"].ToString() != "") { model.othercon = dt.Rows[n]["othercon"].ToString(); } if (dt.Rows[n]["linktype"] != null && dt.Rows[n]["linktype"].ToString() != "") { model.linktype = int.Parse(dt.Rows[n]["linktype"].ToString()); } if (dt.Rows[n]["linkurl"] != null && dt.Rows[n]["linkurl"].ToString() != "") { model.linkurl = dt.Rows[n]["linkurl"].ToString(); } if (dt.Rows[n]["parentid"] != null && dt.Rows[n]["parentid"].ToString() != "") { model.parentid = int.Parse(dt.Rows[n]["parentid"].ToString()); } if (dt.Rows[n]["lft"] != null && dt.Rows[n]["lft"].ToString() != "") { model.lft = int.Parse(dt.Rows[n]["lft"].ToString()); } if (dt.Rows[n]["rgt"] != null && dt.Rows[n]["rgt"].ToString() != "") { model.rgt = int.Parse(dt.Rows[n]["rgt"].ToString()); } if (dt.Rows[n]["depth"] != null && dt.Rows[n]["depth"].ToString() != "") { model.depth = dt.Rows[n]["depth"].ToString(); } if (dt.Rows[n]["lev"] != null && dt.Rows[n]["lev"].ToString() != "") { model.lev = int.Parse(dt.Rows[n]["lev"].ToString()); } if (dt.Rows[n]["indextemplate"] != null && dt.Rows[n]["indextemplate"].ToString() != "") { model.indextemplate = dt.Rows[n]["indextemplate"].ToString(); } if (dt.Rows[n]["listtemplate"] != null && dt.Rows[n]["listtemplate"].ToString() != "") { model.listtemplate = dt.Rows[n]["listtemplate"].ToString(); } if (dt.Rows[n]["contemplate"] != null && dt.Rows[n]["contemplate"].ToString() != "") { model.contemplate = dt.Rows[n]["contemplate"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["createtime"] != null && dt.Rows[n]["createtime"].ToString() != "") { model.createtime = DateTime.Parse(dt.Rows[n]["createtime"].ToString()); } if (dt.Rows[n]["createid"] != null && dt.Rows[n]["createid"].ToString() != "") { model.createid = int.Parse(dt.Rows[n]["createid"].ToString()); } if (dt.Rows[n]["edittime"] != null && dt.Rows[n]["edittime"].ToString() != "") { model.edittime = DateTime.Parse(dt.Rows[n]["edittime"].ToString()); } if (dt.Rows[n]["editid"] != null && dt.Rows[n]["editid"].ToString() != "") { model.editid = int.Parse(dt.Rows[n]["editid"].ToString()); } modelList.Add(model); } } return modelList; } ///获取数据列表 public static List<EnArticleCategory> GetArticleCategoryList(int pageIndex, int pagesSize, string strWhere, string field, string sortkey, string orderByType, out int pageCount) { IDataReader reader = DataCommon.GetPageDataReader(TableName.TBArticleCategory, pageIndex, pagesSize, strWhere, sortkey, orderByType, out pageCount); List<EnArticleCategory> list = new List<EnArticleCategory>(); while (reader.Read()) { EnArticleCategory model = new EnArticleCategory(); if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["subtitle"] != null && reader["subtitle"].ToString() != "") { model.subtitle = reader["subtitle"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["ico"] != null && reader["ico"].ToString() != "") { model.ico = reader["ico"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["banner"] != null && reader["banner"].ToString() != "") { model.banner = reader["banner"].ToString(); } if (reader["keyword"] != null && reader["keyword"].ToString() != "") { model.keyword = reader["keyword"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["context"] != null && reader["context"].ToString() != "") { model.context = reader["context"].ToString(); } if (reader["othercon"] != null && reader["othercon"].ToString() != "") { model.othercon = reader["othercon"].ToString(); } if (reader["linktype"] != null && reader["linktype"].ToString() != "") { model.linktype = int.Parse(reader["linktype"].ToString()); } if (reader["linkurl"] != null && reader["linkurl"].ToString() != "") { model.linkurl = reader["linkurl"].ToString(); } if (reader["parentid"] != null && reader["parentid"].ToString() != "") { model.parentid = int.Parse(reader["parentid"].ToString()); } if (reader["lft"] != null && reader["lft"].ToString() != "") { model.lft = int.Parse(reader["lft"].ToString()); } if (reader["rgt"] != null && reader["rgt"].ToString() != "") { model.rgt = int.Parse(reader["rgt"].ToString()); } if (reader["depth"] != null && reader["depth"].ToString() != "") { model.depth = reader["depth"].ToString(); } if (reader["lev"] != null && reader["lev"].ToString() != "") { model.lev = int.Parse(reader["lev"].ToString()); } if (reader["indextemplate"] != null && reader["indextemplate"].ToString() != "") { model.indextemplate = reader["indextemplate"].ToString(); } if (reader["listtemplate"] != null && reader["listtemplate"].ToString() != "") { model.listtemplate = reader["listtemplate"].ToString(); } if (reader["contemplate"] != null && reader["contemplate"].ToString() != "") { model.contemplate = reader["contemplate"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createtime"] != null && reader["createtime"].ToString() != "") { model.createtime = DateTime.Parse(reader["createtime"].ToString()); } if (reader["createid"] != null && reader["createid"].ToString() != "") { model.createid = int.Parse(reader["createid"].ToString()); } if (reader["edittime"] != null && reader["edittime"].ToString() != "") { model.edittime = DateTime.Parse(reader["edittime"].ToString()); } if (reader["editid"] != null && reader["editid"].ToString() != "") { model.editid = int.Parse(reader["editid"].ToString()); } list.Add(model); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return list; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Articles.cs
C#
oos
53,278
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class PCategoryPTyps { /// <summary> /// 更新对像 /// </summary> public static int EditPCategoryPTyp(List<EnPCategoryPTyp> list) { if (list != null && list.Count > 0) { DbHelper.ExecuteNonQuery(" delete from t_pcategoryptypedef where productcategoryid=" + list[0].productcategoryid); List<CommandInfo> l = new List<CommandInfo>(); foreach (EnPCategoryPTyp model in list) { CommandInfo c = new CommandInfo(); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_pcategoryptypedef("); strSql.Append("productcategoryid,producttypeid)"); strSql.Append(" values ("); strSql.Append("@productcategoryid,@producttypeid)"); SqlParameter[] parameters = { new SqlParameter("@productcategoryid", SqlDbType.Int,4), new SqlParameter("@producttypeid", SqlDbType.Int,4)}; parameters[0].Value = model.productcategoryid; parameters[1].Value = model.producttypeid; c.EffentNextType = EffentNextType.ExcuteEffectRows; c.CommandText = strSql.ToString(); c.Parameters = parameters; l.Add(c); } return DbHelper.ExecuteSqlTran(l); } return 0; } /// <summary> /// 获得数据列表 /// </summary> public static List<EnPCategoryPTyp> GetPCategoryPTypList(string fields,string strWhere) { List<EnPCategoryPTyp> modelList = new List<EnPCategoryPTyp>(); DataTable dt = DataCommon.GetDataTable(TableName.TBPCategoryPTyp, fields, strWhere, ""); if (dt.Rows.Count > 0) { EnPCategoryPTyp model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnPCategoryPTyp(); if (dt.Rows[n]["productcategoryid"] != null && dt.Rows[n]["productcategoryid"].ToString() != "") { model.productcategoryid = int.Parse(dt.Rows[n]["productcategoryid"].ToString()); } if (dt.Rows[n]["producttypeid"] != null && dt.Rows[n]["producttypeid"].ToString() != "") { model.producttypeid = int.Parse(dt.Rows[n]["producttypeid"].ToString()); } modelList.Add(model); } } return modelList; } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/PCategoryPTyps.cs
C#
oos
3,017
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Promotions { //活动信息 public static List<EnWebPromotion> GetWebPromotionList(int PageIndex, int PageSize, string strWhere, string sortkey, string orderby, out int pageCount) { List<EnWebPromotion> list = new List<EnWebPromotion>(); IDataReader reader = DataCommon.GetPageDataReader(TableName.TVPromotion, PageIndex, PageSize, strWhere, sortkey, orderby, out pageCount); while (reader.Read()) { EnWebPromotion model = new EnWebPromotion(); if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["htmltitle"] != null && reader["htmltitle"].ToString() != "") { model.htmltitle = reader["htmltitle"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["ptype"] != null && reader["ptype"].ToString() != "") { model.ptype = int.Parse(reader["ptype"].ToString()); } if (reader["startdatetime"] != null && reader["startdatetime"].ToString() != "") { model.startdatetime = DateTime.Parse(reader["startdatetime"].ToString()); } if (reader["enddatetime"] != null && reader["enddatetime"].ToString() != "") { model.enddatetime = DateTime.Parse(reader["enddatetime"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } //if (reader["pid"] != null && reader["pid"].ToString() != "") //{ // model.pid = int.Parse(reader["pid"].ToString()); //} //if (reader["companyidlist"] != null && reader["companyidlist"].ToString() != "") //{ // model.companyidlist = reader["companyidlist"].ToString(); //} //if (reader["dealeridlist"] != null && reader["dealeridlist"].ToString() != "") //{ // model.dealeridlist = reader["dealeridlist"].ToString(); //} //if (reader["shopidlist"] != null && reader["shopidlist"].ToString() != "") //{ // model.shopidlist = reader["shopidlist"].ToString(); //} //if (reader["brandidlist"] != null && reader["brandidlist"].ToString() != "") //{ // model.brandidlist = reader["brandidlist"].ToString(); //} //if (reader["marketidlist"] != null && reader["marketidlist"].ToString() != "") //{ // model.marketidlist = reader["marketidlist"].ToString(); //} //if (reader["productidlist"] != null && reader["productidlist"].ToString() != "") //{ // model.productidlist = reader["productidlist"].ToString(); //} list.Add(model); } return list; } //活动信息 public static List<EnWebPromotionInfoList> GetWebPromotionInfoList(int PageIndex, int PageSize, string strWhere, string sortkey, string orderby, out int pageCount) { List<EnWebPromotionInfoList> list = new List<EnWebPromotionInfoList>(); IDataReader reader = DataCommon.GetPageDataReader(TableName.TVPromotionInfoList, PageIndex, PageSize, strWhere, sortkey, orderby, out pageCount); while (reader.Read()) { EnWebPromotionInfoList model = new EnWebPromotionInfoList(); if (reader["brandlogo"] != null && reader["brandlogo"].ToString() != "") { model.brandlogo = reader["brandlogo"].ToString(); } if (reader["ptitle"] != null && reader["ptitle"].ToString() != "") { model.ptitle = reader["ptitle"].ToString(); } if (reader["htmltitle"] != null && reader["htmltitle"].ToString() != "") { model.htmltitle = reader["htmltitle"].ToString(); } if (reader["startdatetime"] != null && reader["startdatetime"].ToString() != "") { model.startdatetime = DateTime.Parse(reader["startdatetime"].ToString()); } if (reader["enddatetime"] != null && reader["enddatetime"].ToString() != "") { model.enddatetime = DateTime.Parse(reader["enddatetime"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["ptype"] != null && reader["ptype"].ToString() != "") { model.ptype = int.Parse(reader["ptype"].ToString()); } if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["pid"] != null && reader["pid"].ToString() != "") { model.pid = int.Parse(reader["pid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["type"] != null && reader["type"].ToString() != "") { model.type = reader["type"].ToString(); } if (reader["value"] != null && reader["value"].ToString() != "") { model.value = reader["value"].ToString(); } if (reader["valueletter"] != null && reader["valueletter"].ToString() != "") { model.valueletter = reader["valueletter"].ToString(); } if (reader["valuetitle"] != null && reader["valuetitle"].ToString() != "") { model.valuetitle = reader["valuetitle"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["banner"] != null && reader["banner"].ToString() != "") { model.banner = reader["banner"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["curcountmoney"] != null && reader["curcountmoney"].ToString() != "") { model.curcountmoney = reader["curcountmoney"].ToString(); } if (reader["curcountpeople"] != null && reader["curcountpeople"].ToString() != "") { model.curcountpeople = reader["curcountpeople"].ToString(); } if (reader["curstage"] != null && reader["curstage"].ToString() != "") { model.curstage = reader["curstage"].ToString(); } if (reader["fordio"] != null && reader["fordio"].ToString() != "") { model.fordio = reader["fordio"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["stagelist"] != null && reader["stagelist"].ToString() != "") { model.stagelist = reader["stagelist"].ToString(); } if (reader["stagecount"] != null && reader["stagecount"].ToString() != "") { model.stagecount = int.Parse(reader["stagecount"].ToString()); } list.Add(model); } return list; } //活动信息 public static EnWebPromotionInfoList GetWebPromotionInfoListInfo(string strWhere) { EnWebPromotionInfoList model = new EnWebPromotionInfoList(); StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from "+TableName.TVPromotionInfoList+" "); strSql.Append(strWhere); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); while (reader.Read()) { if (reader["brandlogo"] != null && reader["brandlogo"].ToString() != "") { model.brandlogo = reader["brandlogo"].ToString(); } if (reader["ptitle"] != null && reader["ptitle"].ToString() != "") { model.ptitle = reader["ptitle"].ToString(); } if (reader["htmltitle"] != null && reader["htmltitle"].ToString() != "") { model.htmltitle = reader["htmltitle"].ToString(); } if (reader["startdatetime"] != null && reader["startdatetime"].ToString() != "") { model.startdatetime = DateTime.Parse(reader["startdatetime"].ToString()); } if (reader["enddatetime"] != null && reader["enddatetime"].ToString() != "") { model.enddatetime = DateTime.Parse(reader["enddatetime"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["ptype"] != null && reader["ptype"].ToString() != "") { model.ptype = int.Parse(reader["ptype"].ToString()); } if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["pid"] != null && reader["pid"].ToString() != "") { model.pid = int.Parse(reader["pid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["type"] != null && reader["type"].ToString() != "") { model.type = reader["type"].ToString(); } if (reader["value"] != null && reader["value"].ToString() != "") { model.value = reader["value"].ToString(); } if (reader["valueletter"] != null && reader["valueletter"].ToString() != "") { model.valueletter = reader["valueletter"].ToString(); } if (reader["valuetitle"] != null && reader["valuetitle"].ToString() != "") { model.valuetitle = reader["valuetitle"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["banner"] != null && reader["banner"].ToString() != "") { model.banner = reader["banner"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["curcountmoney"] != null && reader["curcountmoney"].ToString() != "") { model.curcountmoney = reader["curcountmoney"].ToString(); } if (reader["curcountpeople"] != null && reader["curcountpeople"].ToString() != "") { model.curcountpeople = reader["curcountpeople"].ToString(); } if (reader["curstage"] != null && reader["curstage"].ToString() != "") { model.curstage = reader["curstage"].ToString(); } if (reader["fordio"] != null && reader["fordio"].ToString() != "") { model.fordio = reader["fordio"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["stagelist"] != null && reader["stagelist"].ToString() != "") { model.stagelist = reader["stagelist"].ToString(); } if (reader["stagecount"] != null && reader["stagecount"].ToString() != "") { model.stagecount = int.Parse(reader["stagecount"].ToString()); } } return model; } /// <summary> /// 更新对像 /// </summary> public static int EditPromotion(EnPromotion model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_promotion("); strSql.Append("title,htmltitle,letter,attribute,ptype,startdatetime,enddatetime,areacode,address,surface,logo,thumb,bannel,desimage,descript,keywords,template,hits,sort,createmid,lastedid,lastedittime,auditstatus,linestatus)"); strSql.Append(" values ("); strSql.Append("@title,@htmltitle,@letter,@attribute,@ptype,@startdatetime,@enddatetime,@areacode,@address,@surface,@logo,@thumb,@bannel,@desimage,@descript,@keywords,@template,@hits,@sort,@createmid,@lastedid,@lastedittime,@auditstatus,@linestatus)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@htmltitle", SqlDbType.NVarChar,500), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@ptype", SqlDbType.Int,4), new SqlParameter("@startdatetime", SqlDbType.DateTime), new SqlParameter("@enddatetime", SqlDbType.DateTime), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.htmltitle; parameters[2].Value = model.letter; parameters[3].Value = model.attribute; parameters[4].Value = model.ptype; parameters[5].Value = model.startdatetime; parameters[6].Value = model.enddatetime; parameters[7].Value = model.areacode; parameters[8].Value = model.address; parameters[9].Value = model.surface; parameters[10].Value = model.logo; parameters[11].Value = model.thumb; parameters[12].Value = model.bannel; parameters[13].Value = model.desimage; parameters[14].Value = model.descript; parameters[15].Value = model.keywords; parameters[16].Value = model.template; parameters[17].Value = model.hits; parameters[18].Value = model.sort; parameters[19].Value = model.createmid; parameters[20].Value = model.lastedid; parameters[21].Value = model.lastedittime; parameters[22].Value = model.auditstatus; parameters[23].Value = model.linestatus; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_promotion set "); strSql.Append("title=@title,"); strSql.Append("htmltitle=@htmltitle,"); strSql.Append("letter=@letter,"); strSql.Append("attribute=@attribute,"); strSql.Append("ptype=@ptype,"); strSql.Append("startdatetime=@startdatetime,"); strSql.Append("enddatetime=@enddatetime,"); strSql.Append("areacode=@areacode,"); strSql.Append("address=@address,"); strSql.Append("surface=@surface,"); strSql.Append("logo=@logo,"); strSql.Append("thumb=@thumb,"); strSql.Append("bannel=@bannel,"); strSql.Append("desimage=@desimage,"); strSql.Append("descript=@descript,"); strSql.Append("keywords=@keywords,"); strSql.Append("template=@template,"); strSql.Append("hits=@hits,"); strSql.Append("sort=@sort,"); strSql.Append("createmid=@createmid,"); strSql.Append("lastedid=@lastedid,"); strSql.Append("lastedittime=@lastedittime,"); strSql.Append("auditstatus=@auditstatus,"); strSql.Append("linestatus=@linestatus"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@htmltitle", SqlDbType.NVarChar,500), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@ptype", SqlDbType.Int,4), new SqlParameter("@startdatetime", SqlDbType.DateTime), new SqlParameter("@enddatetime", SqlDbType.DateTime), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.htmltitle; parameters[2].Value = model.letter; parameters[3].Value = model.attribute; parameters[4].Value = model.ptype; parameters[5].Value = model.startdatetime; parameters[6].Value = model.enddatetime; parameters[7].Value = model.areacode; parameters[8].Value = model.address; parameters[9].Value = model.surface; parameters[10].Value = model.logo; parameters[11].Value = model.thumb; parameters[12].Value = model.bannel; parameters[13].Value = model.desimage; parameters[14].Value = model.descript; parameters[15].Value = model.keywords; parameters[16].Value = model.template; parameters[17].Value = model.hits; parameters[18].Value = model.sort; parameters[19].Value = model.createmid; parameters[20].Value = model.lastedid; parameters[21].Value = model.lastedittime; parameters[22].Value = model.auditstatus; parameters[23].Value = model.linestatus; parameters[24].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnPromotion GetPromotionInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Promotion "); strSql.Append(strWhere); EnPromotion model = new EnPromotion(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["htmltitle"] != null && reader["htmltitle"].ToString() != "") { model.htmltitle = reader["htmltitle"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["ptype"] != null && reader["ptype"].ToString() != "") { model.ptype = int.Parse(reader["ptype"].ToString()); } if (reader["startdatetime"] != null && reader["startdatetime"].ToString() != "") { model.startdatetime = DateTime.Parse(reader["startdatetime"].ToString()); } if (reader["enddatetime"] != null && reader["enddatetime"].ToString() != "") { model.enddatetime = DateTime.Parse(reader["enddatetime"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnPromotion> GetPromotionList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnPromotion> modelList = new List<EnPromotion>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBPromotion, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnPromotion model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnPromotion(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["htmltitle"] != null && dt.Rows[n]["htmltitle"].ToString() != "") { model.htmltitle = dt.Rows[n]["htmltitle"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["attribute"] != null && dt.Rows[n]["attribute"].ToString() != "") { model.attribute = dt.Rows[n]["attribute"].ToString(); } if (dt.Rows[n]["ptype"] != null && dt.Rows[n]["ptype"].ToString() != "") { model.ptype = int.Parse(dt.Rows[n]["ptype"].ToString()); } if (dt.Rows[n]["startdatetime"] != null && dt.Rows[n]["startdatetime"].ToString() != "") { model.startdatetime = DateTime.Parse(dt.Rows[n]["startdatetime"].ToString()); } if (dt.Rows[n]["enddatetime"] != null && dt.Rows[n]["enddatetime"].ToString() != "") { model.enddatetime = DateTime.Parse(dt.Rows[n]["enddatetime"].ToString()); } if (dt.Rows[n]["areacode"] != null && dt.Rows[n]["areacode"].ToString() != "") { model.areacode = dt.Rows[n]["areacode"].ToString(); } if (dt.Rows[n]["address"] != null && dt.Rows[n]["address"].ToString() != "") { model.address = dt.Rows[n]["address"].ToString(); } if (dt.Rows[n]["surface"] != null && dt.Rows[n]["surface"].ToString() != "") { model.surface = dt.Rows[n]["surface"].ToString(); } if (dt.Rows[n]["logo"] != null && dt.Rows[n]["logo"].ToString() != "") { model.logo = dt.Rows[n]["logo"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["bannel"] != null && dt.Rows[n]["bannel"].ToString() != "") { model.bannel = dt.Rows[n]["bannel"].ToString(); } if (dt.Rows[n]["desimage"] != null && dt.Rows[n]["desimage"].ToString() != "") { model.desimage = dt.Rows[n]["desimage"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["keywords"] != null && dt.Rows[n]["keywords"].ToString() != "") { model.keywords = dt.Rows[n]["keywords"].ToString(); } if (dt.Rows[n]["template"] != null && dt.Rows[n]["template"].ToString() != "") { model.template = dt.Rows[n]["template"].ToString(); } if (dt.Rows[n]["hits"] != null && dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["createmid"] != null && dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } if (dt.Rows[n]["lastedid"] != null && dt.Rows[n]["lastedid"].ToString() != "") { model.lastedid = int.Parse(dt.Rows[n]["lastedid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["auditstatus"] != null && dt.Rows[n]["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(dt.Rows[n]["auditstatus"].ToString()); } if (dt.Rows[n]["linestatus"] != null && dt.Rows[n]["linestatus"].ToString() != "") { model.linestatus = int.Parse(dt.Rows[n]["linestatus"].ToString()); } modelList.Add(model); } } return modelList; } /// <summary> /// 更新对像 /// </summary> public static int EditPromotionDef(EnPromotionDef model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_promotiondef("); strSql.Append("title,pid,attribute,type,value,valueletter,valuetitle,thumb,banner,descript,curcountmoney,curcountpeople,curstage,fordio,sort)"); strSql.Append(" values ("); strSql.Append("@title,@pid,@attribute,@type,@value,@valueletter,@valuetitle,@thumb,@banner,@descript,@curcountmoney,@curcountpeople,@curstage,@fordio,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,300), new SqlParameter("@pid", SqlDbType.Int,4), new SqlParameter("@attribute", SqlDbType.VarChar,50), new SqlParameter("@type", SqlDbType.VarChar,20), new SqlParameter("@value", SqlDbType.VarChar,20), new SqlParameter("@valueletter", SqlDbType.VarChar,20), new SqlParameter("@valuetitle", SqlDbType.NVarChar,50), new SqlParameter("@thumb", SqlDbType.VarChar,100), new SqlParameter("@banner", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@curcountmoney", SqlDbType.VarChar,20), new SqlParameter("@curcountpeople", SqlDbType.VarChar,20), new SqlParameter("@curstage", SqlDbType.VarChar,20), new SqlParameter("@fordio", SqlDbType.VarChar,20), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.pid; parameters[2].Value = model.attribute; parameters[3].Value = model.type; parameters[4].Value = model.value; parameters[5].Value = model.valueletter; parameters[6].Value = model.valuetitle; parameters[7].Value = model.thumb; parameters[8].Value = model.banner; parameters[9].Value = model.descript; parameters[10].Value = model.curcountmoney; parameters[11].Value = model.curcountpeople; parameters[12].Value = model.curstage; parameters[13].Value = model.fordio; parameters[14].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_promotiondef set "); strSql.Append("title=@title,"); strSql.Append("pid=@pid,"); strSql.Append("attribute=@attribute,"); strSql.Append("type=@type,"); strSql.Append("value=@value,"); strSql.Append("valueletter=@valueletter,"); strSql.Append("valuetitle=@valuetitle,"); strSql.Append("thumb=@thumb,"); strSql.Append("banner=@banner,"); strSql.Append("descript=@descript,"); strSql.Append("curcountmoney=@curcountmoney,"); strSql.Append("curcountpeople=@curcountpeople,"); strSql.Append("curstage=@curstage,"); strSql.Append("fordio=@fordio,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,300), new SqlParameter("@pid", SqlDbType.Int,4), new SqlParameter("@attribute", SqlDbType.VarChar,50), new SqlParameter("@type", SqlDbType.VarChar,20), new SqlParameter("@value", SqlDbType.VarChar,20), new SqlParameter("@valueletter", SqlDbType.VarChar,20), new SqlParameter("@valuetitle", SqlDbType.NVarChar,50), new SqlParameter("@thumb", SqlDbType.VarChar,100), new SqlParameter("@banner", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@curcountmoney", SqlDbType.VarChar,20), new SqlParameter("@curcountpeople", SqlDbType.VarChar,20), new SqlParameter("@curstage", SqlDbType.VarChar,20), new SqlParameter("@fordio", SqlDbType.VarChar,20), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.pid; parameters[2].Value = model.attribute; parameters[3].Value = model.type; parameters[4].Value = model.value; parameters[5].Value = model.valueletter; parameters[6].Value = model.valuetitle; parameters[7].Value = model.thumb; parameters[8].Value = model.banner; parameters[9].Value = model.descript; parameters[10].Value = model.curcountmoney; parameters[11].Value = model.curcountpeople; parameters[12].Value = model.curstage; parameters[13].Value = model.fordio; parameters[14].Value = model.sort; parameters[15].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnPromotionDef GetPromotionDefInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Promotiondef "); strSql.Append(strWhere); EnPromotionDef model = new EnPromotionDef(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["pid"] != null && reader["pid"].ToString() != "") { model.pid = int.Parse(reader["pid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["type"] != null && reader["type"].ToString() != "") { model.type = reader["type"].ToString(); } if (reader["value"] != null && reader["value"].ToString() != "") { model.value = reader["value"].ToString(); } if (reader["valueletter"] != null && reader["valueletter"].ToString() != "") { model.valueletter = reader["valueletter"].ToString(); } if (reader["valuetitle"] != null && reader["valuetitle"].ToString() != "") { model.valuetitle = reader["valuetitle"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["banner"] != null && reader["banner"].ToString() != "") { model.banner = reader["banner"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["curcountmoney"] != null && reader["curcountmoney"].ToString() != "") { model.curcountmoney = reader["curcountmoney"].ToString(); } if (reader["curcountpeople"] != null && reader["curcountpeople"].ToString() != "") { model.curcountpeople = reader["curcountpeople"].ToString(); } if (reader["curstage"] != null && reader["curstage"].ToString() != "") { model.curstage = reader["curstage"].ToString(); } if (reader["fordio"] != null && reader["fordio"].ToString() != "") { model.fordio = reader["fordio"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnPromotionDef> GetPromotionDefList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnPromotionDef> modelList = new List<EnPromotionDef>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBPromotionDef, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnPromotionDef model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnPromotionDef(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["pid"] != null && dt.Rows[n]["pid"].ToString() != "") { model.pid = int.Parse(dt.Rows[n]["pid"].ToString()); } if (dt.Rows[n]["attribute"] != null && dt.Rows[n]["attribute"].ToString() != "") { model.attribute = dt.Rows[n]["attribute"].ToString(); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["type"] != null && dt.Rows[n]["type"].ToString() != "") { model.type = dt.Rows[n]["type"].ToString(); } if (dt.Rows[n]["value"] != null && dt.Rows[n]["value"].ToString() != "") { model.value = dt.Rows[n]["value"].ToString(); } if (dt.Rows[n]["valueletter"] != null && dt.Rows[n]["valueletter"].ToString() != "") { model.valueletter = dt.Rows[n]["valueletter"].ToString(); } if (dt.Rows[n]["valuetitle"] != null && dt.Rows[n]["valuetitle"].ToString() != "") { model.valuetitle = dt.Rows[n]["valuetitle"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["banner"] != null && dt.Rows[n]["banner"].ToString() != "") { model.banner = dt.Rows[n]["banner"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["curcountmoney"] != null && dt.Rows[n]["curcountmoney"].ToString() != "") { model.curcountmoney = dt.Rows[n]["curcountmoney"].ToString(); } if (dt.Rows[n]["curcountpeople"] != null && dt.Rows[n]["curcountpeople"].ToString() != "") { model.curcountpeople = dt.Rows[n]["curcountpeople"].ToString(); } if (dt.Rows[n]["curstage"] != null && dt.Rows[n]["curstage"].ToString() != "") { model.curstage = dt.Rows[n]["curstage"].ToString(); } if (dt.Rows[n]["fordio"] != null && dt.Rows[n]["fordio"].ToString() != "") { model.fordio = dt.Rows[n]["fordio"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } /// <summary> /// 更新对像 /// </summary> public static int EditPromotionStage(EnPromotionStage model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_promotionstage("); strSql.Append("title,pid,did,stype,smodle,svaluemin,svaluemax,pmodule,prolue,pvalue,sort)"); strSql.Append(" values ("); strSql.Append("@title,@pid,@did,@stype,@smodle,@svaluemin,@svaluemax,@pmodule,@prolue,@pvalue,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,50), new SqlParameter("@pid", SqlDbType.Int,4), new SqlParameter("@did", SqlDbType.Int,4), new SqlParameter("@stype", SqlDbType.Int,4), new SqlParameter("@smodle", SqlDbType.Int,4), new SqlParameter("@svaluemin", SqlDbType.NVarChar,50), new SqlParameter("@svaluemax", SqlDbType.NVarChar,50), new SqlParameter("@pmodule", SqlDbType.Int,4), new SqlParameter("@prolue", SqlDbType.NVarChar,50), new SqlParameter("@pvalue", SqlDbType.VarChar,50), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.pid; parameters[2].Value = model.did; parameters[3].Value = model.stype; parameters[4].Value = model.smodle; parameters[5].Value = model.svaluemin; parameters[6].Value = model.svaluemax; parameters[7].Value = model.pmodule; parameters[8].Value = model.prolue; parameters[9].Value = model.pvalue; parameters[10].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_promotionstage set "); strSql.Append("title=@title,"); strSql.Append("pid=@pid,"); strSql.Append("did=@did,"); strSql.Append("stype=@stype,"); strSql.Append("smodle=@smodle,"); strSql.Append("svaluemin=@svaluemin,"); strSql.Append("svaluemax=@svaluemax,"); strSql.Append("pmodule=@pmodule,"); strSql.Append("prolue=@prolue,"); strSql.Append("pvalue=@pvalue,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,50), new SqlParameter("@pid", SqlDbType.Int,4), new SqlParameter("@did", SqlDbType.Int,4), new SqlParameter("@stype", SqlDbType.Int,4), new SqlParameter("@smodle", SqlDbType.Int,4), new SqlParameter("@svaluemin", SqlDbType.NVarChar,50), new SqlParameter("@svaluemax", SqlDbType.NVarChar,50), new SqlParameter("@pmodule", SqlDbType.Int,4), new SqlParameter("@prolue", SqlDbType.NVarChar,50), new SqlParameter("@pvalue", SqlDbType.VarChar,50), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.pid; parameters[2].Value = model.did; parameters[3].Value = model.stype; parameters[4].Value = model.smodle; parameters[5].Value = model.svaluemin; parameters[6].Value = model.svaluemax; parameters[7].Value = model.pmodule; parameters[8].Value = model.prolue; parameters[9].Value = model.pvalue; parameters[10].Value = model.sort; parameters[11].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnPromotionStage GetPromotionStageInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_PromotionStage "); strSql.Append(strWhere); EnPromotionStage model = new EnPromotionStage(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["pid"] != null && reader["pid"].ToString() != "") { model.pid = int.Parse(reader["pid"].ToString()); } if (reader["did"] != null && reader["did"].ToString() != "") { model.did = int.Parse(reader["did"].ToString()); } if (reader["stype"] != null && reader["stype"].ToString() != "") { model.stype = int.Parse(reader["stype"].ToString()); } if (reader["smodle"] != null && reader["smodle"].ToString() != "") { model.smodle = int.Parse(reader["smodle"].ToString()); } if (reader["svaluemin"] != null && reader["svaluemin"].ToString() != "") { model.svaluemin = reader["svaluemin"].ToString(); } if (reader["svaluemax"] != null && reader["svaluemax"].ToString() != "") { model.svaluemax = reader["svaluemax"].ToString(); } if (reader["pmodule"] != null && reader["pmodule"].ToString() != "") { model.pmodule = int.Parse(reader["pmodule"].ToString()); } if (reader["prolue"] != null && reader["prolue"].ToString() != "") { model.prolue = reader["prolue"].ToString(); } if (reader["pvalue"] != null && reader["pvalue"].ToString() != "") { model.pvalue = reader["pvalue"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnPromotionStage> GetPromotionStageList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnPromotionStage> modelList = new List<EnPromotionStage>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBPromotionStage, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnPromotionStage model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnPromotionStage(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["pid"] != null && dt.Rows[n]["pid"].ToString() != "") { model.pid = int.Parse(dt.Rows[n]["pid"].ToString()); } if (dt.Rows[n]["did"] != null && dt.Rows[n]["did"].ToString() != "") { model.did = int.Parse(dt.Rows[n]["did"].ToString()); } if (dt.Rows[n]["stype"] != null && dt.Rows[n]["stype"].ToString() != "") { model.stype = int.Parse(dt.Rows[n]["stype"].ToString()); } if (dt.Rows[n]["smodle"] != null && dt.Rows[n]["smodle"].ToString() != "") { model.smodle = int.Parse(dt.Rows[n]["smodle"].ToString()); } if (dt.Rows[n]["svaluemin"] != null && dt.Rows[n]["svaluemin"].ToString() != "") { model.svaluemin = dt.Rows[n]["svaluemin"].ToString(); } if (dt.Rows[n]["svaluemax"] != null && dt.Rows[n]["svaluemax"].ToString() != "") { model.svaluemax = dt.Rows[n]["svaluemax"].ToString(); } if (dt.Rows[n]["pmodule"] != null && dt.Rows[n]["pmodule"].ToString() != "") { model.pmodule = int.Parse(dt.Rows[n]["pmodule"].ToString()); } if (dt.Rows[n]["prolue"] != null && dt.Rows[n]["prolue"].ToString() != "") { model.prolue = dt.Rows[n]["prolue"].ToString(); } if (dt.Rows[n]["pvalue"] != null && dt.Rows[n]["pvalue"].ToString() != "") { model.pvalue = dt.Rows[n]["pvalue"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Promotion.cs
C#
oos
65,048
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Dealers { public static int ExitDealer(string title) { SqlParameter[] parames = { new SqlParameter("@title", SqlDbType.NVarChar, 30)}; parames[0].Value = title; return DataCommon.Exists(TableName.TBDealer, " where title=@title", parames); } #region 共公模块 /// <summary> /// 更新对像 /// </summary> public static int EditDealer(EnDealer model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_dealer("); strSql.Append("mid,title,letter,groupid,attribute,industry,productcategory,vip,areacode,address,mapapi,staffsize,regyear,regcity,buy,sell,linkman,phone,mphone,fax,email,postcode,homepage,domain,domainip,icp,surface,logo,thumb,bannel,desimage,descript,keywords,template,hits,sort,createmid,lastedid,lastedittime,auditstatus,linestatus)"); strSql.Append(" values ("); strSql.Append("@mid,@title,@letter,@groupid,@attribute,@industry,@productcategory,@vip,@areacode,@address,@mapapi,@staffsize,@regyear,@regcity,@buy,@sell,@linkman,@phone,@mphone,@fax,@email,@postcode,@homepage,@domain,@domainip,@icp,@surface,@logo,@thumb,@bannel,@desimage,@descript,@keywords,@template,@hits,@sort,@createmid,@lastedid,@lastedittime,@auditstatus,@linestatus)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@mid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@groupid", SqlDbType.Int,4), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@industry", SqlDbType.VarChar,50), new SqlParameter("@productcategory", SqlDbType.VarChar,50), new SqlParameter("@vip", SqlDbType.Int,4), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,60), new SqlParameter("@mapapi", SqlDbType.NVarChar,50), new SqlParameter("@staffsize", SqlDbType.Int,4), new SqlParameter("@regyear", SqlDbType.VarChar,7), new SqlParameter("@regcity", SqlDbType.VarChar,10), new SqlParameter("@buy", SqlDbType.NVarChar,300), new SqlParameter("@sell", SqlDbType.NVarChar,300), new SqlParameter("@linkman", SqlDbType.NVarChar,20), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@mphone", SqlDbType.VarChar,20), new SqlParameter("@fax", SqlDbType.VarChar,20), new SqlParameter("@email", SqlDbType.VarChar,50), new SqlParameter("@postcode", SqlDbType.VarChar,15), new SqlParameter("@homepage", SqlDbType.VarChar,50), new SqlParameter("@domain", SqlDbType.VarChar,50), new SqlParameter("@domainip", SqlDbType.VarChar,50), new SqlParameter("@icp", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4)}; parameters[0].Value = model.mid; parameters[1].Value = model.title; parameters[2].Value = model.letter; parameters[3].Value = model.groupid; parameters[4].Value = model.attribute; parameters[5].Value = model.industry; parameters[6].Value = model.productcategory; parameters[7].Value = model.vip; parameters[8].Value = model.areacode; parameters[9].Value = model.address; parameters[10].Value = model.mapapi; parameters[11].Value = model.staffsize; parameters[12].Value = model.regyear; parameters[13].Value = model.regcity; parameters[14].Value = model.buy; parameters[15].Value = model.sell; parameters[16].Value = model.linkman; parameters[17].Value = model.phone; parameters[18].Value = model.mphone; parameters[19].Value = model.fax; parameters[20].Value = model.email; parameters[21].Value = model.postcode; parameters[22].Value = model.homepage; parameters[23].Value = model.domain; parameters[24].Value = model.domainip; parameters[25].Value = model.icp; parameters[26].Value = model.surface; parameters[27].Value = model.logo; parameters[28].Value = model.thumb; parameters[29].Value = model.bannel; parameters[30].Value = model.desimage; parameters[31].Value = model.descript; parameters[32].Value = model.keywords; parameters[33].Value = model.template; parameters[34].Value = model.hits; parameters[35].Value = model.sort; parameters[36].Value = model.createmid; parameters[37].Value = model.lastedid; parameters[38].Value = model.lastedittime; parameters[39].Value = model.auditstatus; parameters[40].Value = model.linestatus; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_dealer set "); strSql.Append("mid=@mid,"); strSql.Append("title=@title,"); strSql.Append("letter=@letter,"); strSql.Append("groupid=@groupid,"); strSql.Append("attribute=@attribute,"); strSql.Append("industry=@industry,"); strSql.Append("productcategory=@productcategory,"); strSql.Append("vip=@vip,"); strSql.Append("areacode=@areacode,"); strSql.Append("address=@address,"); strSql.Append("mapapi=@mapapi,"); strSql.Append("staffsize=@staffsize,"); strSql.Append("regyear=@regyear,"); strSql.Append("regcity=@regcity,"); strSql.Append("buy=@buy,"); strSql.Append("sell=@sell,"); strSql.Append("linkman=@linkman,"); strSql.Append("phone=@phone,"); strSql.Append("mphone=@mphone,"); strSql.Append("fax=@fax,"); strSql.Append("email=@email,"); strSql.Append("postcode=@postcode,"); strSql.Append("homepage=@homepage,"); strSql.Append("domain=@domain,"); strSql.Append("domainip=@domainip,"); strSql.Append("icp=@icp,"); strSql.Append("surface=@surface,"); strSql.Append("logo=@logo,"); strSql.Append("thumb=@thumb,"); strSql.Append("bannel=@bannel,"); strSql.Append("desimage=@desimage,"); strSql.Append("descript=@descript,"); strSql.Append("keywords=@keywords,"); strSql.Append("template=@template,"); strSql.Append("hits=@hits,"); strSql.Append("sort=@sort,"); strSql.Append("createmid=@createmid,"); strSql.Append("lastedid=@lastedid,"); strSql.Append("lastedittime=@lastedittime,"); strSql.Append("auditstatus=@auditstatus,"); strSql.Append("linestatus=@linestatus"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@mid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@groupid", SqlDbType.Int,4), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@industry", SqlDbType.VarChar,50), new SqlParameter("@productcategory", SqlDbType.VarChar,50), new SqlParameter("@vip", SqlDbType.Int,4), new SqlParameter("@areacode", SqlDbType.VarChar,10), new SqlParameter("@address", SqlDbType.NVarChar,60), new SqlParameter("@mapapi", SqlDbType.NVarChar,50), new SqlParameter("@staffsize", SqlDbType.Int,4), new SqlParameter("@regyear", SqlDbType.VarChar,7), new SqlParameter("@regcity", SqlDbType.VarChar,10), new SqlParameter("@buy", SqlDbType.NVarChar,300), new SqlParameter("@sell", SqlDbType.NVarChar,300), new SqlParameter("@linkman", SqlDbType.NVarChar,20), new SqlParameter("@phone", SqlDbType.VarChar,20), new SqlParameter("@mphone", SqlDbType.VarChar,20), new SqlParameter("@fax", SqlDbType.VarChar,20), new SqlParameter("@email", SqlDbType.VarChar,50), new SqlParameter("@postcode", SqlDbType.VarChar,15), new SqlParameter("@homepage", SqlDbType.VarChar,50), new SqlParameter("@domain", SqlDbType.VarChar,50), new SqlParameter("@domainip", SqlDbType.VarChar,50), new SqlParameter("@icp", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.mid; parameters[1].Value = model.title; parameters[2].Value = model.letter; parameters[3].Value = model.groupid; parameters[4].Value = model.attribute; parameters[5].Value = model.industry; parameters[6].Value = model.productcategory; parameters[7].Value = model.vip; parameters[8].Value = model.areacode; parameters[9].Value = model.address; parameters[10].Value = model.mapapi; parameters[11].Value = model.staffsize; parameters[12].Value = model.regyear; parameters[13].Value = model.regcity; parameters[14].Value = model.buy; parameters[15].Value = model.sell; parameters[16].Value = model.linkman; parameters[17].Value = model.phone; parameters[18].Value = model.mphone; parameters[19].Value = model.fax; parameters[20].Value = model.email; parameters[21].Value = model.postcode; parameters[22].Value = model.homepage; parameters[23].Value = model.domain; parameters[24].Value = model.domainip; parameters[25].Value = model.icp; parameters[26].Value = model.surface; parameters[27].Value = model.logo; parameters[28].Value = model.thumb; parameters[29].Value = model.bannel; parameters[30].Value = model.desimage; parameters[31].Value = model.descript; parameters[32].Value = model.keywords; parameters[33].Value = model.template; parameters[34].Value = model.hits; parameters[35].Value = model.sort; parameters[36].Value = model.createmid; parameters[37].Value = model.lastedid; parameters[38].Value = model.lastedittime; parameters[39].Value = model.auditstatus; parameters[40].Value = model.linestatus; parameters[41].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnDealer GetDealerInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Dealer "); strSql.Append(strWhere); EnDealer model = new EnDealer(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["mid"] != null && reader["mid"].ToString() != "") { model.mid = int.Parse(reader["mid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["industry"] != null && reader["industry"].ToString() != "") { model.industry = reader["industry"].ToString(); } if (reader["productcategory"] != null && reader["productcategory"].ToString() != "") { model.productcategory = reader["productcategory"].ToString(); } if (reader["vip"] != null && reader["vip"].ToString() != "") { model.vip = int.Parse(reader["vip"].ToString()); } if (reader["areacode"] != null && reader["areacode"].ToString() != "") { model.areacode = reader["areacode"].ToString(); } if (reader["address"] != null && reader["address"].ToString() != "") { model.address = reader["address"].ToString(); } if (reader["mapapi"] != null && reader["mapapi"].ToString() != "") { model.mapapi = reader["mapapi"].ToString(); } if (reader["staffsize"] != null && reader["staffsize"].ToString() != "") { model.staffsize = int.Parse(reader["staffsize"].ToString()); } if (reader["regyear"] != null && reader["regyear"].ToString() != "") { model.regyear = reader["regyear"].ToString(); } if (reader["regcity"] != null && reader["regcity"].ToString() != "") { model.regcity = reader["regcity"].ToString(); } if (reader["buy"] != null && reader["buy"].ToString() != "") { model.buy = reader["buy"].ToString(); } if (reader["sell"] != null && reader["sell"].ToString() != "") { model.sell = reader["sell"].ToString(); } if (reader["linkman"] != null && reader["linkman"].ToString() != "") { model.linkman = reader["linkman"].ToString(); } if (reader["phone"] != null && reader["phone"].ToString() != "") { model.phone = reader["phone"].ToString(); } if (reader["mphone"] != null && reader["mphone"].ToString() != "") { model.mphone = reader["mphone"].ToString(); } if (reader["fax"] != null && reader["fax"].ToString() != "") { model.fax = reader["fax"].ToString(); } if (reader["email"] != null && reader["email"].ToString() != "") { model.email = reader["email"].ToString(); } if (reader["postcode"] != null && reader["postcode"].ToString() != "") { model.postcode = reader["postcode"].ToString(); } if (reader["homepage"] != null && reader["homepage"].ToString() != "") { model.homepage = reader["homepage"].ToString(); } if (reader["domain"] != null && reader["domain"].ToString() != "") { model.domain = reader["domain"].ToString(); } if (reader["domainip"] != null && reader["domainip"].ToString() != "") { model.domainip = reader["domainip"].ToString(); } if (reader["icp"] != null && reader["icp"].ToString() != "") { model.icp = reader["icp"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnDealer> GetDealerList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnDealer> modelList = new List<EnDealer>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBDealer, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnDealer model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnDealer(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["mid"] != null && dt.Rows[n]["mid"].ToString() != "") { model.mid = int.Parse(dt.Rows[n]["mid"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["groupid"] != null && dt.Rows[n]["groupid"].ToString() != "") { model.groupid = int.Parse(dt.Rows[n]["groupid"].ToString()); } if (dt.Rows[n]["attribute"] != null && dt.Rows[n]["attribute"].ToString() != "") { model.attribute = dt.Rows[n]["attribute"].ToString(); } if (dt.Rows[n]["industry"] != null && dt.Rows[n]["industry"].ToString() != "") { model.industry = dt.Rows[n]["industry"].ToString(); } if (dt.Rows[n]["productcategory"] != null && dt.Rows[n]["productcategory"].ToString() != "") { model.productcategory = dt.Rows[n]["productcategory"].ToString(); } if (dt.Rows[n]["vip"] != null && dt.Rows[n]["vip"].ToString() != "") { model.vip = int.Parse(dt.Rows[n]["vip"].ToString()); } if (dt.Rows[n]["areacode"] != null && dt.Rows[n]["areacode"].ToString() != "") { model.areacode = dt.Rows[n]["areacode"].ToString(); } if (dt.Rows[n]["address"] != null && dt.Rows[n]["address"].ToString() != "") { model.address = dt.Rows[n]["address"].ToString(); } if (dt.Rows[n]["mapapi"] != null && dt.Rows[n]["mapapi"].ToString() != "") { model.mapapi = dt.Rows[n]["mapapi"].ToString(); } if (dt.Rows[n]["staffsize"] != null && dt.Rows[n]["staffsize"].ToString() != "") { model.staffsize = int.Parse(dt.Rows[n]["staffsize"].ToString()); } if (dt.Rows[n]["regyear"] != null && dt.Rows[n]["regyear"].ToString() != "") { model.regyear = dt.Rows[n]["regyear"].ToString(); } if (dt.Rows[n]["regcity"] != null && dt.Rows[n]["regcity"].ToString() != "") { model.regcity = dt.Rows[n]["regcity"].ToString(); } if (dt.Rows[n]["buy"] != null && dt.Rows[n]["buy"].ToString() != "") { model.buy = dt.Rows[n]["buy"].ToString(); } if (dt.Rows[n]["sell"] != null && dt.Rows[n]["sell"].ToString() != "") { model.sell = dt.Rows[n]["sell"].ToString(); } if (dt.Rows[n]["linkman"] != null && dt.Rows[n]["linkman"].ToString() != "") { model.linkman = dt.Rows[n]["linkman"].ToString(); } if (dt.Rows[n]["phone"] != null && dt.Rows[n]["phone"].ToString() != "") { model.phone = dt.Rows[n]["phone"].ToString(); } if (dt.Rows[n]["mphone"] != null && dt.Rows[n]["mphone"].ToString() != "") { model.mphone = dt.Rows[n]["mphone"].ToString(); } if (dt.Rows[n]["fax"] != null && dt.Rows[n]["fax"].ToString() != "") { model.fax = dt.Rows[n]["fax"].ToString(); } if (dt.Rows[n]["email"] != null && dt.Rows[n]["email"].ToString() != "") { model.email = dt.Rows[n]["email"].ToString(); } if (dt.Rows[n]["postcode"] != null && dt.Rows[n]["postcode"].ToString() != "") { model.postcode = dt.Rows[n]["postcode"].ToString(); } if (dt.Rows[n]["homepage"] != null && dt.Rows[n]["homepage"].ToString() != "") { model.homepage = dt.Rows[n]["homepage"].ToString(); } if (dt.Rows[n]["domain"] != null && dt.Rows[n]["domain"].ToString() != "") { model.domain = dt.Rows[n]["domain"].ToString(); } if (dt.Rows[n]["domainip"] != null && dt.Rows[n]["domainip"].ToString() != "") { model.domainip = dt.Rows[n]["domainip"].ToString(); } if (dt.Rows[n]["icp"] != null && dt.Rows[n]["icp"].ToString() != "") { model.icp = dt.Rows[n]["icp"].ToString(); } if (dt.Rows[n]["surface"] != null && dt.Rows[n]["surface"].ToString() != "") { model.surface = dt.Rows[n]["surface"].ToString(); } if (dt.Rows[n]["logo"] != null && dt.Rows[n]["logo"].ToString() != "") { model.logo = dt.Rows[n]["logo"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["bannel"] != null && dt.Rows[n]["bannel"].ToString() != "") { model.bannel = dt.Rows[n]["bannel"].ToString(); } if (dt.Rows[n]["desimage"] != null && dt.Rows[n]["desimage"].ToString() != "") { model.desimage = dt.Rows[n]["desimage"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["keywords"] != null && dt.Rows[n]["keywords"].ToString() != "") { model.keywords = dt.Rows[n]["keywords"].ToString(); } if (dt.Rows[n]["template"] != null && dt.Rows[n]["template"].ToString() != "") { model.template = dt.Rows[n]["template"].ToString(); } if (dt.Rows[n]["hits"] != null && dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["createmid"] != null && dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } if (dt.Rows[n]["lastedid"] != null && dt.Rows[n]["lastedid"].ToString() != "") { model.lastedid = int.Parse(dt.Rows[n]["lastedid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["auditstatus"] != null && dt.Rows[n]["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(dt.Rows[n]["auditstatus"].ToString()); } if (dt.Rows[n]["linestatus"] != null && dt.Rows[n]["linestatus"].ToString() != "") { model.linestatus = int.Parse(dt.Rows[n]["linestatus"].ToString()); } modelList.Add(model); } } return modelList; } #endregion #region 共公模块-组 /// <summary> /// 更新对像 /// </summary> public static int EditDealerGroup(EnDealerGroup model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_Dealergroup("); strSql.Append("title,color,avatar,integral,money,adcount,shopcount,brandcount,promotioncount,adrecommend,shoprecommend,brandrecommend,promotionrecommend,permissions,lev,descript,sort)"); strSql.Append(" values ("); strSql.Append("@title,@color,@avatar,@integral,@money,@adcount,@shopcount,@brandcount,@promotioncount,@adrecommend,@shoprecommend,@brandrecommend,@promotionrecommend,@permissions,@lev,@descript,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@color", SqlDbType.Char,7), new SqlParameter("@avatar", SqlDbType.VarChar,40), new SqlParameter("@integral", SqlDbType.Decimal,9), new SqlParameter("@money", SqlDbType.Decimal,9), new SqlParameter("@adcount", SqlDbType.Int,4), new SqlParameter("@shopcount", SqlDbType.Int,4), new SqlParameter("@brandcount", SqlDbType.Int,4), new SqlParameter("@promotioncount", SqlDbType.Int,4), new SqlParameter("@adrecommend", SqlDbType.Int,4), new SqlParameter("@shoprecommend", SqlDbType.Int,4), new SqlParameter("@brandrecommend", SqlDbType.Int,4), new SqlParameter("@promotionrecommend", SqlDbType.Int,4), new SqlParameter("@permissions", SqlDbType.NText), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.color; parameters[2].Value = model.avatar; parameters[3].Value = model.integral; parameters[4].Value = model.money; parameters[5].Value = model.adcount; parameters[6].Value = model.shopcount; parameters[7].Value = model.brandcount; parameters[8].Value = model.promotioncount; parameters[9].Value = model.adrecommend; parameters[10].Value = model.shoprecommend; parameters[11].Value = model.brandrecommend; parameters[12].Value = model.promotionrecommend; parameters[13].Value = model.permissions; parameters[14].Value = model.lev; parameters[15].Value = model.descript; parameters[16].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_Dealergroup set "); strSql.Append("title=@title,"); strSql.Append("color=@color,"); strSql.Append("avatar=@avatar,"); strSql.Append("integral=@integral,"); strSql.Append("money=@money,"); strSql.Append("adcount=@adcount,"); strSql.Append("shopcount=@shopcount,"); strSql.Append("brandcount=@brandcount,"); strSql.Append("promotioncount=@promotioncount,"); strSql.Append("adrecommend=@adrecommend,"); strSql.Append("shoprecommend=@shoprecommend,"); strSql.Append("brandrecommend=@brandrecommend,"); strSql.Append("promotionrecommend=@promotionrecommend,"); strSql.Append("permissions=@permissions,"); strSql.Append("lev=@lev,"); strSql.Append("descript=@descript,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar,30), new SqlParameter("@color", SqlDbType.Char,7), new SqlParameter("@avatar", SqlDbType.VarChar,40), new SqlParameter("@integral", SqlDbType.Decimal,9), new SqlParameter("@money", SqlDbType.Decimal,9), new SqlParameter("@adcount", SqlDbType.Int,4), new SqlParameter("@shopcount", SqlDbType.Int,4), new SqlParameter("@brandcount", SqlDbType.Int,4), new SqlParameter("@promotioncount", SqlDbType.Int,4), new SqlParameter("@adrecommend", SqlDbType.Int,4), new SqlParameter("@shoprecommend", SqlDbType.Int,4), new SqlParameter("@brandrecommend", SqlDbType.Int,4), new SqlParameter("@promotionrecommend", SqlDbType.Int,4), new SqlParameter("@permissions", SqlDbType.NText), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@descript", SqlDbType.NVarChar,300), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.title; parameters[1].Value = model.color; parameters[2].Value = model.avatar; parameters[3].Value = model.integral; parameters[4].Value = model.money; parameters[5].Value = model.adcount; parameters[6].Value = model.shopcount; parameters[7].Value = model.brandcount; parameters[8].Value = model.promotioncount; parameters[9].Value = model.adrecommend; parameters[10].Value = model.shoprecommend; parameters[11].Value = model.brandrecommend; parameters[12].Value = model.promotionrecommend; parameters[13].Value = model.permissions; parameters[14].Value = model.lev; parameters[15].Value = model.descript; parameters[16].Value = model.sort; parameters[17].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnDealerGroup GetDealerGroupInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_DealerGroup "); strSql.Append(strWhere); EnDealerGroup model = new EnDealerGroup(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["color"] != null && reader["color"].ToString() != "") { model.color = reader["color"].ToString(); } if (reader["avatar"] != null && reader["avatar"].ToString() != "") { model.avatar = reader["avatar"].ToString(); } if (reader["integral"] != null && reader["integral"].ToString() != "") { model.integral = decimal.Parse(reader["integral"].ToString()); } if (reader["money"] != null && reader["money"].ToString() != "") { model.money = decimal.Parse(reader["money"].ToString()); } if (reader["adcount"] != null && reader["adcount"].ToString() != "") { model.adcount = int.Parse(reader["adcount"].ToString()); } if (reader["shopcount"] != null && reader["shopcount"].ToString() != "") { model.shopcount = int.Parse(reader["shopcount"].ToString()); } if (reader["brandcount"] != null && reader["brandcount"].ToString() != "") { model.brandcount = int.Parse(reader["brandcount"].ToString()); } if (reader["promotioncount"] != null && reader["promotioncount"].ToString() != "") { model.promotioncount = int.Parse(reader["promotioncount"].ToString()); } if (reader["adrecommend"] != null && reader["adrecommend"].ToString() != "") { model.adrecommend = int.Parse(reader["adrecommend"].ToString()); } if (reader["shoprecommend"] != null && reader["shoprecommend"].ToString() != "") { model.shoprecommend = int.Parse(reader["shoprecommend"].ToString()); } if (reader["brandrecommend"] != null && reader["brandrecommend"].ToString() != "") { model.brandrecommend = int.Parse(reader["brandrecommend"].ToString()); } if (reader["promotionrecommend"] != null && reader["promotionrecommend"].ToString() != "") { model.promotionrecommend = int.Parse(reader["promotionrecommend"].ToString()); } if (reader["permissions"] != null && reader["permissions"].ToString() != "") { model.permissions = reader["permissions"].ToString(); } if (reader["lev"] != null && reader["lev"].ToString() != "") { model.lev = int.Parse(reader["lev"].ToString()); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnDealerGroup> GetDealerGroupList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnDealerGroup> modelList = new List<EnDealerGroup>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBDealerGroup, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnDealerGroup model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnDealerGroup(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["color"] != null && dt.Rows[n]["color"].ToString() != "") { model.color = dt.Rows[n]["color"].ToString(); } if (dt.Rows[n]["avatar"] != null && dt.Rows[n]["avatar"].ToString() != "") { model.avatar = dt.Rows[n]["avatar"].ToString(); } if (dt.Rows[n]["integral"] != null && dt.Rows[n]["integral"].ToString() != "") { model.integral = decimal.Parse(dt.Rows[n]["integral"].ToString()); } if (dt.Rows[n]["money"] != null && dt.Rows[n]["money"].ToString() != "") { model.money = decimal.Parse(dt.Rows[n]["money"].ToString()); } if (dt.Rows[n]["adcount"] != null && dt.Rows[n]["adcount"].ToString() != "") { model.adcount = int.Parse(dt.Rows[n]["adcount"].ToString()); } if (dt.Rows[n]["shopcount"] != null && dt.Rows[n]["shopcount"].ToString() != "") { model.shopcount = int.Parse(dt.Rows[n]["shopcount"].ToString()); } if (dt.Rows[n]["brandcount"] != null && dt.Rows[n]["brandcount"].ToString() != "") { model.brandcount = int.Parse(dt.Rows[n]["brandcount"].ToString()); } if (dt.Rows[n]["promotioncount"] != null && dt.Rows[n]["promotioncount"].ToString() != "") { model.promotioncount = int.Parse(dt.Rows[n]["promotioncount"].ToString()); } if (dt.Rows[n]["adrecommend"] != null && dt.Rows[n]["adrecommend"].ToString() != "") { model.adrecommend = int.Parse(dt.Rows[n]["adrecommend"].ToString()); } if (dt.Rows[n]["shoprecommend"] != null && dt.Rows[n]["shoprecommend"].ToString() != "") { model.shoprecommend = int.Parse(dt.Rows[n]["shoprecommend"].ToString()); } if (dt.Rows[n]["brandrecommend"] != null && dt.Rows[n]["brandrecommend"].ToString() != "") { model.brandrecommend = int.Parse(dt.Rows[n]["brandrecommend"].ToString()); } if (dt.Rows[n]["promotionrecommend"] != null && dt.Rows[n]["promotionrecommend"].ToString() != "") { model.promotionrecommend = int.Parse(dt.Rows[n]["promotionrecommend"].ToString()); } if (dt.Rows[n]["permissions"] != null && dt.Rows[n]["permissions"].ToString() != "") { model.permissions = dt.Rows[n]["permissions"].ToString(); } if (dt.Rows[n]["lev"] != null && dt.Rows[n]["lev"].ToString() != "") { model.lev = int.Parse(dt.Rows[n]["lev"].ToString()); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } modelList.Add(model); } } return modelList; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Dealers.cs
C#
oos
49,187
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Products { public static int ExitBrandSku(string sku) { SqlParameter[] parames = { new SqlParameter("@sku", SqlDbType.VarChar, 30)}; parames[0].Value = sku; return DataCommon.Exists(TableName.TBProduct, " where sku=@sku", parames); } /// <summary> /// 获取产品分类(包含某分类产品总数) /// </summary> /// <returns></returns> public static DataTable GetCategoryAndProductCountList() { string sql = @"select c.id,c.title,c.parentid,isnull(pc.c,0) as c from t_productcategory c left join (select categoryid,count(categoryid) as c from v_product group by categoryid) pc on c.id=pc.categoryid where c.linestatus=1 order by lft "; return DbHelper.ExecuteDataset(sql).Tables[0]; } /// <summary> /// 获取产品分类(包含某分类产品总数) /// </summary> /// <returns></returns> public static DataTable GetCategoryAndProductCountList(string strWhere) { string sql = @"select c.id,c.title,c.parentid,isnull(pc.c,0) as c from t_productcategory c left join (select categoryid,count(categoryid) as c from v_product {0} group by categoryid) pc on c.id=pc.categoryid where c.linestatus=1 order by lft"; return DbHelper.ExecuteDataset(string.Format(sql, strWhere != "" ? " where " + strWhere : strWhere)).Tables[0]; } public static List<EnSearchProductItem> GetProductSearchItem(string strWhere) { if (strWhere == "") { strWhere = " 1=1"; } string sql = @"select t,v,n,c,b,bs,pc from (select 'brand' as t,CONVERT(varchar(20),b.brandid) as v,b.brandtitle as n,count(b.brandid) as c, '0' as b,'0' as bs, '0' as pc from v_product b where linestatus=1 and {0} group by b.brandid,b.brandtitle )as brand UNION ALL select t,v,n,c,b,bs,pc from (select 'brands' as t,CONVERT(varchar(20),b.brandsid) as v,b.brandstitle as n,count(b.brandsid) as c, b.brandid as b,'0' as bs, '0' as pc from v_product b where linestatus=1 and {0} group by b.brandsid,b.brandstitle,b.brandid )as brands UNION ALL select t,v,n,c,b,bs,pc from (select 'pcategory' as t,CONVERT(varchar(20),c2.id) as v,c2.title as n,count(c2.id) as c, b.brandid as b,b.brandsid as bs, '0'as pc from v_product b left join t_productcategory c on c.id=b.categoryid left join t_productcategory c2 on c2.id=c.parentid where b.linestatus=1 and {0} group by c2.id,c2.title,b.brandid,b.brandsid )as pcategory UNION ALL select t,v,n,c,b,bs,pc from (select 'category' as t,CONVERT(varchar(20),c.id) as v,c.title as n,count(c.id) as c, b.brandid as b,b.brandsid as bs, c.parentid as pc from v_product b left join t_productcategory c on c.id=b.categoryid where b.linestatus=1 and {0} group by c.id,c.title,b.brandid,b.brandsid,c.parentid )as category"; List<EnSearchProductItem> list = new List<EnSearchProductItem>(); IDataReader reader = DbHelper.ExecuteReader(string.Format(sql, strWhere)); while (reader.Read()) { EnSearchProductItem model = new EnSearchProductItem(); if (reader["t"] != null && reader["t"].ToString() != "") { model.type = reader["t"].ToString(); } if (reader["v"] != null && reader["v"].ToString() != "") { model.value = reader["v"].ToString(); } if (reader["n"] != null && reader["n"].ToString() != "") { model.title = reader["n"].ToString(); } if (reader["c"] != null && reader["c"].ToString() != "") { model.count = int.Parse(reader["c"].ToString()); } if (reader["b"] != null && reader["b"].ToString() != "") { model.brandid = reader["b"].ToString(); } if (reader["bs"] != null && reader["bs"].ToString() != "") { model.brandsid = reader["bs"].ToString(); } if (reader["pc"] != null && reader["pc"].ToString() != "") { model.pcategoryid = reader["pc"].ToString(); } model.isCur = false; list.Add(model); } return list; } public static EnWebProduct GetWebProducInfo(string strWhere) { EnWebProduct model = new EnWebProduct(); IDataReader reader = DataCommon.GetDataIReader(TableName.TVProduct, "", strWhere, ""); while (reader.Read()) { if (reader["shopxml"] != null && reader["shopxml"].ToString() != "") { model.shopxml = reader["shopxml"].ToString(); } if (reader["attributexml"] != null && reader["attributexml"].ToString() != "") { model.attributexml = reader["attributexml"].ToString(); } if (reader["shopprice"] != null && reader["shopprice"].ToString() != "") { model.shopprice = reader["shopprice"].ToString(); } if (reader["spreadname"] != null && reader["spreadname"].ToString() != "") { model.spreadname = reader["spreadname"].ToString(); } if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["shottitle"] != null && reader["shottitle"].ToString() != "") { model.shottitle = reader["shottitle"].ToString(); } if (reader["tcolor"] != null && reader["tcolor"].ToString() != "") { model.tcolor = reader["tcolor"].ToString(); } if (reader["sku"] != null && reader["sku"].ToString() != "") { model.sku = reader["sku"].ToString(); } if (reader["no"] != null && reader["no"].ToString() != "") { model.no = reader["no"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["categoryid"] != null && reader["categoryid"].ToString() != "") { model.categoryid = int.Parse(reader["categoryid"].ToString()); } if (reader["categorytitle"] != null && reader["categorytitle"].ToString() != "") { model.categorytitle = reader["categorytitle"].ToString(); } if (reader["subcategoryidlist"] != null && reader["subcategoryidlist"].ToString() != "") { model.subcategoryidlist = reader["subcategoryidlist"].ToString(); } if (reader["subcategorytitlelist"] != null && reader["subcategorytitlelist"].ToString() != "") { model.subcategorytitlelist = reader["subcategorytitlelist"].ToString(); } if (reader["brandid"] != null && reader["brandid"].ToString() != "") { model.brandid = int.Parse(reader["brandid"].ToString()); } if (reader["brandtitle"] != null && reader["brandtitle"].ToString() != "") { model.brandtitle = reader["brandtitle"].ToString(); } if (reader["brandlogo"] != null && reader["brandlogo"].ToString() != "") { model.brandlogo = reader["brandlogo"].ToString(); } if (reader["brandsid"] != null && reader["brandsid"].ToString() != "") { model.brandsid = int.Parse(reader["brandsid"].ToString()); } if (reader["brandstitle"] != null && reader["brandstitle"].ToString() != "") { model.brandstitle = reader["brandstitle"].ToString(); } if (reader["stylevalue"] != null && reader["stylevalue"].ToString() != "") { model.stylevalue = reader["stylevalue"].ToString(); } if (reader["stylename"] != null && reader["stylename"].ToString() != "") { model.stylename = reader["stylename"].ToString(); } if (reader["colorname"] != null && reader["colorname"].ToString() != "") { model.colorname = reader["colorname"].ToString(); } if (reader["colorvalue"] != null && reader["colorvalue"].ToString() != "") { model.colorvalue = reader["colorvalue"].ToString(); } if (reader["materialvalue"] != null && reader["materialvalue"].ToString() != "") { model.materialvalue = reader["materialvalue"].ToString(); } if (reader["materialname"] != null && reader["materialname"].ToString() != "") { model.materialname = reader["materialname"].ToString(); } if (reader["unit"] != null && reader["unit"].ToString() != "") { model.unit = reader["unit"].ToString(); } if (reader["localitycode"] != null && reader["localitycode"].ToString() != "") { model.localitycode = reader["localitycode"].ToString(); } if (reader["shipcode"] != null && reader["shipcode"].ToString() != "") { model.shipcode = reader["shipcode"].ToString(); } if (reader["customize"] != null && reader["customize"].ToString() != "") { model.customize = int.Parse(reader["customize"].ToString()); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["tob2c"] != null && reader["tob2c"].ToString() != "") { model.tob2c = reader["tob2c"].ToString(); } if (reader["companyid"] != null && reader["companyid"].ToString() != "") { model.companyid = int.Parse(reader["companyid"].ToString()); } if (reader["companyname"] != null && reader["companyname"].ToString() != "") { model.companyname = reader["companyname"].ToString(); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } } return model; } //产品列表 public static List<EnWebProduct> GetWebProductList(int PageIndex, int PageSize, string strWhere,string sortkey, string ordertype, out int pageCount) { List<EnWebProduct> list = new List<EnWebProduct>(); IDataReader reader = DataCommon.GetPageDataReader(TableName.TVProduct, PageIndex, PageSize, strWhere, sortkey, ordertype, out pageCount); while (reader.Read()) { EnWebProduct model = new EnWebProduct(); if (reader["shopxml"] != null && reader["shopxml"].ToString() != "") { model.shopxml = reader["shopxml"].ToString(); } if (reader["attributexml"] != null && reader["attributexml"].ToString() != "") { model.attributexml = reader["attributexml"].ToString(); } if (reader["shopprice"] != null && reader["shopprice"].ToString() != "") { model.shopprice = reader["shopprice"].ToString(); } if (reader["spreadname"] != null && reader["spreadname"].ToString() != "") { model.spreadname = reader["spreadname"].ToString(); } if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["shottitle"] != null && reader["shottitle"].ToString() != "") { model.shottitle = reader["shottitle"].ToString(); } if (reader["tcolor"] != null && reader["tcolor"].ToString() != "") { model.tcolor = reader["tcolor"].ToString(); } if (reader["sku"] != null && reader["sku"].ToString() != "") { model.sku = reader["sku"].ToString(); } if (reader["no"] != null && reader["no"].ToString() != "") { model.no = reader["no"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["categoryid"] != null && reader["categoryid"].ToString() != "") { model.categoryid = int.Parse(reader["categoryid"].ToString()); } if (reader["categorytitle"] != null && reader["categorytitle"].ToString() != "") { model.categorytitle = reader["categorytitle"].ToString(); } if (reader["subcategoryidlist"] != null && reader["subcategoryidlist"].ToString() != "") { model.subcategoryidlist = reader["subcategoryidlist"].ToString(); } if (reader["subcategorytitlelist"] != null && reader["subcategorytitlelist"].ToString() != "") { model.subcategorytitlelist = reader["subcategorytitlelist"].ToString(); } if (reader["brandid"] != null && reader["brandid"].ToString() != "") { model.brandid = int.Parse(reader["brandid"].ToString()); } if (reader["brandtitle"] != null && reader["brandtitle"].ToString() != "") { model.brandtitle = reader["brandtitle"].ToString(); } if (reader["brandlogo"] != null && reader["brandlogo"].ToString() != "") { model.brandlogo = reader["brandlogo"].ToString(); } if (reader["brandsid"] != null && reader["brandsid"].ToString() != "") { model.brandsid = int.Parse(reader["brandsid"].ToString()); } if (reader["brandstitle"] != null && reader["brandstitle"].ToString() != "") { model.brandstitle = reader["brandstitle"].ToString(); } if (reader["stylevalue"] != null && reader["stylevalue"].ToString() != "") { model.stylevalue = reader["stylevalue"].ToString(); } if (reader["stylename"] != null && reader["stylename"].ToString() != "") { model.stylename = reader["stylename"].ToString(); } if (reader["colorname"] != null && reader["colorname"].ToString() != "") { model.colorname = reader["colorname"].ToString(); } if (reader["colorvalue"] != null && reader["colorvalue"].ToString() != "") { model.colorvalue = reader["colorvalue"].ToString(); } if (reader["materialvalue"] != null && reader["materialvalue"].ToString() != "") { model.materialvalue = reader["materialvalue"].ToString(); } if (reader["materialname"] != null && reader["materialname"].ToString() != "") { model.materialname = reader["materialname"].ToString(); } if (reader["unit"] != null && reader["unit"].ToString() != "") { model.unit = reader["unit"].ToString(); } if (reader["localitycode"] != null && reader["localitycode"].ToString() != "") { model.localitycode = reader["localitycode"].ToString(); } if (reader["shipcode"] != null && reader["shipcode"].ToString() != "") { model.shipcode = reader["shipcode"].ToString(); } if (reader["customize"] != null && reader["customize"].ToString() != "") { model.customize = int.Parse(reader["customize"].ToString()); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["tob2c"] != null && reader["tob2c"].ToString() != "") { model.tob2c = reader["tob2c"].ToString(); } if (reader["companyid"] != null && reader["companyid"].ToString() != "") { model.companyid = int.Parse(reader["companyid"].ToString()); } if (reader["companyname"] != null && reader["companyname"].ToString() != "") { model.companyname = reader["companyname"].ToString(); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } list.Add(model); } return list; } public static List<EnSearchItem> GetMarketProductSearchItem(string marketId) { string strSql = @"SELECT t, v, n, c FROM (SELECT 'brand' AS t, CONVERT(varchar(30), brandid) AS v, brandtitle AS n, COUNT(brandid) AS c FROM dbo.v_product WHERE (linestatus = 1) and brandid in (select brandid from t_shopbrand where shopid in(select shopid from t_marketstoreyshop where marketid={0})) GROUP BY brandid, brandtitle) AS brand UNION ALL SELECT t, v, n, c FROM (SELECT 'style' AS t, CONVERT(varchar(30), stylevalue) AS v, stylename AS n, COUNT(stylevalue) AS c FROM dbo.v_product AS v_product_3 WHERE (linestatus = 1) and brandid in (select brandid from t_shopbrand where shopid in(select shopid from t_marketstoreyshop where marketid={0})) GROUP BY stylevalue, stylename) AS style UNION ALL SELECT t, v, n, c FROM (SELECT 'material' AS t, CONVERT(varchar(30), materialvalue) AS v, materialname AS n, COUNT(materialvalue) AS c FROM dbo.v_product AS v_product_2 WHERE (linestatus = 1) and brandid in (select brandid from t_shopbrand where shopid in(select shopid from t_marketstoreyshop where marketid={0})) GROUP BY materialvalue, materialname) AS material UNION ALL SELECT t, v, n, c FROM (SELECT 'color' AS t, CONVERT(varchar(30), colorvalue) AS v, colorname AS n, COUNT(colorvalue) AS c FROM dbo.v_product AS v_product_1 WHERE (linestatus = 1) and brandid in (select brandid from t_shopbrand where shopid in(select shopid from t_marketstoreyshop where marketid={0})) GROUP BY colorvalue, colorname) AS color UNION ALL SELECT t, v, n, c FROM (SELECT 'spread' AS t, CONVERT(varchar(30), g.value) AS v, g.title AS n, COUNT(g.value) AS c FROM dbo.v_product AS p LEFT OUTER JOIN dbo.t_brand AS t ON p.brandid = t.id LEFT OUTER JOIN dbo.t_config AS g ON g.value = t.spread AND g.type = 5 AND g.module = 103 WHERE (p.linestatus = 1) and brandid in (select brandid from t_shopbrand where shopid in(select shopid from t_marketstoreyshop where marketid={0})) GROUP BY g.value, g.title) AS spread UNION ALL SELECT t, v, n, c FROM (SELECT 'type' AS t, CONVERT(varchar(30), a.typevalue) AS v, a.typename AS n, COUNT(p.id) AS c FROM dbo.v_product AS p LEFT OUTER JOIN dbo.t_productattribute AS a ON p.id = a.productid WHERE (p.linestatus = 1) and brandid in (select brandid from t_shopbrand where shopid in(select shopid from t_marketstoreyshop where marketid={0})) GROUP BY a.typevalue, a.typename) AS type"; List<EnSearchItem> list = new List<EnSearchItem>(); IDataReader reader = DbHelper.ExecuteReader(string.Format(strSql,marketId)); while (reader.Read()) { EnSearchItem model = new EnSearchItem(); if (reader["t"] != null && reader["t"].ToString() != "") { model.type = reader["t"].ToString(); } if (reader["v"] != null && reader["v"].ToString() != "") { model.value = reader["v"].ToString(); } if (reader["n"] != null && reader["n"].ToString() != "") { model.title = reader["n"].ToString(); } if (reader["c"] != null && reader["c"].ToString() != "") { model.count = int.Parse(reader["c"].ToString()); } model.isCur = false; list.Add(model); } return list; } //企业搜索选项 public static List<EnSearchItem> GetProductSearchItem() { List<EnSearchItem> list = new List<EnSearchItem>(); IDataReader reader = DbHelper.ExecuteReader(" select * from " + TableName.TVProductSearchItem); while (reader.Read()) { EnSearchItem model = new EnSearchItem(); if (reader["t"] != null && reader["t"].ToString() != "") { model.type = reader["t"].ToString(); } if (reader["v"] != null && reader["v"].ToString() != "") { model.value = reader["v"].ToString(); } if (reader["n"] != null && reader["n"].ToString() != "") { model.title = reader["n"].ToString(); } if (reader["c"] != null && reader["c"].ToString() != "") { model.count = int.Parse(reader["c"].ToString()); } model.isCur = false; list.Add(model); } return list; } public static List<EnSearchItem> GetProductSearchTypeItem(string strWhere) { string sql = @"SELECT 'type' AS t, CONVERT(varchar(30), a.typevalue) AS v, a.typename AS n, COUNT(p.id) AS c FROM dbo.v_product AS p LEFT OUTER JOIN dbo.t_productattribute AS a ON p.id = a.productid WHERE (p.linestatus = 1) {0} GROUP BY a.typevalue, a.typename"; strWhere = strWhere != "" ? " and " + strWhere : strWhere; List<EnSearchItem> list = new List<EnSearchItem>(); IDataReader reader = DbHelper.ExecuteReader(string.Format(sql, strWhere)); while (reader.Read()) { EnSearchItem model = new EnSearchItem(); if (reader["t"] != null && reader["t"].ToString() != "") { model.type = reader["t"].ToString(); } if (reader["v"] != null && reader["v"].ToString() != "") { model.value = reader["v"].ToString(); } if (reader["n"] != null && reader["n"].ToString() != "") { model.title = reader["n"].ToString(); } if (reader["c"] != null && reader["c"].ToString() != "") { model.count = int.Parse(reader["c"].ToString()); } model.isCur = false; list.Add(model); } return list; } /// <summary> /// 更新对像 /// </summary> public static int EditProduct(EnProduct model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_product("); strSql.Append("attribute,title,shottitle,tcolor,sku,no,letter,categoryid,categorytitle,subcategoryidlist,subcategorytitlelist,brandid,brandtitle,brandsid,brandstitle,stylevalue,stylename,colorname,colorvalue,materialvalue,materialname,unit,localitycode,shipcode,customize,surface,logo,thumb,bannel,desimage,descript,tob2c,companyid,companyname,createmid,hits,sort,lastedid,lastedittime,auditstatus,linestatus)"); strSql.Append(" values ("); strSql.Append("@attribute,@title,@shottitle,@tcolor,@sku,@no,@letter,@categoryid,@categorytitle,@subcategoryidlist,@subcategorytitlelist,@brandid,@brandtitle,@brandsid,@brandstitle,@stylevalue,@stylename,@colorname,@colorvalue,@materialvalue,@materialname,@unit,@localitycode,@shipcode,@customize,@surface,@logo,@thumb,@bannel,@desimage,@descript,@tob2c,@companyid,@companyname,@createmid,@hits,@sort,@lastedid,@lastedittime,@auditstatus,@linestatus)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@shottitle", SqlDbType.NVarChar,20), new SqlParameter("@tcolor", SqlDbType.Char,7), new SqlParameter("@sku", SqlDbType.VarChar,50), new SqlParameter("@no", SqlDbType.VarChar,50), new SqlParameter("@letter", SqlDbType.VarChar,30), new SqlParameter("@categoryid", SqlDbType.Int,4), new SqlParameter("@categorytitle", SqlDbType.NVarChar,50), new SqlParameter("@subcategoryidlist", SqlDbType.VarChar,50), new SqlParameter("@subcategorytitlelist", SqlDbType.NVarChar,200), new SqlParameter("@brandid", SqlDbType.Int,4), new SqlParameter("@brandtitle", SqlDbType.NVarChar,50), new SqlParameter("@brandsid", SqlDbType.Int,4), new SqlParameter("@brandstitle", SqlDbType.NVarChar,50), new SqlParameter("@stylevalue", SqlDbType.NVarChar,50), new SqlParameter("@stylename", SqlDbType.NVarChar,50), new SqlParameter("@colorname", SqlDbType.NVarChar,50), new SqlParameter("@colorvalue", SqlDbType.NVarChar,50), new SqlParameter("@materialvalue", SqlDbType.NVarChar,50), new SqlParameter("@materialname", SqlDbType.NVarChar,50), new SqlParameter("@unit", SqlDbType.NVarChar,4), new SqlParameter("@localitycode", SqlDbType.VarChar,12), new SqlParameter("@shipcode", SqlDbType.VarChar,12), new SqlParameter("@customize", SqlDbType.Int,4), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NVarChar,500), new SqlParameter("@tob2c", SqlDbType.VarChar,50), new SqlParameter("@companyid", SqlDbType.Int,4), new SqlParameter("@companyname", SqlDbType.NVarChar,50), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4)}; parameters[0].Value = model.attribute; parameters[1].Value = model.title; parameters[2].Value = model.shottitle; parameters[3].Value = model.tcolor; parameters[4].Value = model.sku; parameters[5].Value = model.no; parameters[6].Value = model.letter; parameters[7].Value = model.categoryid; parameters[8].Value = model.categorytitle; parameters[9].Value = model.subcategoryidlist; parameters[10].Value = model.subcategorytitlelist; parameters[11].Value = model.brandid; parameters[12].Value = model.brandtitle; parameters[13].Value = model.brandsid; parameters[14].Value = model.brandstitle; parameters[15].Value = model.stylevalue; parameters[16].Value = model.stylename; parameters[17].Value = model.colorname; parameters[18].Value = model.colorvalue; parameters[19].Value = model.materialvalue; parameters[20].Value = model.materialname; parameters[21].Value = model.unit; parameters[22].Value = model.localitycode; parameters[23].Value = model.shipcode; parameters[24].Value = model.customize; parameters[25].Value = model.surface; parameters[26].Value = model.logo; parameters[27].Value = model.thumb; parameters[28].Value = model.bannel; parameters[29].Value = model.desimage; parameters[30].Value = model.descript; parameters[31].Value = model.tob2c; parameters[32].Value = model.companyid; parameters[33].Value = model.companyname; parameters[34].Value = model.createmid; parameters[35].Value = model.hits; parameters[36].Value = model.sort; parameters[37].Value = model.lastedid; parameters[38].Value = model.lastedittime; parameters[39].Value = model.auditstatus; parameters[40].Value = model.linestatus; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_product set "); strSql.Append("attribute=@attribute,"); strSql.Append("title=@title,"); strSql.Append("shottitle=@shottitle,"); strSql.Append("tcolor=@tcolor,"); strSql.Append("sku=@sku,"); strSql.Append("no=@no,"); strSql.Append("letter=@letter,"); strSql.Append("categoryid=@categoryid,"); strSql.Append("categorytitle=@categorytitle,"); strSql.Append("subcategoryidlist=@subcategoryidlist,"); strSql.Append("subcategorytitlelist=@subcategorytitlelist,"); strSql.Append("brandid=@brandid,"); strSql.Append("brandtitle=@brandtitle,"); strSql.Append("brandsid=@brandsid,"); strSql.Append("brandstitle=@brandstitle,"); strSql.Append("stylevalue=@stylevalue,"); strSql.Append("stylename=@stylename,"); strSql.Append("colorname=@colorname,"); strSql.Append("colorvalue=@colorvalue,"); strSql.Append("materialvalue=@materialvalue,"); strSql.Append("materialname=@materialname,"); strSql.Append("unit=@unit,"); strSql.Append("localitycode=@localitycode,"); strSql.Append("shipcode=@shipcode,"); strSql.Append("customize=@customize,"); strSql.Append("surface=@surface,"); strSql.Append("logo=@logo,"); strSql.Append("thumb=@thumb,"); strSql.Append("bannel=@bannel,"); strSql.Append("desimage=@desimage,"); strSql.Append("descript=@descript,"); strSql.Append("tob2c=@tob2c,"); strSql.Append("companyid=@companyid,"); strSql.Append("companyname=@companyname,"); strSql.Append("createmid=@createmid,"); strSql.Append("hits=@hits,"); strSql.Append("sort=@sort,"); strSql.Append("lastedid=@lastedid,"); strSql.Append("lastedittime=@lastedittime,"); strSql.Append("auditstatus=@auditstatus,"); strSql.Append("linestatus=@linestatus"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@shottitle", SqlDbType.NVarChar,20), new SqlParameter("@tcolor", SqlDbType.Char,7), new SqlParameter("@sku", SqlDbType.VarChar,50), new SqlParameter("@no", SqlDbType.VarChar,50), new SqlParameter("@letter", SqlDbType.VarChar,30), new SqlParameter("@categoryid", SqlDbType.Int,4), new SqlParameter("@categorytitle", SqlDbType.NVarChar,50), new SqlParameter("@subcategoryidlist", SqlDbType.VarChar,50), new SqlParameter("@subcategorytitlelist", SqlDbType.NVarChar,200), new SqlParameter("@brandid", SqlDbType.Int,4), new SqlParameter("@brandtitle", SqlDbType.NVarChar,50), new SqlParameter("@brandsid", SqlDbType.Int,4), new SqlParameter("@brandstitle", SqlDbType.NVarChar,50), new SqlParameter("@stylevalue", SqlDbType.NVarChar,50), new SqlParameter("@stylename", SqlDbType.NVarChar,50), new SqlParameter("@colorname", SqlDbType.NVarChar,50), new SqlParameter("@colorvalue", SqlDbType.NVarChar,50), new SqlParameter("@materialvalue", SqlDbType.NVarChar,50), new SqlParameter("@materialname", SqlDbType.NVarChar,50), new SqlParameter("@unit", SqlDbType.NVarChar,4), new SqlParameter("@localitycode", SqlDbType.VarChar,12), new SqlParameter("@shipcode", SqlDbType.VarChar,12), new SqlParameter("@customize", SqlDbType.Int,4), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NVarChar,500), new SqlParameter("@tob2c", SqlDbType.VarChar,50), new SqlParameter("@companyid", SqlDbType.Int,4), new SqlParameter("@companyname", SqlDbType.NVarChar,50), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.attribute; parameters[1].Value = model.title; parameters[2].Value = model.shottitle; parameters[3].Value = model.tcolor; parameters[4].Value = model.sku; parameters[5].Value = model.no; parameters[6].Value = model.letter; parameters[7].Value = model.categoryid; parameters[8].Value = model.categorytitle; parameters[9].Value = model.subcategoryidlist; parameters[10].Value = model.subcategorytitlelist; parameters[11].Value = model.brandid; parameters[12].Value = model.brandtitle; parameters[13].Value = model.brandsid; parameters[14].Value = model.brandstitle; parameters[15].Value = model.stylevalue; parameters[16].Value = model.stylename; parameters[17].Value = model.colorname; parameters[18].Value = model.colorvalue; parameters[19].Value = model.materialvalue; parameters[20].Value = model.materialname; parameters[21].Value = model.unit; parameters[22].Value = model.localitycode; parameters[23].Value = model.shipcode; parameters[24].Value = model.customize; parameters[25].Value = model.surface; parameters[26].Value = model.logo; parameters[27].Value = model.thumb; parameters[28].Value = model.bannel; parameters[29].Value = model.desimage; parameters[30].Value = model.descript; parameters[31].Value = model.tob2c; parameters[32].Value = model.companyid; parameters[33].Value = model.companyname; parameters[34].Value = model.createmid; parameters[35].Value = model.hits; parameters[36].Value = model.sort; parameters[37].Value = model.lastedid; parameters[38].Value = model.lastedittime; parameters[39].Value = model.auditstatus; parameters[40].Value = model.linestatus; parameters[41].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnProduct GetProductInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Product "); strSql.Append(strWhere); EnProduct model = new EnProduct(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["shottitle"] != null && reader["shottitle"].ToString() != "") { model.shottitle = reader["shottitle"].ToString(); } if (reader["tcolor"] != null && reader["tcolor"].ToString() != "") { model.tcolor = reader["tcolor"].ToString(); } if (reader["sku"] != null && reader["sku"].ToString() != "") { model.sku = reader["sku"].ToString(); } if (reader["no"] != null && reader["no"].ToString() != "") { model.no = reader["no"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["categoryid"] != null && reader["categoryid"].ToString() != "") { model.categoryid = int.Parse(reader["categoryid"].ToString()); } if (reader["categorytitle"] != null && reader["categorytitle"].ToString() != "") { model.categorytitle = reader["categorytitle"].ToString(); } if (reader["subcategoryidlist"] != null && reader["subcategoryidlist"].ToString() != "") { model.subcategoryidlist = reader["subcategoryidlist"].ToString(); } if (reader["subcategorytitlelist"] != null && reader["subcategorytitlelist"].ToString() != "") { model.subcategorytitlelist = reader["subcategorytitlelist"].ToString(); } if (reader["brandid"] != null && reader["brandid"].ToString() != "") { model.brandid = int.Parse(reader["brandid"].ToString()); } if (reader["brandtitle"] != null && reader["brandtitle"].ToString() != "") { model.brandtitle = reader["brandtitle"].ToString(); } if (reader["brandsid"] != null && reader["brandsid"].ToString() != "") { model.brandsid = int.Parse(reader["brandsid"].ToString()); } if (reader["brandstitle"] != null && reader["brandstitle"].ToString() != "") { model.brandstitle = reader["brandstitle"].ToString(); } if (reader["stylevalue"] != null && reader["stylevalue"].ToString() != "") { model.stylevalue = reader["stylevalue"].ToString(); } if (reader["stylename"] != null && reader["stylename"].ToString() != "") { model.stylename = reader["stylename"].ToString(); } if (reader["colorname"] != null && reader["colorname"].ToString() != "") { model.colorname = reader["colorname"].ToString(); } if (reader["colorvalue"] != null && reader["colorvalue"].ToString() != "") { model.colorvalue = reader["colorvalue"].ToString(); } if (reader["materialvalue"] != null && reader["materialvalue"].ToString() != "") { model.materialvalue = reader["materialvalue"].ToString(); } if (reader["materialname"] != null && reader["materialname"].ToString() != "") { model.materialname = reader["materialname"].ToString(); } if (reader["unit"] != null && reader["unit"].ToString() != "") { model.unit = reader["unit"].ToString(); } if (reader["localitycode"] != null && reader["localitycode"].ToString() != "") { model.localitycode = reader["localitycode"].ToString(); } if (reader["shipcode"] != null && reader["shipcode"].ToString() != "") { model.shipcode = reader["shipcode"].ToString(); } if (reader["customize"] != null && reader["customize"].ToString() != "") { model.customize = int.Parse(reader["customize"].ToString()); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["tob2c"] != null && reader["tob2c"].ToString() != "") { model.tob2c = reader["tob2c"].ToString(); } if (reader["companyid"] != null && reader["companyid"].ToString() != "") { model.companyid = int.Parse(reader["companyid"].ToString()); } if (reader["companyname"] != null && reader["companyname"].ToString() != "") { model.companyname = reader["companyname"].ToString(); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnProduct> GetProductList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnProduct> modelList = new List<EnProduct>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBProduct, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnProduct model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnProduct(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["attribute"] != null && dt.Rows[n]["attribute"].ToString() != "") { model.attribute = dt.Rows[n]["attribute"].ToString(); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["shottitle"] != null && dt.Rows[n]["shottitle"].ToString() != "") { model.shottitle = dt.Rows[n]["shottitle"].ToString(); } if (dt.Rows[n]["tcolor"] != null && dt.Rows[n]["tcolor"].ToString() != "") { model.tcolor = dt.Rows[n]["tcolor"].ToString(); } if (dt.Rows[n]["sku"] != null && dt.Rows[n]["sku"].ToString() != "") { model.sku = dt.Rows[n]["sku"].ToString(); } if (dt.Rows[n]["no"] != null && dt.Rows[n]["no"].ToString() != "") { model.no = dt.Rows[n]["no"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["categoryid"] != null && dt.Rows[n]["categoryid"].ToString() != "") { model.categoryid = int.Parse(dt.Rows[n]["categoryid"].ToString()); } if (dt.Rows[n]["categorytitle"] != null && dt.Rows[n]["categorytitle"].ToString() != "") { model.categorytitle = dt.Rows[n]["categorytitle"].ToString(); } if (dt.Rows[n]["subcategoryidlist"] != null && dt.Rows[n]["subcategoryidlist"].ToString() != "") { model.subcategoryidlist = dt.Rows[n]["subcategoryidlist"].ToString(); } if (dt.Rows[n]["subcategorytitlelist"] != null && dt.Rows[n]["subcategorytitlelist"].ToString() != "") { model.subcategorytitlelist = dt.Rows[n]["subcategorytitlelist"].ToString(); } if (dt.Rows[n]["brandid"] != null && dt.Rows[n]["brandid"].ToString() != "") { model.brandid = int.Parse(dt.Rows[n]["brandid"].ToString()); } if (dt.Rows[n]["brandtitle"] != null && dt.Rows[n]["brandtitle"].ToString() != "") { model.brandtitle = dt.Rows[n]["brandtitle"].ToString(); } if (dt.Rows[n]["brandsid"] != null && dt.Rows[n]["brandsid"].ToString() != "") { model.brandsid = int.Parse(dt.Rows[n]["brandsid"].ToString()); } if (dt.Rows[n]["brandstitle"] != null && dt.Rows[n]["brandstitle"].ToString() != "") { model.brandstitle = dt.Rows[n]["brandstitle"].ToString(); } if (dt.Rows[n]["stylevalue"] != null && dt.Rows[n]["stylevalue"].ToString() != "") { model.stylevalue = dt.Rows[n]["stylevalue"].ToString(); } if (dt.Rows[n]["stylename"] != null && dt.Rows[n]["stylename"].ToString() != "") { model.stylename = dt.Rows[n]["stylename"].ToString(); } if (dt.Rows[n]["colorname"] != null && dt.Rows[n]["colorname"].ToString() != "") { model.colorname = dt.Rows[n]["colorname"].ToString(); } if (dt.Rows[n]["colorvalue"] != null && dt.Rows[n]["colorvalue"].ToString() != "") { model.colorvalue = dt.Rows[n]["colorvalue"].ToString(); } if (dt.Rows[n]["materialvalue"] != null && dt.Rows[n]["materialvalue"].ToString() != "") { model.materialvalue = dt.Rows[n]["materialvalue"].ToString(); } if (dt.Rows[n]["materialname"] != null && dt.Rows[n]["materialname"].ToString() != "") { model.materialname = dt.Rows[n]["materialname"].ToString(); } if (dt.Rows[n]["unit"] != null && dt.Rows[n]["unit"].ToString() != "") { model.unit = dt.Rows[n]["unit"].ToString(); } if (dt.Rows[n]["localitycode"] != null && dt.Rows[n]["localitycode"].ToString() != "") { model.localitycode = dt.Rows[n]["localitycode"].ToString(); } if (dt.Rows[n]["shipcode"] != null && dt.Rows[n]["shipcode"].ToString() != "") { model.shipcode = dt.Rows[n]["shipcode"].ToString(); } if (dt.Rows[n]["customize"] != null && dt.Rows[n]["customize"].ToString() != "") { model.customize = int.Parse(dt.Rows[n]["customize"].ToString()); } if (dt.Rows[n]["surface"] != null && dt.Rows[n]["surface"].ToString() != "") { model.surface = dt.Rows[n]["surface"].ToString(); } if (dt.Rows[n]["logo"] != null && dt.Rows[n]["logo"].ToString() != "") { model.logo = dt.Rows[n]["logo"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["bannel"] != null && dt.Rows[n]["bannel"].ToString() != "") { model.bannel = dt.Rows[n]["bannel"].ToString(); } if (dt.Rows[n]["desimage"] != null && dt.Rows[n]["desimage"].ToString() != "") { model.desimage = dt.Rows[n]["desimage"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["tob2c"] != null && dt.Rows[n]["tob2c"].ToString() != "") { model.tob2c = dt.Rows[n]["tob2c"].ToString(); } if (dt.Rows[n]["companyid"] != null && dt.Rows[n]["companyid"].ToString() != "") { model.companyid = int.Parse(dt.Rows[n]["companyid"].ToString()); } if (dt.Rows[n]["companyname"] != null && dt.Rows[n]["companyname"].ToString() != "") { model.companyname = dt.Rows[n]["companyname"].ToString(); } if (dt.Rows[n]["createmid"] != null && dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } if (dt.Rows[n]["hits"] != null && dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["lastedid"] != null && dt.Rows[n]["lastedid"].ToString() != "") { model.lastedid = int.Parse(dt.Rows[n]["lastedid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["auditstatus"] != null && dt.Rows[n]["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(dt.Rows[n]["auditstatus"].ToString()); } if (dt.Rows[n]["linestatus"] != null && dt.Rows[n]["linestatus"].ToString() != "") { model.linestatus = int.Parse(dt.Rows[n]["linestatus"].ToString()); } modelList.Add(model); } } return modelList; } #region 产品内容 public static int EditProductCon(EnProductCon model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_productcon("); strSql.Append("productid,contype,con)"); strSql.Append(" values ("); strSql.Append("@productid,@contype,@con)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@productid", SqlDbType.Int,4), new SqlParameter("@contype", SqlDbType.Int,4), new SqlParameter("@con", SqlDbType.NText)}; parameters[0].Value = model.productid; parameters[1].Value = model.contype; parameters[2].Value = model.con; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_productcon set "); strSql.Append("productid=@productid,"); strSql.Append("contype=@contype,"); strSql.Append("con=@con"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@productid", SqlDbType.Int,4), new SqlParameter("@contype", SqlDbType.Int,4), new SqlParameter("@con", SqlDbType.NText), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.productid; parameters[1].Value = model.contype; parameters[2].Value = model.con; parameters[3].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnProductCon GetProductConInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_ProductCon "); strSql.Append(strWhere); EnProductCon model = new EnProductCon(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["productid"] != null && reader["productid"].ToString() != "") { model.productid = int.Parse(reader["productid"].ToString()); } if (reader["contype"] != null && reader["contype"].ToString() != "") { model.contype = int.Parse(reader["contype"].ToString()); } if (reader["con"] != null && reader["con"].ToString() != "") { model.con = reader["con"].ToString(); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnProductCon> GetProductConList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnProductCon> modelList = new List<EnProductCon>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBProductCon, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnProductCon model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnProductCon(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["productid"] != null && dt.Rows[n]["productid"].ToString() != "") { model.productid = int.Parse(dt.Rows[n]["productid"].ToString()); } if (dt.Rows[n]["contype"] != null && dt.Rows[n]["contype"].ToString() != "") { model.contype = int.Parse(dt.Rows[n]["contype"].ToString()); } if (dt.Rows[n]["con"] != null && dt.Rows[n]["con"].ToString() != "") { model.con = dt.Rows[n]["con"].ToString(); } modelList.Add(model); } } return modelList; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Products.cs
C#
oos
71,409
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Advertisements { #region 共公广告 /// <summary> /// 更新对像 /// </summary> public static int EditAdvertisement(EnAdvertisement model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_advertising("); strSql.Append("categoryid,title,linkurl,flashurl,imgurl,videourl,adtext,adcode,isopen,adlinkman,adlinkphone,adlinkemail,lastedittime,lasteditaid)"); strSql.Append(" values ("); strSql.Append("@categoryid,@title,@linkurl,@flashurl,@imgurl,@videourl,@adtext,@adcode,@isopen,@adlinkman,@adlinkphone,@adlinkemail,@lastedittime,@lasteditaid)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@categoryid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,50), new SqlParameter("@linkurl", SqlDbType.VarChar,100), new SqlParameter("@flashurl", SqlDbType.VarChar,100), new SqlParameter("@imgurl", SqlDbType.VarChar,100), new SqlParameter("@videourl", SqlDbType.VarChar,100), new SqlParameter("@adtext", SqlDbType.NVarChar,2000), new SqlParameter("@adcode", SqlDbType.VarChar,2000), new SqlParameter("@isopen", SqlDbType.Int,4), new SqlParameter("@adlinkman", SqlDbType.NVarChar,20), new SqlParameter("@adlinkphone", SqlDbType.NVarChar,20), new SqlParameter("@adlinkemail", SqlDbType.NVarChar,20), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@lasteditaid", SqlDbType.Int,4)}; parameters[0].Value = model.categoryid; parameters[1].Value = model.title; parameters[2].Value = model.linkurl; parameters[3].Value = model.flashurl; parameters[4].Value = model.imgurl; parameters[5].Value = model.videourl; parameters[6].Value = model.adtext; parameters[7].Value = model.adcode; parameters[8].Value = model.isopen; parameters[9].Value = model.adlinkman; parameters[10].Value = model.adlinkphone; parameters[11].Value = model.adlinkemail; parameters[12].Value = model.lastedittime; parameters[13].Value = model.lasteditaid; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_advertising set "); strSql.Append("categoryid=@categoryid,"); strSql.Append("title=@title,"); strSql.Append("linkurl=@linkurl,"); strSql.Append("flashurl=@flashurl,"); strSql.Append("imgurl=@imgurl,"); strSql.Append("videourl=@videourl,"); strSql.Append("adtext=@adtext,"); strSql.Append("adcode=@adcode,"); strSql.Append("isopen=@isopen,"); strSql.Append("adlinkman=@adlinkman,"); strSql.Append("adlinkphone=@adlinkphone,"); strSql.Append("adlinkemail=@adlinkemail,"); strSql.Append("lastedittime=@lastedittime,"); strSql.Append("lasteditaid=@lasteditaid"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@categoryid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,50), new SqlParameter("@linkurl", SqlDbType.VarChar,100), new SqlParameter("@flashurl", SqlDbType.VarChar,100), new SqlParameter("@imgurl", SqlDbType.VarChar,100), new SqlParameter("@videourl", SqlDbType.VarChar,100), new SqlParameter("@adtext", SqlDbType.NVarChar,2000), new SqlParameter("@adcode", SqlDbType.VarChar,2000), new SqlParameter("@isopen", SqlDbType.Int,4), new SqlParameter("@adlinkman", SqlDbType.NVarChar,20), new SqlParameter("@adlinkphone", SqlDbType.NVarChar,20), new SqlParameter("@adlinkemail", SqlDbType.NVarChar,20), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@lasteditaid", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.categoryid; parameters[1].Value = model.title; parameters[2].Value = model.linkurl; parameters[3].Value = model.flashurl; parameters[4].Value = model.imgurl; parameters[5].Value = model.videourl; parameters[6].Value = model.adtext; parameters[7].Value = model.adcode; parameters[8].Value = model.isopen; parameters[9].Value = model.adlinkman; parameters[10].Value = model.adlinkphone; parameters[11].Value = model.adlinkemail; parameters[12].Value = model.lastedittime; parameters[13].Value = model.lasteditaid; parameters[14].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnAdvertisement GetAdvertisementInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_advertising "); strSql.Append(strWhere); EnAdvertisement model = new EnAdvertisement(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["categoryid"] != null && reader["categoryid"].ToString() != "") { model.categoryid = int.Parse(reader["categoryid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["linkurl"] != null && reader["linkurl"].ToString() != "") { model.linkurl = reader["linkurl"].ToString(); } if (reader["flashurl"] != null && reader["flashurl"].ToString() != "") { model.flashurl = reader["flashurl"].ToString(); } if (reader["imgurl"] != null && reader["imgurl"].ToString() != "") { model.imgurl = reader["imgurl"].ToString(); } if (reader["videourl"] != null && reader["videourl"].ToString() != "") { model.videourl = reader["videourl"].ToString(); } if (reader["adtext"] != null && reader["adtext"].ToString() != "") { model.adtext = reader["adtext"].ToString(); } if (reader["adcode"] != null && reader["adcode"].ToString() != "") { model.adcode = reader["adcode"].ToString(); } if (reader["isopen"] != null && reader["isopen"].ToString() != "") { model.isopen = int.Parse(reader["isopen"].ToString()); } if (reader["adlinkman"] != null && reader["adlinkman"].ToString() != "") { model.adlinkman = reader["adlinkman"].ToString(); } if (reader["adlinkphone"] != null && reader["adlinkphone"].ToString() != "") { model.adlinkphone = reader["adlinkphone"].ToString(); } if (reader["adlinkemail"] != null && reader["adlinkemail"].ToString() != "") { model.adlinkemail = reader["adlinkemail"].ToString(); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["lasteditaid"] != null && reader["lasteditaid"].ToString() != "") { model.lasteditaid = int.Parse(reader["lasteditaid"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnAdvertisement> GetAdvertisementList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnAdvertisement> modelList = new List<EnAdvertisement>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBAdvertisement, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnAdvertisement model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnAdvertisement(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["categoryid"] != null && dt.Rows[n]["categoryid"].ToString() != "") { model.categoryid = int.Parse(dt.Rows[n]["categoryid"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["linkurl"] != null && dt.Rows[n]["linkurl"].ToString() != "") { model.linkurl = dt.Rows[n]["linkurl"].ToString(); } if (dt.Rows[n]["flashurl"] != null && dt.Rows[n]["flashurl"].ToString() != "") { model.flashurl = dt.Rows[n]["flashurl"].ToString(); } if (dt.Rows[n]["imgurl"] != null && dt.Rows[n]["imgurl"].ToString() != "") { model.imgurl = dt.Rows[n]["imgurl"].ToString(); } if (dt.Rows[n]["videourl"] != null && dt.Rows[n]["videourl"].ToString() != "") { model.videourl = dt.Rows[n]["videourl"].ToString(); } if (dt.Rows[n]["adtext"] != null && dt.Rows[n]["adtext"].ToString() != "") { model.adtext = dt.Rows[n]["adtext"].ToString(); } if (dt.Rows[n]["adcode"] != null && dt.Rows[n]["adcode"].ToString() != "") { model.adcode = dt.Rows[n]["adcode"].ToString(); } if (dt.Rows[n]["isopen"] != null && dt.Rows[n]["isopen"].ToString() != "") { model.isopen = int.Parse(dt.Rows[n]["isopen"].ToString()); } if (dt.Rows[n]["adlinkman"] != null && dt.Rows[n]["adlinkman"].ToString() != "") { model.adlinkman = dt.Rows[n]["adlinkman"].ToString(); } if (dt.Rows[n]["adlinkphone"] != null && dt.Rows[n]["adlinkphone"].ToString() != "") { model.adlinkphone = dt.Rows[n]["adlinkphone"].ToString(); } if (dt.Rows[n]["adlinkemail"] != null && dt.Rows[n]["adlinkemail"].ToString() != "") { model.adlinkemail = dt.Rows[n]["adlinkemail"].ToString(); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["lasteditaid"] != null && dt.Rows[n]["lasteditaid"].ToString() != "") { model.lasteditaid = int.Parse(dt.Rows[n]["lasteditaid"].ToString()); } modelList.Add(model); } } return modelList; } #endregion #region 共公广告分类 /// <summary> /// 更新对像 /// </summary> public static int EditAdvertisementCategory(EnAdvertisementCategory model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_advertisingcategory("); strSql.Append("parentid,moduleid,modulevalue,title,img,height,width,isopen,adtype,starttime,endtime,descript,template,sort)"); strSql.Append(" values ("); strSql.Append("@parentid,@moduleid,@modulevalue,@title,@img,@height,@width,@isopen,@adtype,@starttime,@endtime,@descript,@template,@sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@parentid", SqlDbType.Int,4), new SqlParameter("@moduleid", SqlDbType.Int,4), new SqlParameter("@modulevalue", SqlDbType.NVarChar,50), new SqlParameter("@title", SqlDbType.NVarChar,50), new SqlParameter("@img", SqlDbType.VarChar,50), new SqlParameter("@height", SqlDbType.Int,4), new SqlParameter("@width", SqlDbType.Int,4), new SqlParameter("@isopen", SqlDbType.Int,4), new SqlParameter("@adtype", SqlDbType.Int,4), new SqlParameter("@starttime", SqlDbType.DateTime), new SqlParameter("@endtime", SqlDbType.DateTime), new SqlParameter("@descript", SqlDbType.NChar,10), new SqlParameter("@template", SqlDbType.NVarChar,2000), new SqlParameter("@sort", SqlDbType.Int,4)}; parameters[0].Value = model.parentid; parameters[1].Value = model.moduleid; parameters[2].Value = model.modulevalue; parameters[3].Value = model.title; parameters[4].Value = model.img; parameters[5].Value = model.height; parameters[6].Value = model.width; parameters[7].Value = model.isopen; parameters[8].Value = model.adtype; parameters[9].Value = model.starttime; parameters[10].Value = model.endtime; parameters[11].Value = model.descript; parameters[12].Value = model.template; parameters[13].Value = model.sort; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_advertisingcategory set "); strSql.Append("parentid=@parentid,"); strSql.Append("moduleid=@moduleid,"); strSql.Append("modulevalue=@modulevalue,"); strSql.Append("title=@title,"); strSql.Append("img=@img,"); strSql.Append("height=@height,"); strSql.Append("width=@width,"); strSql.Append("isopen=@isopen,"); strSql.Append("adtype=@adtype,"); strSql.Append("starttime=@starttime,"); strSql.Append("endtime=@endtime,"); strSql.Append("descript=@descript,"); strSql.Append("template=@template,"); strSql.Append("sort=@sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@parentid", SqlDbType.Int,4), new SqlParameter("@moduleid", SqlDbType.Int,4), new SqlParameter("@modulevalue", SqlDbType.NVarChar,50), new SqlParameter("@title", SqlDbType.NVarChar,50), new SqlParameter("@img", SqlDbType.VarChar,50), new SqlParameter("@height", SqlDbType.Int,4), new SqlParameter("@width", SqlDbType.Int,4), new SqlParameter("@isopen", SqlDbType.Int,4), new SqlParameter("@adtype", SqlDbType.Int,4), new SqlParameter("@starttime", SqlDbType.DateTime), new SqlParameter("@endtime", SqlDbType.DateTime), new SqlParameter("@descript", SqlDbType.NChar,10), new SqlParameter("@template", SqlDbType.NVarChar,2000), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.parentid; parameters[1].Value = model.moduleid; parameters[2].Value = model.modulevalue; parameters[3].Value = model.title; parameters[4].Value = model.img; parameters[5].Value = model.height; parameters[6].Value = model.width; parameters[7].Value = model.isopen; parameters[8].Value = model.adtype; parameters[9].Value = model.starttime; parameters[10].Value = model.endtime; parameters[11].Value = model.descript; parameters[12].Value = model.template; parameters[13].Value = model.sort; parameters[14].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnAdvertisementCategory GetAdvertisementCategoryInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_advertisingcategory "); strSql.Append(strWhere); EnAdvertisementCategory model = new EnAdvertisementCategory(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["parentid"] != null && reader["parentid"].ToString() != "") { model.parentid = int.Parse(reader["parentid"].ToString()); } if (reader["moduleid"] != null && reader["moduleid"].ToString() != "") { model.moduleid = int.Parse(reader["moduleid"].ToString()); } if (reader["modulevalue"] != null && reader["modulevalue"].ToString() != "") { model.modulevalue = reader["modulevalue"].ToString(); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["img"] != null && reader["img"].ToString() != "") { model.img = reader["img"].ToString(); } if (reader["height"] != null && reader["height"].ToString() != "") { model.height = int.Parse(reader["height"].ToString()); } if (reader["width"] != null && reader["width"].ToString() != "") { model.width = int.Parse(reader["width"].ToString()); } if (reader["isopen"] != null && reader["isopen"].ToString() != "") { model.isopen = int.Parse(reader["isopen"].ToString()); } if (reader["adtype"] != null && reader["adtype"].ToString() != "") { model.adtype = int.Parse(reader["adtype"].ToString()); } if (reader["starttime"] != null && reader["starttime"].ToString() != "") { model.starttime = DateTime.Parse(reader["starttime"].ToString()); } if (reader["endtime"] != null && reader["endtime"].ToString() != "") { model.endtime = DateTime.Parse(reader["endtime"].ToString()); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnAdvertisementCategory> GetAdvertisementCategoryList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnAdvertisementCategory> modelList = new List<EnAdvertisementCategory>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBAdvertisementCategory, PageIndex, PageSize, strWhere, "", 1, out pageCount); DataView dv = dt.DefaultView; dv.Sort = "sort,id desc"; dt = dv.ToTable(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Select(" parentid=0")) { EnAdvertisementCategory model = new EnAdvertisementCategory(); if (dr["id"] != null && dr["id"].ToString() != "") { model.id = int.Parse(dr["id"].ToString()); } if (dr["parentid"] != null && dr["parentid"].ToString() != "") { model.parentid = int.Parse(dr["parentid"].ToString()); } if (dr["moduleid"] != null && dr["moduleid"].ToString() != "") { model.moduleid = int.Parse(dr["moduleid"].ToString()); } if (dr["modulevalue"] != null && dr["modulevalue"].ToString() != "") { model.modulevalue = dr["modulevalue"].ToString(); } if (dr["title"] != null && dr["title"].ToString() != "") { model.title = dr["title"].ToString(); } if (dr["img"] != null && dr["img"].ToString() != "") { model.img = dr["img"].ToString(); } if (dr["height"] != null && dr["height"].ToString() != "") { model.height = int.Parse(dr["height"].ToString()); } if (dr["width"] != null && dr["width"].ToString() != "") { model.width = int.Parse(dr["width"].ToString()); } if (dr["isopen"] != null && dr["isopen"].ToString() != "") { model.isopen = int.Parse(dr["isopen"].ToString()); } if (dr["adtype"] != null && dr["adtype"].ToString() != "") { model.adtype = int.Parse(dr["adtype"].ToString()); } if (dr["starttime"] != null && dr["starttime"].ToString() != "") { model.starttime = DateTime.Parse(dr["starttime"].ToString()); } if (dr["endtime"] != null && dr["endtime"].ToString() != "") { model.endtime = DateTime.Parse(dr["endtime"].ToString()); } if (dr["descript"] != null && dr["descript"].ToString() != "") { model.descript = dr["descript"].ToString(); } if (dr["template"] != null && dr["template"].ToString() != "") { model.template = dr["template"].ToString(); } if (dr["sort"] != null && dr["sort"].ToString() != "") { model.sort = int.Parse(dr["sort"].ToString()); } modelList.Add(model); foreach (DataRow drSub in dt.Select(" parentid="+model.id)) { EnAdvertisementCategory modelSub = new EnAdvertisementCategory(); if (drSub["id"] != null && drSub["id"].ToString() != "") { modelSub.id = int.Parse(drSub["id"].ToString()); } if (drSub["parentid"] != null && drSub["parentid"].ToString() != "") { modelSub.parentid = int.Parse(drSub["parentid"].ToString()); } if (drSub["moduleid"] != null && drSub["moduleid"].ToString() != "") { modelSub.moduleid = int.Parse(drSub["moduleid"].ToString()); } if (drSub["modulevalue"] != null && drSub["modulevalue"].ToString() != "") { modelSub.modulevalue = drSub["modulevalue"].ToString(); } if (drSub["title"] != null && drSub["title"].ToString() != "") { modelSub.title = drSub["title"].ToString(); } if (drSub["img"] != null && drSub["img"].ToString() != "") { modelSub.img = drSub["img"].ToString(); } if (drSub["height"] != null && drSub["height"].ToString() != "") { modelSub.height = int.Parse(drSub["height"].ToString()); } if (drSub["width"] != null && drSub["width"].ToString() != "") { modelSub.width = int.Parse(drSub["width"].ToString()); } if (drSub["isopen"] != null && drSub["isopen"].ToString() != "") { modelSub.isopen = int.Parse(drSub["isopen"].ToString()); } if (drSub["adtype"] != null && drSub["adtype"].ToString() != "") { modelSub.adtype = int.Parse(drSub["adtype"].ToString()); } if (drSub["starttime"] != null && drSub["starttime"].ToString() != "") { modelSub.starttime = DateTime.Parse(drSub["starttime"].ToString()); } if (drSub["endtime"] != null && drSub["endtime"].ToString() != "") { modelSub.endtime = DateTime.Parse(drSub["endtime"].ToString()); } if (drSub["descript"] != null && drSub["descript"].ToString() != "") { modelSub.descript = drSub["descript"].ToString(); } if (drSub["template"] != null && drSub["template"].ToString() != "") { modelSub.template = drSub["template"].ToString(); } if (drSub["sort"] != null && drSub["sort"].ToString() != "") { modelSub.sort = int.Parse(drSub["sort"].ToString()); } modelList.Add(modelSub); } } } return modelList; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Advertisements.cs
C#
oos
31,164
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class MarketStoreys { /// <summary> /// 更新对像 /// </summary> public static int EditMarketStorey(EnMarketStorey model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_marketstorey("); strSql.Append("marketid,markettitle,title,number,surface,logo,thumb,bannel,desimage,descript,keywords,template,hits,sort,lastedid,lastedittime)"); strSql.Append(" values ("); strSql.Append("@marketid,@markettitle,@title,@number,@surface,@logo,@thumb,@bannel,@desimage,@descript,@keywords,@template,@hits,@sort,@lastedid,@lastedittime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@marketid", SqlDbType.Int,4), new SqlParameter("@markettitle", SqlDbType.NVarChar,50), new SqlParameter("@title", SqlDbType.NVarChar,50), new SqlParameter("@number", SqlDbType.NVarChar,20), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime)}; parameters[0].Value = model.marketid; parameters[1].Value = model.markettitle; parameters[2].Value = model.title; parameters[3].Value = model.number; parameters[4].Value = model.surface; parameters[5].Value = model.logo; parameters[6].Value = model.thumb; parameters[7].Value = model.bannel; parameters[8].Value = model.desimage; parameters[9].Value = model.descript; parameters[10].Value = model.keywords; parameters[11].Value = model.template; parameters[12].Value = model.hits; parameters[13].Value = model.sort; parameters[14].Value = model.lastedid; parameters[15].Value = model.lastedittime; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_marketstorey set "); strSql.Append("marketid=@marketid,"); strSql.Append("markettitle=@markettitle,"); strSql.Append("title=@title,"); strSql.Append("number=@number,"); strSql.Append("surface=@surface,"); strSql.Append("logo=@logo,"); strSql.Append("thumb=@thumb,"); strSql.Append("bannel=@bannel,"); strSql.Append("desimage=@desimage,"); strSql.Append("descript=@descript,"); strSql.Append("keywords=@keywords,"); strSql.Append("template=@template,"); strSql.Append("hits=@hits,"); strSql.Append("sort=@sort,"); strSql.Append("lastedid=@lastedid,"); strSql.Append("lastedittime=@lastedittime"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@marketid", SqlDbType.Int,4), new SqlParameter("@markettitle", SqlDbType.NVarChar,50), new SqlParameter("@title", SqlDbType.NVarChar,50), new SqlParameter("@number", SqlDbType.NVarChar,20), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.marketid; parameters[1].Value = model.markettitle; parameters[2].Value = model.title; parameters[3].Value = model.number; parameters[4].Value = model.surface; parameters[5].Value = model.logo; parameters[6].Value = model.thumb; parameters[7].Value = model.bannel; parameters[8].Value = model.desimage; parameters[9].Value = model.descript; parameters[10].Value = model.keywords; parameters[11].Value = model.template; parameters[12].Value = model.hits; parameters[13].Value = model.sort; parameters[14].Value = model.lastedid; parameters[15].Value = model.lastedittime; parameters[16].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnMarketStorey GetMarketStoreyInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_MarketStorey "); strSql.Append(strWhere); EnMarketStorey model = new EnMarketStorey(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["marketid"] != null && reader["marketid"].ToString() != "") { model.marketid = int.Parse(reader["marketid"].ToString()); } if (reader["markettitle"] != null && reader["markettitle"].ToString() != "") { model.markettitle = reader["markettitle"].ToString(); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["number"] != null && reader["number"].ToString() != "") { model.number = reader["number"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnMarketStorey> GetMarketStoreyList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnMarketStorey> modelList = new List<EnMarketStorey>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBMarketStorey, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnMarketStorey model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnMarketStorey(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["marketid"] != null && dt.Rows[n]["marketid"].ToString() != "") { model.marketid = int.Parse(dt.Rows[n]["marketid"].ToString()); } if (dt.Rows[n]["markettitle"] != null && dt.Rows[n]["markettitle"].ToString() != "") { model.markettitle = dt.Rows[n]["markettitle"].ToString(); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["number"] != null && dt.Rows[n]["number"].ToString() != "") { model.number = dt.Rows[n]["number"].ToString(); } if (dt.Rows[n]["surface"] != null && dt.Rows[n]["surface"].ToString() != "") { model.surface = dt.Rows[n]["surface"].ToString(); } if (dt.Rows[n]["logo"] != null && dt.Rows[n]["logo"].ToString() != "") { model.logo = dt.Rows[n]["logo"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["bannel"] != null && dt.Rows[n]["bannel"].ToString() != "") { model.bannel = dt.Rows[n]["bannel"].ToString(); } if (dt.Rows[n]["desimage"] != null && dt.Rows[n]["desimage"].ToString() != "") { model.desimage = dt.Rows[n]["desimage"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["keywords"] != null && dt.Rows[n]["keywords"].ToString() != "") { model.keywords = dt.Rows[n]["keywords"].ToString(); } if (dt.Rows[n]["template"] != null && dt.Rows[n]["template"].ToString() != "") { model.template = dt.Rows[n]["template"].ToString(); } if (dt.Rows[n]["hits"] != null && dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["lastedid"] != null && dt.Rows[n]["lastedid"].ToString() != "") { model.lastedid = int.Parse(dt.Rows[n]["lastedid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } modelList.Add(model); } } return modelList; } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/MarketStoreys.cs
C#
oos
15,123
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class Brands { public static int ExitBrandTitleLetter(string title) { SqlParameter[] parames = { new SqlParameter("@letter", SqlDbType.VarChar, 30)}; parames[0].Value = title; return DataCommon.Exists(TableName.TBBrand, " where letter=@letter", parames); } public static int ExitBrandTitle(string title) { SqlParameter[] parames = { new SqlParameter("@title", SqlDbType.NVarChar, 30)}; parames[0].Value = title; return DataCommon.Exists(TableName.TBBrand, " where title=@title", parames); } public static int ExitBrandsTitle(string title) { SqlParameter[] parames = { new SqlParameter("@title", SqlDbType.NVarChar, 30)}; parames[0].Value = title; return DataCommon.Exists(TableName.TBBrands, " where title=@title", parames); } #region 福家网+家具快搜品牌 /// <summary> /// 获得数据列表 /// </summary> public static List<EnAllBrand> GetAllBrandList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnAllBrand> modelList = new List<EnAllBrand>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TVAllBrand, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnAllBrand model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnAllBrand(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = long.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["brandid"] != null && dt.Rows[n]["brandid"].ToString() != "") { model.brandid = int.Parse(dt.Rows[n]["brandid"].ToString()); } if (dt.Rows[n]["brandcode"] != null && dt.Rows[n]["brandcode"].ToString() != "") { model.brandcode = dt.Rows[n]["brandcode"].ToString(); } if (dt.Rows[n]["companycode"] != null && dt.Rows[n]["companycode"].ToString() != "") { model.companycode = dt.Rows[n]["companycode"].ToString(); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString() + "/" + dt.Rows[n]["quanpin"].ToString() + "_" + dt.Rows[n]["fordio"].ToString(); } if (dt.Rows[n]["quanpin"] != null && dt.Rows[n]["quanpin"].ToString() != "") { model.quanpin = dt.Rows[n]["quanpin"].ToString(); } if (dt.Rows[n]["ename"] != null && dt.Rows[n]["ename"].ToString() != "") { model.ename = dt.Rows[n]["ename"].ToString(); } if (dt.Rows[n]["logo"] != null && dt.Rows[n]["logo"].ToString() != "") { model.logo = dt.Rows[n]["logo"].ToString(); } if (dt.Rows[n]["compayid"] != null && dt.Rows[n]["compayid"].ToString() != "") { model.compayid = int.Parse(dt.Rows[n]["compayid"].ToString()); } if (dt.Rows[n]["fordio"] != null && dt.Rows[n]["fordio"].ToString() != "") { model.fordio = dt.Rows[n]["fordio"].ToString(); } modelList.Add(model); } } return modelList; } #endregion #region 共公模块 /// <summary> /// 更新对像 /// </summary> public static int EditBrand(EnBrand model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_brand("); strSql.Append("companyid,title,letter,groupid,attribute,productcategory,homepage,productcount,spread,material,style,color,surface,logo,thumb,bannel,desimage,descript,keywords,template,hits,sort,createmid,lasteditid,lastedittime,auditstatus,linestatus)"); strSql.Append(" values ("); strSql.Append("@companyid,@title,@letter,@groupid,@attribute,@productcategory,@homepage,@productcount,@spread,@material,@style,@color,@surface,@logo,@thumb,@bannel,@desimage,@descript,@keywords,@template,@hits,@sort,@createmid,@lasteditid,@lastedittime,@auditstatus,@linestatus)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@companyid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@groupid", SqlDbType.Int,4), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@productcategory", SqlDbType.VarChar,50), new SqlParameter("@homepage", SqlDbType.VarChar,50), new SqlParameter("@productcount", SqlDbType.Int,4), new SqlParameter("@spread", SqlDbType.NVarChar,30), new SqlParameter("@material", SqlDbType.NVarChar,50), new SqlParameter("@style", SqlDbType.NVarChar,50), new SqlParameter("@color", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lasteditid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4)}; parameters[0].Value = model.companyid; parameters[1].Value = model.title; parameters[2].Value = model.letter; parameters[3].Value = model.groupid; parameters[4].Value = model.attribute; parameters[5].Value = model.productcategory; parameters[6].Value = model.homepage; parameters[7].Value = model.productcount; parameters[8].Value = model.spread; parameters[9].Value = model.material; parameters[10].Value = model.style; parameters[11].Value = model.color; parameters[12].Value = model.surface; parameters[13].Value = model.logo; parameters[14].Value = model.thumb; parameters[15].Value = model.bannel; parameters[16].Value = model.desimage; parameters[17].Value = model.descript; parameters[18].Value = model.keywords; parameters[19].Value = model.template; parameters[20].Value = model.hits; parameters[21].Value = model.sort; parameters[22].Value = model.createmid; parameters[23].Value = model.lasteditid; parameters[24].Value = model.lastedittime; parameters[25].Value = model.auditstatus; parameters[26].Value = model.linestatus; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_brand set "); strSql.Append("companyid=@companyid,"); strSql.Append("title=@title,"); strSql.Append("letter=@letter,"); strSql.Append("groupid=@groupid,"); strSql.Append("attribute=@attribute,"); strSql.Append("productcategory=@productcategory,"); strSql.Append("homepage=@homepage,"); strSql.Append("productcount=@productcount,"); strSql.Append("spread=@spread,"); strSql.Append("material=@material,"); strSql.Append("style=@style,"); strSql.Append("color=@color,"); strSql.Append("surface=@surface,"); strSql.Append("logo=@logo,"); strSql.Append("thumb=@thumb,"); strSql.Append("bannel=@bannel,"); strSql.Append("desimage=@desimage,"); strSql.Append("descript=@descript,"); strSql.Append("keywords=@keywords,"); strSql.Append("template=@template,"); strSql.Append("hits=@hits,"); strSql.Append("sort=@sort,"); strSql.Append("createmid=@createmid,"); strSql.Append("lasteditid=@lasteditid,"); strSql.Append("lastedittime=@lastedittime,"); strSql.Append("auditstatus=@auditstatus,"); strSql.Append("linestatus=@linestatus"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@companyid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@groupid", SqlDbType.Int,4), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@productcategory", SqlDbType.VarChar,50), new SqlParameter("@homepage", SqlDbType.VarChar,50), new SqlParameter("@productcount", SqlDbType.Int,4), new SqlParameter("@spread", SqlDbType.NVarChar,30), new SqlParameter("@material", SqlDbType.NVarChar,50), new SqlParameter("@style", SqlDbType.NVarChar,50), new SqlParameter("@color", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lasteditid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.companyid; parameters[1].Value = model.title; parameters[2].Value = model.letter; parameters[3].Value = model.groupid; parameters[4].Value = model.attribute; parameters[5].Value = model.productcategory; parameters[6].Value = model.homepage; parameters[7].Value = model.productcount; parameters[8].Value = model.spread; parameters[9].Value = model.material; parameters[10].Value = model.style; parameters[11].Value = model.color; parameters[12].Value = model.surface; parameters[13].Value = model.logo; parameters[14].Value = model.thumb; parameters[15].Value = model.bannel; parameters[16].Value = model.desimage; parameters[17].Value = model.descript; parameters[18].Value = model.keywords; parameters[19].Value = model.template; parameters[20].Value = model.hits; parameters[21].Value = model.sort; parameters[22].Value = model.createmid; parameters[23].Value = model.lasteditid; parameters[24].Value = model.lastedittime; parameters[25].Value = model.auditstatus; parameters[26].Value = model.linestatus; parameters[27].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnBrand GetBrandInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Brand "); strSql.Append(strWhere); EnBrand model = new EnBrand(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["companyid"] != null && reader["companyid"].ToString() != "") { model.companyid = int.Parse(reader["companyid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["groupid"] != null && reader["groupid"].ToString() != "") { model.groupid = int.Parse(reader["groupid"].ToString()); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["productcategory"] != null && reader["productcategory"].ToString() != "") { model.productcategory = reader["productcategory"].ToString(); } if (reader["homepage"] != null && reader["homepage"].ToString() != "") { model.homepage = reader["homepage"].ToString(); } if (reader["productcount"] != null && reader["productcount"].ToString() != "") { model.productcount = int.Parse(reader["productcount"].ToString()); } if (reader["spread"] != null && reader["spread"].ToString() != "") { model.spread = reader["spread"].ToString(); } if (reader["material"] != null && reader["material"].ToString() != "") { model.material = reader["material"].ToString(); } if (reader["style"] != null && reader["style"].ToString() != "") { model.style = reader["style"].ToString(); } if (reader["color"] != null && reader["color"].ToString() != "") { model.color = reader["color"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lasteditid"] != null && reader["lasteditid"].ToString() != "") { model.lasteditid = int.Parse(reader["lasteditid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnBrand> GetBrandList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnBrand> modelList = new List<EnBrand>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBBrand, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnBrand model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnBrand(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["companyid"] != null && dt.Rows[n]["companyid"].ToString() != "") { model.companyid = int.Parse(dt.Rows[n]["companyid"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["groupid"] != null && dt.Rows[n]["groupid"].ToString() != "") { model.groupid = int.Parse(dt.Rows[n]["groupid"].ToString()); } if (dt.Rows[n]["attribute"] != null && dt.Rows[n]["attribute"].ToString() != "") { model.attribute = dt.Rows[n]["attribute"].ToString(); } if (dt.Rows[n]["productcategory"] != null && dt.Rows[n]["productcategory"].ToString() != "") { model.productcategory = dt.Rows[n]["productcategory"].ToString(); } if (dt.Rows[n]["homepage"] != null && dt.Rows[n]["homepage"].ToString() != "") { model.homepage = dt.Rows[n]["homepage"].ToString(); } if (dt.Rows[n]["productcount"] != null && dt.Rows[n]["productcount"].ToString() != "") { model.productcount = int.Parse(dt.Rows[n]["productcount"].ToString()); } if (dt.Rows[n]["spread"] != null && dt.Rows[n]["spread"].ToString() != "") { model.spread = dt.Rows[n]["spread"].ToString(); } if (dt.Rows[n]["material"] != null && dt.Rows[n]["material"].ToString() != "") { model.material = dt.Rows[n]["material"].ToString(); } if (dt.Rows[n]["style"] != null && dt.Rows[n]["style"].ToString() != "") { model.style = dt.Rows[n]["style"].ToString(); } if (dt.Rows[n]["color"] != null && dt.Rows[n]["color"].ToString() != "") { model.color = dt.Rows[n]["color"].ToString(); } if (dt.Rows[n]["surface"] != null && dt.Rows[n]["surface"].ToString() != "") { model.surface = dt.Rows[n]["surface"].ToString(); } if (dt.Rows[n]["logo"] != null && dt.Rows[n]["logo"].ToString() != "") { model.logo = dt.Rows[n]["logo"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["bannel"] != null && dt.Rows[n]["bannel"].ToString() != "") { model.bannel = dt.Rows[n]["bannel"].ToString(); } if (dt.Rows[n]["desimage"] != null && dt.Rows[n]["desimage"].ToString() != "") { model.desimage = dt.Rows[n]["desimage"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["keywords"] != null && dt.Rows[n]["keywords"].ToString() != "") { model.keywords = dt.Rows[n]["keywords"].ToString(); } if (dt.Rows[n]["template"] != null && dt.Rows[n]["template"].ToString() != "") { model.template = dt.Rows[n]["template"].ToString(); } if (dt.Rows[n]["hits"] != null && dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["createmid"] != null && dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } if (dt.Rows[n]["lasteditid"] != null && dt.Rows[n]["lasteditid"].ToString() != "") { model.lasteditid = int.Parse(dt.Rows[n]["lasteditid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["auditstatus"] != null && dt.Rows[n]["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(dt.Rows[n]["auditstatus"].ToString()); } if (dt.Rows[n]["linestatus"] != null && dt.Rows[n]["linestatus"].ToString() != "") { model.linestatus = int.Parse(dt.Rows[n]["linestatus"].ToString()); } modelList.Add(model); } } return modelList; } /// <summary> /// 获得数据列表 /// </summary> public static List<EnWebBrand> GetWebBrandList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnWebBrand> modelList = new List<EnWebBrand>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TVBrand, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnWebBrand model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnWebBrand(); model.companyname = dt.Rows[n]["companyname"].ToString(); model.attribute = dt.Rows[n]["attribute"].ToString(); model.productcategory = dt.Rows[n]["productcategory"].ToString(); model.homepage = dt.Rows[n]["homepage"].ToString(); if (dt.Rows[n]["productcount"].ToString() != "") { model.productcount = int.Parse(dt.Rows[n]["productcount"].ToString()); } model.spread = dt.Rows[n]["spread"].ToString(); model.material = dt.Rows[n]["material"].ToString(); model.style = dt.Rows[n]["style"].ToString(); model.surface = dt.Rows[n]["surface"].ToString(); model.logo = dt.Rows[n]["logo"].ToString(); model.thumb = dt.Rows[n]["thumb"].ToString(); model.spreadname = dt.Rows[n]["spreadname"].ToString(); model.bannel = dt.Rows[n]["bannel"].ToString(); model.desimage = dt.Rows[n]["desimage"].ToString(); model.descript = dt.Rows[n]["descript"].ToString(); model.keywords = dt.Rows[n]["keywords"].ToString(); model.template = dt.Rows[n]["template"].ToString(); if (dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } if (dt.Rows[n]["lasteditid"].ToString() != "") { model.lasteditid = int.Parse(dt.Rows[n]["lasteditid"].ToString()); } if (dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } model.stylename = dt.Rows[n]["stylename"].ToString(); if (dt.Rows[n]["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(dt.Rows[n]["auditstatus"].ToString()); } if (dt.Rows[n]["linestatus"].ToString() != "") { model.linestatus = int.Parse(dt.Rows[n]["linestatus"].ToString()); } model.materialname = dt.Rows[n]["materialname"].ToString(); if (dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["companyid"].ToString() != "") { model.companyid = int.Parse(dt.Rows[n]["companyid"].ToString()); } model.title = dt.Rows[n]["title"].ToString(); model.letter = dt.Rows[n]["letter"].ToString(); if (dt.Rows[n]["groupid"].ToString() != "") { model.groupid = int.Parse(dt.Rows[n]["groupid"].ToString()); } modelList.Add(model); } } return modelList; } #endregion #region brands /// <summary> /// 更新对像 /// </summary> public static int EditBrands(EnBrands model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_brands("); strSql.Append("brandid,title,letter,attribute,productcount,spread,material,style,surface,logo,thumb,bannel,desimage,descript,keywords,template,hits,sort,createmid,lasteditid,lastedittime,auditstatus,linestatus)"); strSql.Append(" values ("); strSql.Append("@brandid,@title,@letter,@attribute,@productcount,@spread,@material,@style,@surface,@logo,@thumb,@bannel,@desimage,@descript,@keywords,@template,@hits,@sort,@createmid,@lasteditid,@lastedittime,@auditstatus,@linestatus)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@brandid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@productcount", SqlDbType.Int,4), new SqlParameter("@spread", SqlDbType.NVarChar,30), new SqlParameter("@material", SqlDbType.NVarChar,50), new SqlParameter("@style", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lasteditid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4)}; parameters[0].Value = model.brandid; parameters[1].Value = model.title; parameters[2].Value = model.letter; parameters[3].Value = model.attribute; parameters[4].Value = model.productcount; parameters[5].Value = model.spread; parameters[6].Value = model.material; parameters[7].Value = model.style; parameters[8].Value = model.surface; parameters[9].Value = model.logo; parameters[10].Value = model.thumb; parameters[11].Value = model.bannel; parameters[12].Value = model.desimage; parameters[13].Value = model.descript; parameters[14].Value = model.keywords; parameters[15].Value = model.template; parameters[16].Value = model.hits; parameters[17].Value = model.sort; parameters[18].Value = model.createmid; parameters[19].Value = model.lasteditid; parameters[20].Value = model.lastedittime; parameters[21].Value = model.auditstatus; parameters[22].Value = model.linestatus; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_brands set "); strSql.Append("brandid=@brandid,"); strSql.Append("title=@title,"); strSql.Append("letter=@letter,"); strSql.Append("attribute=@attribute,"); strSql.Append("productcount=@productcount,"); strSql.Append("spread=@spread,"); strSql.Append("material=@material,"); strSql.Append("style=@style,"); strSql.Append("surface=@surface,"); strSql.Append("logo=@logo,"); strSql.Append("thumb=@thumb,"); strSql.Append("bannel=@bannel,"); strSql.Append("desimage=@desimage,"); strSql.Append("descript=@descript,"); strSql.Append("keywords=@keywords,"); strSql.Append("template=@template,"); strSql.Append("hits=@hits,"); strSql.Append("sort=@sort,"); strSql.Append("createmid=@createmid,"); strSql.Append("lasteditid=@lasteditid,"); strSql.Append("lastedittime=@lastedittime,"); strSql.Append("auditstatus=@auditstatus,"); strSql.Append("linestatus=@linestatus"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@brandid", SqlDbType.Int,4), new SqlParameter("@title", SqlDbType.NVarChar,80), new SqlParameter("@letter", SqlDbType.VarChar,20), new SqlParameter("@attribute", SqlDbType.VarChar,100), new SqlParameter("@productcount", SqlDbType.Int,4), new SqlParameter("@spread", SqlDbType.NVarChar,30), new SqlParameter("@material", SqlDbType.NVarChar,50), new SqlParameter("@style", SqlDbType.NVarChar,50), new SqlParameter("@surface", SqlDbType.VarChar,200), new SqlParameter("@logo", SqlDbType.VarChar,40), new SqlParameter("@thumb", SqlDbType.VarChar,40), new SqlParameter("@bannel", SqlDbType.VarChar,300), new SqlParameter("@desimage", SqlDbType.VarChar,400), new SqlParameter("@descript", SqlDbType.NText), new SqlParameter("@keywords", SqlDbType.NVarChar,200), new SqlParameter("@template", SqlDbType.VarChar,50), new SqlParameter("@hits", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lasteditid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@linestatus", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.brandid; parameters[1].Value = model.title; parameters[2].Value = model.letter; parameters[3].Value = model.attribute; parameters[4].Value = model.productcount; parameters[5].Value = model.spread; parameters[6].Value = model.material; parameters[7].Value = model.style; parameters[8].Value = model.surface; parameters[9].Value = model.logo; parameters[10].Value = model.thumb; parameters[11].Value = model.bannel; parameters[12].Value = model.desimage; parameters[13].Value = model.descript; parameters[14].Value = model.keywords; parameters[15].Value = model.template; parameters[16].Value = model.hits; parameters[17].Value = model.sort; parameters[18].Value = model.createmid; parameters[19].Value = model.lasteditid; parameters[20].Value = model.lastedittime; parameters[21].Value = model.auditstatus; parameters[22].Value = model.linestatus; parameters[23].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnBrands GetBrandsInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_Brands "); strSql.Append(strWhere); EnBrands model = new EnBrands(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["brandid"] != null && reader["brandid"].ToString() != "") { model.brandid = int.Parse(reader["brandid"].ToString()); } if (reader["title"] != null && reader["title"].ToString() != "") { model.title = reader["title"].ToString(); } if (reader["letter"] != null && reader["letter"].ToString() != "") { model.letter = reader["letter"].ToString(); } if (reader["attribute"] != null && reader["attribute"].ToString() != "") { model.attribute = reader["attribute"].ToString(); } if (reader["productcount"] != null && reader["productcount"].ToString() != "") { model.productcount = int.Parse(reader["productcount"].ToString()); } if (reader["spread"] != null && reader["spread"].ToString() != "") { model.spread = reader["spread"].ToString(); } if (reader["material"] != null && reader["material"].ToString() != "") { model.material = reader["material"].ToString(); } if (reader["style"] != null && reader["style"].ToString() != "") { model.style = reader["style"].ToString(); } if (reader["surface"] != null && reader["surface"].ToString() != "") { model.surface = reader["surface"].ToString(); } if (reader["logo"] != null && reader["logo"].ToString() != "") { model.logo = reader["logo"].ToString(); } if (reader["thumb"] != null && reader["thumb"].ToString() != "") { model.thumb = reader["thumb"].ToString(); } if (reader["bannel"] != null && reader["bannel"].ToString() != "") { model.bannel = reader["bannel"].ToString(); } if (reader["desimage"] != null && reader["desimage"].ToString() != "") { model.desimage = reader["desimage"].ToString(); } if (reader["descript"] != null && reader["descript"].ToString() != "") { model.descript = reader["descript"].ToString(); } if (reader["keywords"] != null && reader["keywords"].ToString() != "") { model.keywords = reader["keywords"].ToString(); } if (reader["template"] != null && reader["template"].ToString() != "") { model.template = reader["template"].ToString(); } if (reader["hits"] != null && reader["hits"].ToString() != "") { model.hits = int.Parse(reader["hits"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lasteditid"] != null && reader["lasteditid"].ToString() != "") { model.lasteditid = int.Parse(reader["lasteditid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } if (reader["linestatus"] != null && reader["linestatus"].ToString() != "") { model.linestatus = int.Parse(reader["linestatus"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnBrands> GetBrandsList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnBrands> modelList = new List<EnBrands>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBBrands, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnBrands model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnBrands(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["brandid"] != null && dt.Rows[n]["brandid"].ToString() != "") { model.brandid = int.Parse(dt.Rows[n]["brandid"].ToString()); } if (dt.Rows[n]["title"] != null && dt.Rows[n]["title"].ToString() != "") { model.title = dt.Rows[n]["title"].ToString(); } if (dt.Rows[n]["letter"] != null && dt.Rows[n]["letter"].ToString() != "") { model.letter = dt.Rows[n]["letter"].ToString(); } if (dt.Rows[n]["attribute"] != null && dt.Rows[n]["attribute"].ToString() != "") { model.attribute = dt.Rows[n]["attribute"].ToString(); } if (dt.Rows[n]["productcount"] != null && dt.Rows[n]["productcount"].ToString() != "") { model.productcount = int.Parse(dt.Rows[n]["productcount"].ToString()); } if (dt.Rows[n]["spread"] != null && dt.Rows[n]["spread"].ToString() != "") { model.spread = dt.Rows[n]["spread"].ToString(); } if (dt.Rows[n]["material"] != null && dt.Rows[n]["material"].ToString() != "") { model.material = dt.Rows[n]["material"].ToString(); } if (dt.Rows[n]["style"] != null && dt.Rows[n]["style"].ToString() != "") { model.style = dt.Rows[n]["style"].ToString(); } if (dt.Rows[n]["surface"] != null && dt.Rows[n]["surface"].ToString() != "") { model.surface = dt.Rows[n]["surface"].ToString(); } if (dt.Rows[n]["logo"] != null && dt.Rows[n]["logo"].ToString() != "") { model.logo = dt.Rows[n]["logo"].ToString(); } if (dt.Rows[n]["thumb"] != null && dt.Rows[n]["thumb"].ToString() != "") { model.thumb = dt.Rows[n]["thumb"].ToString(); } if (dt.Rows[n]["bannel"] != null && dt.Rows[n]["bannel"].ToString() != "") { model.bannel = dt.Rows[n]["bannel"].ToString(); } if (dt.Rows[n]["desimage"] != null && dt.Rows[n]["desimage"].ToString() != "") { model.desimage = dt.Rows[n]["desimage"].ToString(); } if (dt.Rows[n]["descript"] != null && dt.Rows[n]["descript"].ToString() != "") { model.descript = dt.Rows[n]["descript"].ToString(); } if (dt.Rows[n]["keywords"] != null && dt.Rows[n]["keywords"].ToString() != "") { model.keywords = dt.Rows[n]["keywords"].ToString(); } if (dt.Rows[n]["template"] != null && dt.Rows[n]["template"].ToString() != "") { model.template = dt.Rows[n]["template"].ToString(); } if (dt.Rows[n]["hits"] != null && dt.Rows[n]["hits"].ToString() != "") { model.hits = int.Parse(dt.Rows[n]["hits"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["createmid"] != null && dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } if (dt.Rows[n]["lasteditid"] != null && dt.Rows[n]["lasteditid"].ToString() != "") { model.lasteditid = int.Parse(dt.Rows[n]["lasteditid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["auditstatus"] != null && dt.Rows[n]["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(dt.Rows[n]["auditstatus"].ToString()); } if (dt.Rows[n]["linestatus"] != null && dt.Rows[n]["linestatus"].ToString() != "") { model.linestatus = int.Parse(dt.Rows[n]["linestatus"].ToString()); } modelList.Add(model); } } return modelList; } #endregion #region AppBrand public static int AddAppendBrand(List<EnAppBrand> list) { List<CommandInfo> cmdList = new List<CommandInfo>(); foreach (EnAppBrand ap in list) { if (ap.brandid != 0) { CommandInfo model = new CommandInfo(); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_appbrand("); strSql.Append("dealerid,dealetitle,brandid,brandtitle,companyid,companytitle,shopid,shoptitle,appmodule,apptype,apptime,createmid,lastedittime,auditstatus)"); strSql.Append(" values ("); strSql.Append("@dealerid,@dealetitle,@brandid,@brandtitle,@companyid,@companytitle,@shopid,@shoptitle,@appmodule,@apptype,@apptime,@createmid,@lastedittime,@auditstatus)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@dealerid", SqlDbType.Int,4), new SqlParameter("@dealetitle", SqlDbType.NVarChar,50), new SqlParameter("@brandid", SqlDbType.Int,4), new SqlParameter("@brandtitle", SqlDbType.NVarChar,50), new SqlParameter("@companyid", SqlDbType.Int,4), new SqlParameter("@companytitle", SqlDbType.NVarChar,50), new SqlParameter("@shopid", SqlDbType.Int,4), new SqlParameter("@shoptitle", SqlDbType.NVarChar,50), new SqlParameter("@appmodule", SqlDbType.Int,4), new SqlParameter("@apptype", SqlDbType.Int,4), new SqlParameter("@apptime", SqlDbType.DateTime), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4)}; parameters[0].Value = ap.dealerid; parameters[1].Value = ap.dealetitle; parameters[2].Value = ap.brandid; parameters[3].Value = ap.brandtitle; parameters[4].Value = ap.companyid; parameters[5].Value = ap.companytitle; parameters[6].Value = ap.shopid; parameters[7].Value = ap.shoptitle; parameters[8].Value = ap.appmodule; parameters[9].Value = ap.apptype; parameters[10].Value = ap.apptime; parameters[11].Value = ap.createmid; parameters[12].Value = ap.lastedittime; parameters[13].Value = ap.auditstatus; model.CommandText = strSql.ToString(); model.Parameters = parameters; model.EffentNextType = EffentNextType.ExcuteEffectRows; cmdList.Add(model); } } return DbHelper.ExecuteSqlTran(cmdList); } /// <summary> /// 更新对像 /// </summary> public static int EditAppBrand(EnAppBrand model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_appbrand("); strSql.Append("dealerid,dealetitle,brandid,brandtitle,companyid,companytitle,shopid,shoptitle,appmodule,apptype,apptime,createmid,lastedittime,auditstatus)"); strSql.Append(" values ("); strSql.Append("@dealerid,@dealetitle,@brandid,@brandtitle,@companyid,@companytitle,@shopid,@shoptitle,@appmodule,@apptype,@apptime,@createmid,@lastedittime,@auditstatus)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@dealerid", SqlDbType.Int,4), new SqlParameter("@dealetitle", SqlDbType.NVarChar,50), new SqlParameter("@brandid", SqlDbType.Int,4), new SqlParameter("@brandtitle", SqlDbType.NVarChar,50), new SqlParameter("@companyid", SqlDbType.Int,4), new SqlParameter("@companytitle", SqlDbType.NVarChar,50), new SqlParameter("@shopid", SqlDbType.Int,4), new SqlParameter("@shoptitle", SqlDbType.NVarChar,50), new SqlParameter("@appmodule", SqlDbType.Int,4), new SqlParameter("@apptype", SqlDbType.Int,4), new SqlParameter("@apptime", SqlDbType.DateTime), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4)}; parameters[0].Value = model.dealerid; parameters[1].Value = model.dealetitle; parameters[2].Value = model.brandid; parameters[3].Value = model.brandtitle; parameters[4].Value = model.companyid; parameters[5].Value = model.companytitle; parameters[6].Value = model.shopid; parameters[7].Value = model.shoptitle; parameters[8].Value = model.appmodule; parameters[9].Value = model.apptype; parameters[10].Value = model.apptime; parameters[11].Value = model.createmid; parameters[12].Value = model.lastedittime; parameters[13].Value = model.auditstatus; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_appbrand set "); strSql.Append("dealerid=@dealerid,"); strSql.Append("dealetitle=@dealetitle,"); strSql.Append("brandid=@brandid,"); strSql.Append("brandtitle=@brandtitle,"); strSql.Append("companyid=@companyid,"); strSql.Append("companytitle=@companytitle,"); strSql.Append("shopid=@shopid,"); strSql.Append("shoptitle=@shoptitle,"); strSql.Append("appmodule=@appmodule,"); strSql.Append("apptype=@apptype,"); strSql.Append("apptime=@apptime,"); strSql.Append("createmid=@createmid,"); strSql.Append("lastedittime=@lastedittime,"); strSql.Append("auditstatus=@auditstatus"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@dealerid", SqlDbType.Int,4), new SqlParameter("@dealetitle", SqlDbType.NVarChar,50), new SqlParameter("@brandid", SqlDbType.Int,4), new SqlParameter("@brandtitle", SqlDbType.NVarChar,50), new SqlParameter("@companyid", SqlDbType.Int,4), new SqlParameter("@companytitle", SqlDbType.NVarChar,50), new SqlParameter("@shopid", SqlDbType.Int,4), new SqlParameter("@shoptitle", SqlDbType.NVarChar,50), new SqlParameter("@appmodule", SqlDbType.Int,4), new SqlParameter("@apptype", SqlDbType.Int,4), new SqlParameter("@apptime", SqlDbType.DateTime), new SqlParameter("@createmid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@auditstatus", SqlDbType.Int,4), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.dealerid; parameters[1].Value = model.dealetitle; parameters[2].Value = model.brandid; parameters[3].Value = model.brandtitle; parameters[4].Value = model.companyid; parameters[5].Value = model.companytitle; parameters[6].Value = model.shopid; parameters[7].Value = model.shoptitle; parameters[8].Value = model.appmodule; parameters[9].Value = model.apptype; parameters[10].Value = model.apptime; parameters[11].Value = model.createmid; parameters[12].Value = model.lastedittime; parameters[13].Value = model.auditstatus; parameters[14].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnAppBrand GetAppBrandInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_AppBrand "); strSql.Append(strWhere); EnAppBrand model = new EnAppBrand(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["dealerid"] != null && reader["dealerid"].ToString() != "") { model.dealerid = int.Parse(reader["dealerid"].ToString()); } if (reader["dealetitle"] != null && reader["dealetitle"].ToString() != "") { model.dealetitle = reader["dealetitle"].ToString(); } if (reader["brandid"] != null && reader["brandid"].ToString() != "") { model.brandid = int.Parse(reader["brandid"].ToString()); } if (reader["brandtitle"] != null && reader["brandtitle"].ToString() != "") { model.brandtitle = reader["brandtitle"].ToString(); } if (reader["companyid"] != null && reader["companyid"].ToString() != "") { model.companyid = int.Parse(reader["companyid"].ToString()); } if (reader["companytitle"] != null && reader["companytitle"].ToString() != "") { model.companytitle = reader["companytitle"].ToString(); } if (reader["shopid"] != null && reader["shopid"].ToString() != "") { model.shopid = int.Parse(reader["shopid"].ToString()); } if (reader["shoptitle"] != null && reader["shoptitle"].ToString() != "") { model.shoptitle = reader["shoptitle"].ToString(); } if (reader["appmodule"] != null && reader["appmodule"].ToString() != "") { model.appmodule = int.Parse(reader["appmodule"].ToString()); } if (reader["apptype"] != null && reader["apptype"].ToString() != "") { model.apptype = int.Parse(reader["apptype"].ToString()); } if (reader["apptim"] != null && reader["apptim"].ToString() != "") { model.apptime =DateTime.Parse(reader["apptime"].ToString()); } if (reader["createmid"] != null && reader["createmid"].ToString() != "") { model.createmid = int.Parse(reader["createmid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["auditstatus"] != null && reader["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(reader["auditstatus"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnAppBrand> GetAppBrandList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnAppBrand> modelList = new List<EnAppBrand>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBAppBrand, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnAppBrand model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnAppBrand(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["dealerid"] != null && dt.Rows[n]["dealerid"].ToString() != "") { model.dealerid = int.Parse(dt.Rows[n]["dealerid"].ToString()); } if (dt.Rows[n]["dealetitle"] != null && dt.Rows[n]["dealetitle"].ToString() != "") { model.dealetitle = dt.Rows[n]["dealetitle"].ToString(); } if (dt.Rows[n]["brandid"] != null && dt.Rows[n]["brandid"].ToString() != "") { model.brandid = int.Parse(dt.Rows[n]["brandid"].ToString()); } if (dt.Rows[n]["brandtitle"] != null && dt.Rows[n]["brandtitle"].ToString() != "") { model.brandtitle = dt.Rows[n]["brandtitle"].ToString(); } if (dt.Rows[n]["companyid"] != null && dt.Rows[n]["companyid"].ToString() != "") { model.companyid = int.Parse(dt.Rows[n]["companyid"].ToString()); } if (dt.Rows[n]["companytitle"] != null && dt.Rows[n]["companytitle"].ToString() != "") { model.companytitle = dt.Rows[n]["companytitle"].ToString(); } if (dt.Rows[n]["shopid"] != null && dt.Rows[n]["shopid"].ToString() != "") { model.shopid = int.Parse(dt.Rows[n]["shopid"].ToString()); } if (dt.Rows[n]["shoptitle"] != null && dt.Rows[n]["shoptitle"].ToString() != "") { model.shoptitle = dt.Rows[n]["shoptitle"].ToString(); } if (dt.Rows[n]["appmodule"] != null && dt.Rows[n]["appmodule"].ToString() != "") { model.appmodule = int.Parse(dt.Rows[n]["appmodule"].ToString()); } if (dt.Rows[n]["apptype"] != null && dt.Rows[n]["apptype"].ToString() != "") { model.apptype = int.Parse(dt.Rows[n]["apptype"].ToString()); } if (dt.Rows[n]["apptime"] != null && dt.Rows[n]["apptime"].ToString() != "") { model.apptime = DateTime.Parse(dt.Rows[n]["apptime"].ToString()); } if (dt.Rows[n]["createmid"] != null && dt.Rows[n]["createmid"].ToString() != "") { model.createmid = int.Parse(dt.Rows[n]["createmid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } if (dt.Rows[n]["auditstatus"] != null && dt.Rows[n]["auditstatus"].ToString() != "") { model.auditstatus = int.Parse(dt.Rows[n]["auditstatus"].ToString()); } modelList.Add(model); } } return modelList; } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/Brands.cs
C#
oos
68,559
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; using TREC.Entity; using TRECommon; namespace TREC.Data { public class MarketStoreyShops { public static EnWebMarketStoreyShop GetWebMarketStoreyShopInfo(string strWhere) { EnWebMarketStoreyShop model = new EnWebMarketStoreyShop(); IDataReader reader = DataCommon.GetDataIReader(TableName.TVMarketStoreyShop, "", strWhere, ""); while (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["marketid"] != null && reader["marketid"].ToString() != "") { model.marketid = int.Parse(reader["marketid"].ToString()); } if (reader["markettitle"] != null && reader["markettitle"].ToString() != "") { model.markettitle = reader["markettitle"].ToString(); } if (reader["storeyid"] != null && reader["storeyid"].ToString() != "") { model.storeyid = int.Parse(reader["storeyid"].ToString()); } if (reader["storeytitle"] != null && reader["storeytitle"].ToString() != "") { model.storeytitle = reader["storeytitle"].ToString(); } if (reader["shopid"] != null && reader["shopid"].ToString() != "") { model.shopid = int.Parse(reader["shopid"].ToString()); } if (reader["shoptitle"] != null && reader["shoptitle"].ToString() != "") { model.shoptitle = reader["shoptitle"].ToString(); } if (reader["brandidlist"] != null && reader["brandidlist"].ToString() != "") { model.brandidlist = reader["brandidlist"].ToString(); } if (reader["brandtitlelist"] != null && reader["brandtitlelist"].ToString() != "") { model.brandtitlelist = reader["brandtitlelist"].ToString(); } if (reader["istop"] != null && reader["istop"].ToString() != "") { model.istop = int.Parse(reader["istop"].ToString()); } if (reader["isrecommend"] != null && reader["isrecommend"].ToString() != "") { model.isrecommend = int.Parse(reader["isrecommend"].ToString()); } if (reader["lev"] != null && reader["lev"].ToString() != "") { model.lev = int.Parse(reader["lev"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["shopthumb"] != null && reader["shopthumb"].ToString() != "") { model.shopthumb = reader["shopthumb"].ToString(); } if (reader["shopmap"] != null && reader["shopmap"].ToString() != "") { model.shopmap = reader["shopmap"].ToString(); } if (reader["shoplinkman"] != null && reader["shoplinkman"].ToString() != "") { model.shoplinkman = reader["shoplinkman"].ToString(); } if (reader["shopphone"] != null && reader["shopphone"].ToString() != "") { model.shopphone = reader["shopphone"].ToString(); } if (reader["shopareacode"] != null && reader["shopareacode"].ToString() != "") { model.shopareacode = reader["shopareacode"].ToString(); } if (reader["shopaddress"] != null && reader["shopaddress"].ToString() != "") { model.shopaddress = reader["shopaddress"].ToString(); } if (reader["brandxml"] != null && reader["brandxml"].ToString() != "") { model.brandxml = reader["brandxml"].ToString(); } } return model; } //卖场列表 public static List<EnWebMarketStoreyShop> GetWebWebMarketStoreyShopList(int PageIndex, int PageSize, string strWhere,string sortkey, string ordertype, out int pageCount) { List<EnWebMarketStoreyShop> list = new List<EnWebMarketStoreyShop>(); IDataReader reader = DataCommon.GetPageDataReader(TableName.TVMarketStoreyShop, PageIndex, PageSize, strWhere, sortkey, ordertype, out pageCount); while (reader.Read()) { EnWebMarketStoreyShop model = new EnWebMarketStoreyShop(); if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["marketid"] != null && reader["marketid"].ToString() != "") { model.marketid = int.Parse(reader["marketid"].ToString()); } if (reader["markettitle"] != null && reader["markettitle"].ToString() != "") { model.markettitle = reader["markettitle"].ToString(); } if (reader["storeyid"] != null && reader["storeyid"].ToString() != "") { model.storeyid = int.Parse(reader["storeyid"].ToString()); } if (reader["storeytitle"] != null && reader["storeytitle"].ToString() != "") { model.storeytitle = reader["storeytitle"].ToString(); } if (reader["shopid"] != null && reader["shopid"].ToString() != "") { model.shopid = int.Parse(reader["shopid"].ToString()); } if (reader["shoptitle"] != null && reader["shoptitle"].ToString() != "") { model.shoptitle = reader["shoptitle"].ToString(); } if (reader["brandidlist"] != null && reader["brandidlist"].ToString() != "") { model.brandidlist = reader["brandidlist"].ToString(); } if (reader["brandtitlelist"] != null && reader["brandtitlelist"].ToString() != "") { model.brandtitlelist = reader["brandtitlelist"].ToString(); } if (reader["istop"] != null && reader["istop"].ToString() != "") { model.istop = int.Parse(reader["istop"].ToString()); } if (reader["isrecommend"] != null && reader["isrecommend"].ToString() != "") { model.isrecommend = int.Parse(reader["isrecommend"].ToString()); } if (reader["lev"] != null && reader["lev"].ToString() != "") { model.lev = int.Parse(reader["lev"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } if (reader["shopthumb"] != null && reader["shopthumb"].ToString() != "") { model.shopthumb = reader["shopthumb"].ToString(); } if (reader["shopmap"] != null && reader["shopmap"].ToString() != "") { model.shopmap = reader["shopmap"].ToString(); } if (reader["shoplinkman"] != null && reader["shoplinkman"].ToString() != "") { model.shoplinkman = reader["shoplinkman"].ToString(); } if (reader["shopphone"] != null && reader["shopphone"].ToString() != "") { model.shopphone = reader["shopphone"].ToString(); } if (reader["shopareacode"] != null && reader["shopareacode"].ToString() != "") { model.shopareacode = reader["shopareacode"].ToString(); } if (reader["shopaddress"] != null && reader["shopaddress"].ToString() != "") { model.shopaddress = reader["shopaddress"].ToString(); } if (reader["brandxml"] != null && reader["brandxml"].ToString() != "") { model.brandxml = reader["brandxml"].ToString(); } list.Add(model); } return list; } public static int UpMarketShorey(List<EnMarketStoreyShop> list) { List<CommandInfo> cmdList = new List<CommandInfo>(); //更新前删除 CommandInfo delShopBrand = new CommandInfo(); foreach (EnMarketStoreyShop sb in list) { if (sb.marketid != 0 && sb.shopid!=0) { CommandInfo model = new CommandInfo(); StringBuilder strSql = new StringBuilder(); strSql.Append("delete from t_marketstoreyshop where marketid="); strSql.Append(sb.marketid); strSql.Append(" and shopid="); strSql.Append(sb.shopid); strSql.Append("insert into t_marketstoreyshop("); strSql.Append("marketid,markettitle,storeyid,storeytitle,shopid,shoptitle,brandidlist,brandtitlelist,istop,isrecommend,lev,sort,lastedid,lastedittime)"); strSql.Append(" values ("); strSql.Append("@marketid,@markettitle,@storeyid,@storeytitle,@shopid,@shoptitle,@brandidlist,@brandtitlelist,@istop,@isrecommend,@lev,@sort,@lastedid,@lastedittime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@marketid", SqlDbType.Int,4), new SqlParameter("@markettitle", SqlDbType.NVarChar,50), new SqlParameter("@storeyid", SqlDbType.Int,4), new SqlParameter("@storeytitle", SqlDbType.NVarChar,50), new SqlParameter("@shopid", SqlDbType.Int,4), new SqlParameter("@shoptitle", SqlDbType.NVarChar,50), new SqlParameter("@brandidlist", SqlDbType.VarChar,50), new SqlParameter("@brandtitlelist", SqlDbType.NVarChar,200), new SqlParameter("@istop", SqlDbType.Int,4), new SqlParameter("@isrecommend", SqlDbType.Int,4), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime)}; parameters[0].Value = sb.marketid; parameters[1].Value = sb.markettitle; parameters[2].Value = sb.storeyid; parameters[3].Value = sb.storeytitle; parameters[4].Value = sb.shopid; parameters[5].Value = sb.shoptitle; parameters[6].Value = sb.brandidlist; parameters[7].Value = sb.brandtitlelist; parameters[8].Value = sb.istop; parameters[9].Value = sb.isrecommend; parameters[10].Value = sb.lev; parameters[11].Value = sb.sort; parameters[12].Value = sb.lastedid; parameters[13].Value = sb.lastedittime; model.CommandText = strSql.ToString(); model.Parameters = parameters; model.EffentNextType = EffentNextType.ExcuteEffectRows; cmdList.Add(model); } } return DbHelper.ExecuteSqlTran(cmdList); } /// <summary> /// 更新对像 /// </summary> public static int EditMarketStoreyShop(EnMarketStoreyShop model) { if (model.id == 0) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_marketstoreyshop("); strSql.Append("marketid,markettitle,storeyid,storeytitle,shopid,shoptitle,brandidlist,brandtitlelist,istop,isrecommend,lev,sort,lastedid,lastedittime)"); strSql.Append(" values ("); strSql.Append("@marketid,@markettitle,@storeyid,@storeytitle,@shopid,@shoptitle,@brandidlist,@brandtitlelist,@istop,@isrecommend,@lev,@sort,@lastedid,@lastedittime)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@marketid", SqlDbType.Int,4), new SqlParameter("@markettitle", SqlDbType.NVarChar,50), new SqlParameter("@storeyid", SqlDbType.Int,4), new SqlParameter("@storeytitle", SqlDbType.NVarChar,50), new SqlParameter("@shopid", SqlDbType.Int,4), new SqlParameter("@shoptitle", SqlDbType.NVarChar,50), new SqlParameter("@brandidlist", SqlDbType.VarChar,50), new SqlParameter("@brandtitlelist", SqlDbType.NVarChar,200), new SqlParameter("@istop", SqlDbType.Int,4), new SqlParameter("@isrecommend", SqlDbType.Int,4), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime)}; parameters[0].Value = model.marketid; parameters[1].Value = model.markettitle; parameters[2].Value = model.storeyid; parameters[3].Value = model.storeytitle; parameters[4].Value = model.shopid; parameters[5].Value = model.shoptitle; parameters[6].Value = model.brandidlist; parameters[7].Value = model.brandtitlelist; parameters[8].Value = model.istop; parameters[9].Value = model.isrecommend; parameters[10].Value = model.lev; parameters[11].Value = model.sort; parameters[12].Value = model.lastedid; parameters[13].Value = model.lastedittime; object obj = DbHelper.ExecuteScalar(CommandType.Text, strSql.ToString(), parameters); if (obj != null) { return TypeConverter.ObjectToInt(obj); } } else { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_marketstoreyshop set "); strSql.Append("marketid=@marketid,"); strSql.Append("markettitle=@markettitle,"); strSql.Append("storeyid=@storeyid,"); strSql.Append("storeytitle=@storeytitle,"); strSql.Append("shopid=@shopid,"); strSql.Append("shoptitle=@shoptitle,"); strSql.Append("brandidlist=@brandidlist,"); strSql.Append("brandtitlelist=@brandtitlelist,"); strSql.Append("istop=@istop,"); strSql.Append("isrecommend=@isrecommend,"); strSql.Append("lev=@lev,"); strSql.Append("sort=@sort,"); strSql.Append("lastedid=@lastedid,"); strSql.Append("lastedittime=@lastedittime"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@marketid", SqlDbType.Int,4), new SqlParameter("@markettitle", SqlDbType.NVarChar,50), new SqlParameter("@storeyid", SqlDbType.Int,4), new SqlParameter("@storeytitle", SqlDbType.NVarChar,50), new SqlParameter("@shopid", SqlDbType.Int,4), new SqlParameter("@shoptitle", SqlDbType.NVarChar,50), new SqlParameter("@brandidlist", SqlDbType.VarChar,50), new SqlParameter("@brandtitlelist", SqlDbType.NVarChar,200), new SqlParameter("@istop", SqlDbType.Int,4), new SqlParameter("@isrecommend", SqlDbType.Int,4), new SqlParameter("@lev", SqlDbType.Int,4), new SqlParameter("@sort", SqlDbType.Int,4), new SqlParameter("@lastedid", SqlDbType.Int,4), new SqlParameter("@lastedittime", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = model.marketid; parameters[1].Value = model.markettitle; parameters[2].Value = model.storeyid; parameters[3].Value = model.storeytitle; parameters[4].Value = model.shopid; parameters[5].Value = model.shoptitle; parameters[6].Value = model.brandidlist; parameters[7].Value = model.brandtitlelist; parameters[8].Value = model.istop; parameters[9].Value = model.isrecommend; parameters[10].Value = model.lev; parameters[11].Value = model.sort; parameters[12].Value = model.lastedid; parameters[13].Value = model.lastedittime; parameters[14].Value = model.id; if (DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters) > 0) { return model.id; } } return 0; } /// <summary> /// 得到一个对象实体 /// </summary> public static EnMarketStoreyShop GetMarketStoreyShopInfo(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from t_MarketStoreyShop "); strSql.Append(strWhere); EnMarketStoreyShop model = new EnMarketStoreyShop(); IDataReader reader = DbHelper.ExecuteReader(CommandType.Text, strSql.ToString()); if (reader.Read()) { if (reader["id"] != null && reader["id"].ToString() != "") { model.id = int.Parse(reader["id"].ToString()); } if (reader["marketid"] != null && reader["marketid"].ToString() != "") { model.marketid = int.Parse(reader["marketid"].ToString()); } if (reader["markettitle"] != null && reader["markettitle"].ToString() != "") { model.markettitle = reader["markettitle"].ToString(); } if (reader["storeyid"] != null && reader["storeyid"].ToString() != "") { model.storeyid = int.Parse(reader["storeyid"].ToString()); } if (reader["storeytitle"] != null && reader["storeytitle"].ToString() != "") { model.storeytitle = reader["storeytitle"].ToString(); } if (reader["shopid"] != null && reader["shopid"].ToString() != "") { model.shopid = int.Parse(reader["shopid"].ToString()); } if (reader["shoptitle"] != null && reader["shoptitle"].ToString() != "") { model.shoptitle = reader["shoptitle"].ToString(); } if (reader["brandidlist"] != null && reader["brandidlist"].ToString() != "") { model.brandidlist = reader["brandidlist"].ToString(); } if (reader["brandtitlelist"] != null && reader["brandtitlelist"].ToString() != "") { model.brandtitlelist = reader["brandtitlelist"].ToString(); } if (reader["istop"] != null && reader["istop"].ToString() != "") { model.istop = int.Parse(reader["istop"].ToString()); } if (reader["isrecommend"] != null && reader["isrecommend"].ToString() != "") { model.isrecommend = int.Parse(reader["isrecommend"].ToString()); } if (reader["lev"] != null && reader["lev"].ToString() != "") { model.lev = int.Parse(reader["lev"].ToString()); } if (reader["sort"] != null && reader["sort"].ToString() != "") { model.sort = int.Parse(reader["sort"].ToString()); } if (reader["lastedid"] != null && reader["lastedid"].ToString() != "") { model.lastedid = int.Parse(reader["lastedid"].ToString()); } if (reader["lastedittime"] != null && reader["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(reader["lastedittime"].ToString()); } reader.Close(); if (!reader.IsClosed) { reader.Close(); } return model; } else { reader.Close(); if (!reader.IsClosed) { reader.Close(); } return null; } } /// <summary> /// 获得数据列表 /// </summary> public static List<EnMarketStoreyShop> GetMarketStoreyShopList(int PageIndex, int PageSize, string strWhere, out int pageCount) { List<EnMarketStoreyShop> modelList = new List<EnMarketStoreyShop>(); DataTable dt = DataCommon.GetPageDataTable(TableName.TBMarketStoreyShop, PageIndex, PageSize, strWhere, "", 1, out pageCount); if (dt.Rows.Count > 0) { EnMarketStoreyShop model; for (int n = 0; n < dt.Rows.Count; n++) { model = new EnMarketStoreyShop(); if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } if (dt.Rows[n]["marketid"] != null && dt.Rows[n]["marketid"].ToString() != "") { model.marketid = int.Parse(dt.Rows[n]["marketid"].ToString()); } if (dt.Rows[n]["markettitle"] != null && dt.Rows[n]["markettitle"].ToString() != "") { model.markettitle = dt.Rows[n]["markettitle"].ToString(); } if (dt.Rows[n]["storeyid"] != null && dt.Rows[n]["storeyid"].ToString() != "") { model.storeyid = int.Parse(dt.Rows[n]["storeyid"].ToString()); } if (dt.Rows[n]["storeytitle"] != null && dt.Rows[n]["storeytitle"].ToString() != "") { model.storeytitle = dt.Rows[n]["storeytitle"].ToString(); } if (dt.Rows[n]["shopid"] != null && dt.Rows[n]["shopid"].ToString() != "") { model.shopid = int.Parse(dt.Rows[n]["shopid"].ToString()); } if (dt.Rows[n]["shoptitle"] != null && dt.Rows[n]["shoptitle"].ToString() != "") { model.shoptitle = dt.Rows[n]["shoptitle"].ToString(); } if (dt.Rows[n]["brandidlist"] != null && dt.Rows[n]["brandidlist"].ToString() != "") { model.brandidlist = dt.Rows[n]["brandidlist"].ToString(); } if (dt.Rows[n]["brandtitlelist"] != null && dt.Rows[n]["brandtitlelist"].ToString() != "") { model.brandtitlelist = dt.Rows[n]["brandtitlelist"].ToString(); } if (dt.Rows[n]["istop"] != null && dt.Rows[n]["istop"].ToString() != "") { model.istop = int.Parse(dt.Rows[n]["istop"].ToString()); } if (dt.Rows[n]["isrecommend"] != null && dt.Rows[n]["isrecommend"].ToString() != "") { model.isrecommend = int.Parse(dt.Rows[n]["isrecommend"].ToString()); } if (dt.Rows[n]["lev"] != null && dt.Rows[n]["lev"].ToString() != "") { model.lev = int.Parse(dt.Rows[n]["lev"].ToString()); } if (dt.Rows[n]["sort"] != null && dt.Rows[n]["sort"].ToString() != "") { model.sort = int.Parse(dt.Rows[n]["sort"].ToString()); } if (dt.Rows[n]["lastedid"] != null && dt.Rows[n]["lastedid"].ToString() != "") { model.lastedid = int.Parse(dt.Rows[n]["lastedid"].ToString()); } if (dt.Rows[n]["lastedittime"] != null && dt.Rows[n]["lastedittime"].ToString() != "") { model.lastedittime = DateTime.Parse(dt.Rows[n]["lastedittime"].ToString()); } modelList.Add(model); } } return modelList; } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Provide/MarketStoreyShops.cs
C#
oos
27,465
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // 有关程序集的常规信息通过以下 // 特性集控制。更改这些特性值可修改 // 与程序集关联的信息。 [assembly: AssemblyTitle("TREC.Data")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("FORDIO")] [assembly: AssemblyProduct("TREC.Data")] [assembly: AssemblyCopyright("Copyright © FORDIO 2012")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // 将 ComVisible 设置为 false 使此程序集中的类型 // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型, // 则将该类型上的 ComVisible 特性设置为 true。 [assembly: ComVisible(false)] // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID [assembly: Guid("64b51bd7-440f-48d4-8f40-3fcb88decd03")] // 程序集的版本信息由下面四个值组成: // // 主版本 // 次版本 // 内部版本号 // 修订号 // // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, // 方法是按如下所示使用“*”: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
10aaa-10aaa
trunk/TRECommerce/TREC.Data/Properties/AssemblyInfo.cs
C#
oos
1,362
using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Text; using SQLDMO; namespace TREC.Data { public class SqlDataCommon { /// <summary> /// 备份数据库 /// </summary> /// <param name="backupPath">备份文件路径</param> /// <param name="serverName">服务器名称</param> /// <param name="userName">数据库用户名</param> /// <param name="password">数据库密码</param> /// <param name="dbName">数据库名称</param> /// <param name="fileName">备份文件名</param> /// <returns></returns> public string BackUpDatabase(string backUpPath, string serverName, string userName, string password, string strDbName, string strFileName) { SQLServer svr = new SQLServerClass(); try { svr.Connect(serverName, userName, password); Backup bak = new BackupClass(); bak.Action = 0; bak.Initialize = true; bak.Files = backUpPath + strFileName; bak.Database = strDbName; bak.SQLBackup(svr); return string.Empty; } catch (Exception ex) { return ex.Message.Replace("'", " ").Replace("\n", " ").Replace("\\", "/"); } finally { svr.DisConnect(); } } /// <summary> /// 恢复数据库 /// </summary> /// <param name="backupPath">备份文件路径</param> /// <param name="serverName">服务器名称</param> /// <param name="userName">数据库用户名</param> /// <param name="password">数据库密码</param> /// <param name="dbName">数据库名称</param> /// <param name="fileName">备份文件名</param> /// <returns></returns> public string RestoreDatabase(string backUpPath, string serverName, string userName, string password, string strDbName, string strFileName) { #region 数据库的恢复的代码 SQLServer svr = new SQLServerClass(); try { svr.Connect(serverName, userName, password); QueryResults qr = svr.EnumProcesses(-1); int iColPIDNum = -1; int iColDbName = -1; for (int i = 1; i <= qr.Columns; i++) { string strName = qr.get_ColumnName(i); if (strName.ToUpper().Trim() == "SPID") iColPIDNum = i; else if (strName.ToUpper().Trim() == "DBNAME") iColDbName = i; if (iColPIDNum != -1 && iColDbName != -1) break; } for (int i = 1; i <= qr.Rows; i++) { string strDBName = qr.GetColumnString(i, iColDbName); if (strDBName.ToUpper() == strDbName.ToUpper()) svr.KillProcess(qr.GetColumnLong(i, iColPIDNum)); } Restore res = new RestoreClass(); res.Action = 0; res.Files = backUpPath + strFileName; res.Database = strDbName; res.ReplaceDatabase = true; res.SQLRestore(svr); return ""; } catch (Exception err) { return err.Message.Replace("'", " ").Replace("\n", " ").Replace("\\", "/"); } finally { svr.DisConnect(); } #endregion } /// <summary> /// 执行SQL /// </summary> /// <param name="sql"></param> /// <returns></returns> public string RunSql(string sql) { string errorInfo = ""; if (sql != "") { SqlConnection conn = new SqlConnection(DbHelper.ConnectionString); conn.Open(); string[] sqlArray = Tools.SplitString(sql, "--/* TR.Soft SQL Separator */--"); foreach (string sqlStr in sqlArray) { if (string.IsNullOrEmpty(sqlStr)) //当读到空的Sql语句则继续 { continue; } using (SqlTransaction trans = conn.BeginTransaction()) { try { DbHelper.ExecuteNonQuery(CommandType.Text, sqlStr); trans.Commit(); } catch (Exception ex) { trans.Rollback(); string message = ex.Message.Replace("'", " "); message = message.Replace("\\", "/"); message = message.Replace("\r\n", "\\r\\n"); message = message.Replace("\r", "\\r"); message = message.Replace("\n", "\\n"); errorInfo += message + "<br />"; } } } conn.Close(); } return errorInfo; } /// <summary> /// 执行SQLToDataSet /// </summary> /// <param name="sql"></param> /// <returns></returns> public DataSet RunSqlToDataSet(string sql,out string errorInfo) { DataSet ds = new DataSet(); string message = ""; if (sql != "") { SqlConnection conn = new SqlConnection(DbHelper.ConnectionString); conn.Open(); string[] sqlArray = Tools.SplitString(sql, "--/* TR.Soft SQL Separator */--"); foreach (string sqlStr in sqlArray) { if (string.IsNullOrEmpty(sqlStr)) //当读到空的Sql语句则继续 { continue; } using (SqlTransaction trans = conn.BeginTransaction()) { try { ds = DbHelper.ExecuteDataset(CommandType.Text, sqlStr); trans.Commit(); errorInfo = ""; } catch (Exception ex) { trans.Rollback(); message = ex.Message.Replace("'", " "); message = message.Replace("\\", "/"); message = message.Replace("\r\n", "\\r\\n"); message = message.Replace("\r", "\\r"); message = message.Replace("\n", "\\n"); message += message + "<br />"; } } } conn.Close(); } errorInfo = message; return ds; } /// <summary> /// 查找所有数据库 /// </summary> /// <returns></returns> public DataSet GetAllDatabase(string connection,out string errorMsg) { string sql = "Select Name FROM Master.dbo.SysDatabases orDER BY Name"; string errorInfo = ""; DataSet ds = new DataSet(); SqlConnection conn = new SqlConnection(connection); try { conn.Open(); } catch (Exception ex) { string message = ex.Message.Replace("'", " "); message = message.Replace("\\", "/"); message = message.Replace("\r\n", "\\r\\n"); message = message.Replace("\r", "\\r"); message = message.Replace("\n", "\\n"); errorInfo += message + "<br />"; } if (string.IsNullOrEmpty(errorInfo)) { string[] sqlArray = Tools.SplitString(sql, "--/* TR.Soft SQL Separator */--"); foreach (string sqlStr in sqlArray) { if (string.IsNullOrEmpty(sqlStr)) //当读到空的Sql语句则继续 { continue; } using (SqlTransaction trans = conn.BeginTransaction()) { try { ds = DbHelper.ExecuteDataset(CommandType.Text, sqlStr); trans.Commit(); } catch (Exception ex) { trans.Rollback(); string message = ex.Message.Replace("'", " "); message = message.Replace("\\", "/"); message = message.Replace("\r\n", "\\r\\n"); message = message.Replace("\r", "\\r"); message = message.Replace("\n", "\\n"); errorInfo += message + "<br />"; } } } conn.Close(); } errorMsg = errorInfo; return ds; } /// <summary> /// 查找所有数据库 /// </summary> /// <returns></returns> public DataSet GetAllTable(string connection, string database, out string errorMsg) { string sql = "use " + database + " SELECT name FROM sysobjects WHERE type = 'U'"; string errorInfo = ""; DataSet ds = new DataSet(); SqlConnection conn = new SqlConnection(connection + "database=" + database + ";"); try { conn.Open(); } catch (Exception ex) { conn.Close(); string message = ex.Message.Replace("'", " "); message = message.Replace("\\", "/"); message = message.Replace("\r\n", "\\r\\n"); message = message.Replace("\r", "\\r"); message = message.Replace("\n", "\\n"); errorInfo += message + "<br />"; } if (string.IsNullOrEmpty(errorInfo)) { string[] sqlArray = Tools.SplitString(sql, "--/* TR.Soft SQL Separator */--"); foreach (string sqlStr in sqlArray) { if (string.IsNullOrEmpty(sqlStr)) //当读到空的Sql语句则继续 { continue; } using (SqlTransaction trans = conn.BeginTransaction()) { try { ds = DbHelper.ExecuteDataset(CommandType.Text, sqlStr); trans.Commit(); } catch (Exception ex) { trans.Rollback(); string message = ex.Message.Replace("'", " "); message = message.Replace("\\", "/"); message = message.Replace("\r\n", "\\r\\n"); message = message.Replace("\r", "\\r"); message = message.Replace("\n", "\\n"); errorInfo += message + "<br />"; } } } conn.Close(); } errorMsg = errorInfo; return ds; } /// <summary> /// 获取所有列 /// </summary> /// <param name="tableName"></param> /// <param name="errorMsg"></param> /// <returns></returns> public DataSet GetAllFields(string connection,string dbname, string tableName, out string errorMsg) { StringBuilder sb=new StringBuilder(); DataSet ds = new DataSet(); string errorInfo = ""; sb.Append("use " + dbname + " "); sb.Append(@" SELECT tableName=case when a.colorder=1 then d.name else '' end, tableDescript=case when a.colorder=1 then isnull(f.value,'') else '' end, fieldId=a.colorder, fieldName=a.name, fieldMark=case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end, fieldPK=case when exists(SELECT 1 FROM sysobjects where xtype='PK' and name in ( SELECT name FROM sysindexes WHERE indid in( SELECT indid FROM sysindexkeys WHERE id = a.id AND colid=a.colid ))) then '√' else '' end, fieldType=b.name, fieldByte=a.length, fieldLength=COLUMNPROPERTY(a.id,a.name,'PRECISION'), fieldScale=isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0), fieldNull=case when a.isnullable=1 then '√'else '' end, fieldDefaultValue=isnull(e.text,''), fieldDescript=isnull(g.[value],'') FROM syscolumns a left join systypes b on a.xusertype=b.xusertype inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties' left join syscomments e on a.cdefault=e.id left join sys.extended_properties g on a.id=g.major_id and a.colid=g.minor_id left join sys.extended_properties f on d.id=f.major_id and f.minor_id=0"); if(!string.IsNullOrEmpty(tableName)) sb.Append("where d.name='"+tableName+"' --如果只查询指定表,加上此条件"); sb.Append(" order by a.id,a.colorder"); SqlConnection conn = new SqlConnection(connection); SqlTransaction trans = null; try { conn.Open(); using (trans = conn.BeginTransaction()) { ds = DbHelper.ExecuteDataset(CommandType.Text, sb.ToString()); trans.Commit(); conn.Close(); } } catch (Exception ex) { if (trans != null) { trans.Rollback(); } conn.Close(); string message = ex.Message.Replace("'", " "); message = message.Replace("\\", "/"); message = message.Replace("\r\n", "\\r\\n"); message = message.Replace("\r", "\\r"); message = message.Replace("\n", "\\n"); errorInfo += message + "<br />"; } conn.Close(); errorMsg = errorInfo; return ds; } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/SqlDataCommon.cs
C#
oos
16,091
using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Text; using System.Data; using System.Data.Common; using System.Data.SqlClient; namespace TREC.Data { public class DbHelper { #region 私有变量 /// <summary> /// 数据库连接字符串 /// </summary> public static string m_connectionstring= null; /// <summary> /// DbProviderFactory实例 /// </summary> private static DbProviderFactory m_factory = null; /// <summary> /// 锁 /// </summary> private static object lockHelper = new object(); #endregion #region 属性 /// <summary> /// 数据库连接字符串 (默认字符串在此修改) /// </summary> public static string ConnectionString { get { if (m_connectionstring == null) { m_connectionstring = System.Configuration.ConfigurationManager.ConnectionStrings["connectionstr"].ToString(); } return m_connectionstring; } set { m_connectionstring = value; } } /// <summary> /// DbProviderFactory实例 /// </summary> public static DbProviderFactory Factory { get { if (m_factory == null) { lock (lockHelper) { try { if (m_factory == null) { //return SqlClientFactory.Instance; //IDbProvider Provider = null; //Provider = (IDbProvider)Activator.CreateInstance(Type.GetType("System.Data.SqlClient", false, true)); return DbProviderFactories.GetFactory("System.Data.SqlClient"); } } catch { throw new Exception("工厂实列化数据类型错误。请检查DbHelper文件!"); } } } return m_factory; } set{ m_factory = value; } } #endregion #region 私有方法 /// <summary> /// 预处理用户提供的命令,数据库连接/事务/命令类型/参数 /// </summary> /// <param name="connection">数据库连接</param> /// <param name="command">要处理的DbCommand</param> /// <param name="transaction">一个有效的事务或者是null值</param> /// <param name="commandType">命令类型 (存储过程,命令文本, 其它.)</param> /// <param name="commandText">存储过程名或都SQL命令文本</param> /// <param name="commandParameters">和命令相关联的DbParameter参数数组,如果没有参数为'null'</param> /// <param name="mustCloseConnection"><c>true</c> 如果连接是打开的,则为true,其它情况下为false.</param> private static void PrepareCommand(DbConnection connection, DbCommand command, DbTransaction transaction, CommandType commandType, string commandText, DbParameter[] commandParameters, out bool mustCloseConnection) { if (command == null) throw new ArgumentNullException("command"); if (commandText == null || commandText.Length == 0) throw new ArgumentNullException("commandText"); if (connection.State != ConnectionState.Open) { mustCloseConnection = true; connection.Open(); } else { mustCloseConnection = false; } command.Connection = connection; command.CommandText = commandText; if (transaction != null) { if (transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction"); command.Transaction = transaction; } command.CommandType = commandType; if (commandParameters != null) AttachParameters(command, commandParameters); } /// <summary> /// 将DbParameter参数数组(参数值)分配给DbCommand命令. /// 这个方法将给任何一个参数分配DBNull.Value; /// 该操作将阻止默认值的使用. /// </summary> /// <param name="command">命令名</param> /// <param name="commandDbParameters">DbParamentss参数数组</param> private static void AttachParameters(DbCommand command, DbParameter[] commandDbParameters) { if (command == null) throw new ArgumentNullException("command"); if (commandDbParameters != null) { foreach (DbParameter p in commandDbParameters) { if (p != null) { if ((p.Direction == ParameterDirection.Input || p.Direction == ParameterDirection.InputOutput) && (p.Value == null)) { p.Value = DBNull.Value; } command.Parameters.Add(p); } } } } #endregion 私有方法结束 #region ExecuteCommandWithSplitter方法 /// <summary> /// 运行含有GO命令的多条SQL命令 /// </summary> /// <param name="commandText">SQL命令字符串</param> /// <param name="splitter">分割字符串</param> public static void ExecuteCommandWithSplitter(string commandText, string splitter) { int startPos = 0; do { int lastPos = commandText.IndexOf(splitter, startPos); int len = (lastPos > startPos ? lastPos : commandText.Length) - startPos; string query = commandText.Substring(startPos, len); if (query.Trim().Length > 0) { try { ExecuteNonQuery(CommandType.Text, query); } catch { ;} } if (lastPos == -1) break; else startPos = lastPos + splitter.Length; } while (startPos < commandText.Length); } /// <summary> /// 运行含有GO命令的多条SQL命令 /// </summary> /// <param name="commandText">SQL命令字符串</param> public static void ExecuteCommandWithSplitter(string commandText) { ExecuteCommandWithSplitter(commandText, "\r\nGO\r\n"); } #endregion ExecuteCommandWithSplitter方法结束 #region ExecuteNonQuery方法 ExcuteNonQuery 方法 返回命令影响的行数 /// <summary> /// 执行指定连接字符串,类型的DbCommand. /// </summary> /// <remarks> /// 示例: /// int result = ExecuteNonQuery("SELECT * FROM [table123]"); /// </remarks> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回命令影响的行数</returns> public static int ExecuteNonQuery(string commandText) { return ExecuteNonQuery(CommandType.Text, commandText, (DbParameter[])null); } /// <summary> /// 执行指定连接字符串,类型的DbCommand. /// </summary> /// <remarks> /// 示例: /// int result = ExecuteNonQuery("SELECT * FROM [table123]"); /// </remarks> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回命令影响的行数</returns> public static int ExecuteNonQuery(out int id, string commandText) { return ExecuteNonQuery(out id, CommandType.Text, commandText, (DbParameter[])null); } /// <summary> /// 执行指定连接字符串,类型的DbCommand. /// </summary> /// <remarks> /// 示例: /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders"); /// </remarks> /// <param name="ConnectionString">一个有效的数据库连接字符串</param> /// <param name="commandType">命令类型 (存储过程,命令文本, 其它.)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回命令影响的行数</returns> public static int ExecuteNonQuery(CommandType commandType, string commandText) { return ExecuteNonQuery(commandType, commandText, (DbParameter[])null); } /// <summary> /// 执行指定连接字符串,并返回刚插入的自增ID /// </summary> /// <remarks> /// 示例: /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders"); /// </remarks> /// <param name="ConnectionString">一个有效的数据库连接字符串</param> /// <param name="commandType">命令类型 (存储过程,命令文本, 其它.)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回命令影响的行数</returns> public static int ExecuteNonQuery(out int id, CommandType commandType, string commandText) { return ExecuteNonQuery(out id, commandType, commandText, (DbParameter[])null); } /// <summary> /// 执行指定连接字符串,类型的DbCommand.如果没有提供参数,不返回结果. /// </summary> /// <remarks> /// 示例: /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="ConnectionString">一个有效的数据库连接字符串</param> /// <param name="commandType">命令类型 (存储过程,命令文本, 其它.)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <param name="commandParameters">DbParameter参数数组</param> /// <returns>返回命令影响的行数</returns> public static int ExecuteNonQuery(CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (ConnectionString == null || ConnectionString.Length == 0) throw new ArgumentNullException("ConnectionString"); using (DbConnection connection = Factory.CreateConnection()) { connection.ConnectionString = ConnectionString;//ConnectionString; //connection.Open(); return ExecuteNonQuery(connection, commandType, commandText, commandParameters); } } /// <summary> /// 执行指定连接字符串并返回刚插入的自增ID,类型的DbCommand.如果没有提供参数,不返回结果. /// </summary> /// <param name="commandType">命令类型 (存储过程,命令文本, 其它.)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <param name="commandParameters">DbParameter参数数组</param> /// <returns>返回命令影响的行数</returns> public static int ExecuteNonQuery(out int id, CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (ConnectionString == null || ConnectionString.Length == 0) throw new ArgumentNullException("ConnectionString"); using (DbConnection connection = Factory.CreateConnection()) { connection.ConnectionString = ConnectionString; //ConnectionString; //connection.Open(); return ExecuteNonQuery(out id, connection, commandType, commandText, commandParameters); } } /// <summary> /// 执行指定数据库连接对象的命令 /// </summary> /// <remarks> /// 示例: /// int result = ExecuteNonQuery(conn, CommandType.StoredProcedure, "PublishOrders"); /// </remarks> /// <param name="connection">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型(存储过程,命令文本或其它.)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回影响的行数</returns> public static int ExecuteNonQuery(DbConnection connection, CommandType commandType, string commandText) { return ExecuteNonQuery(connection, commandType, commandText, (DbParameter[])null); } /// <summary> /// 执行指定数据库连接对象的命令并返回自增ID /// </summary> /// <remarks> /// 示例: /// int result = ExecuteNonQuery(conn, CommandType.StoredProcedure, "PublishOrders"); /// </remarks> /// <param name="connection">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型(存储过程,命令文本或其它.)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回影响的行数</returns> public static int ExecuteNonQuery(out int id, DbConnection connection, CommandType commandType, string commandText) { return ExecuteNonQuery(out id, connection, commandType, commandText, (DbParameter[])null); } /// <summary> /// 执行指定数据库连接对象的命令 /// </summary> /// <remarks> /// 示例: /// int result = ExecuteNonQuery(conn, CommandType.StoredProcedure, "PublishOrders", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="connection">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型(存储过程,命令文本或其它.)</param> /// <param name="commandText">T存储过程名称或SQL语句</param> /// <param name="commandParameters">SqlParamter参数数组</param> /// <returns>返回影响的行数</returns> public static int ExecuteNonQuery(DbConnection connection, CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (connection == null) throw new ArgumentNullException("connection"); // 创建DbCommand命令,并进行预处理 DbCommand cmd = Factory.CreateCommand(); bool mustCloseConnection = false; PrepareCommand(connection, cmd, (DbTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection); // 执行DbCommand命令,并返回结果. int retval = cmd.ExecuteNonQuery(); // 清除参数,以便再次使用. cmd.Parameters.Clear(); if (mustCloseConnection) connection.Close(); return retval; } /// <summary> /// 执行指定数据库连接对象的命令 /// </summary> /// <remarks> /// 示例: /// int result = ExecuteNonQuery(conn, CommandType.StoredProcedure, "PublishOrders", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="connection">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型(存储过程,命令文本或其它.)</param> /// <param name="commandText">T存储过程名称或SQL语句</param> /// <param name="commandParameters">SqlParamter参数数组</param> /// <returns>返回影响的行数</returns> public static int ExecuteNonQuery(out int id, DbConnection connection, CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (connection == null) throw new ArgumentNullException("connection"); // 创建DbCommand命令,并进行预处理 DbCommand cmd = Factory.CreateCommand(); bool mustCloseConnection = false; PrepareCommand(connection, cmd, (DbTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection); // 执行命令 int retval = cmd.ExecuteNonQuery(); // 清除参数,以便再次使用. cmd.Parameters.Clear(); id = Convert.ToInt32(cmd.ExecuteScalar()); if (mustCloseConnection) { connection.Close(); } return retval; } /// <summary> /// 执行带事务的DbCommand. /// </summary> /// <remarks> /// 示例.: /// int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "PublishOrders"); /// </remarks> /// <param name="transaction">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型(存储过程,命令文本或其它.)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回影响的行数/returns> public static int ExecuteNonQuery(DbTransaction transaction, CommandType commandType, string commandText) { return ExecuteNonQuery(transaction, commandType, commandText, (DbParameter[])null); } /// <summary> /// 执行带事务的DbCommand. /// </summary> /// <remarks> /// 示例.: /// int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "PublishOrders"); /// </remarks> /// <param name="transaction">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型(存储过程,命令文本或其它.)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回影响的行数/returns> public static int ExecuteNonQuery(out int id, DbTransaction transaction, CommandType commandType, string commandText) { return ExecuteNonQuery(out id, transaction, commandType, commandText, (DbParameter[])null); } /// <summary> /// 执行带事务的DbCommand(指定参数). /// </summary> /// <remarks> /// 示例: /// int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "GetOrders", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="transaction">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型(存储过程,命令文本或其它.)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <param name="commandParameters">SqlParamter参数数组</param> /// <returns>返回影响的行数</returns> public static int ExecuteNonQuery(DbTransaction transaction, CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (transaction == null) throw new ArgumentNullException("transaction"); if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction"); // 预处理 DbCommand cmd = Factory.CreateCommand(); bool mustCloseConnection = false; PrepareCommand(transaction.Connection, cmd, transaction, commandType, commandText, commandParameters, out mustCloseConnection); // 执行 // 执行DbCommand命令,并返回结果. int retval = cmd.ExecuteNonQuery(); // 清除参数集,以便再次使用. cmd.Parameters.Clear(); return retval; } /// <summary> /// 执行带事务的DbCommand(指定参数). /// </summary> /// <remarks> /// 示例: /// int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "GetOrders", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="transaction">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型(存储过程,命令文本或其它.)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <param name="commandParameters">SqlParamter参数数组</param> /// <returns>返回影响的行数</returns> public static int ExecuteNonQuery(out int id, DbTransaction transaction, CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (transaction == null) throw new ArgumentNullException("transaction"); if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction"); // 预处理 DbCommand cmd = Factory.CreateCommand(); bool mustCloseConnection = false; PrepareCommand(transaction.Connection, cmd, transaction, commandType, commandText, commandParameters, out mustCloseConnection); // 执行 int retval = cmd.ExecuteNonQuery(); // 清除参数,以便再次使用. cmd.Parameters.Clear(); id = Convert.ToInt32(cmd.ExecuteScalar().ToString()); return retval; } #endregion ExecuteNonQuery方法结束 #region ExecuteScalar 返回结果集中的第一行第一列 #region 基 /// <summary> /// 执行指定数据库连接对象的命令,指定参数,返回结果集中的第一行第一列. /// </summary> /// <remarks> /// 示例: /// int orderCount = (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="connection">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <param name="commandParameters">分配给命令的SqlParamter参数数组</param> /// <returns>返回结果集中的第一行第一列</returns> public static object ExecuteScalar(DbConnection connection, CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (connection == null) throw new ArgumentNullException("connection"); //connection.Close(); connection.ConnectionString = ConnectionString; connection.Open(); // 创建DbCommand命令,并进行预处理 DbCommand cmd = Factory.CreateCommand(); bool mustCloseConnection = false; PrepareCommand(connection, cmd, (DbTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection); // 执行DbCommand命令,并返回结果. object retval = cmd.ExecuteScalar(); // 清除参数,以便再次使用. cmd.Parameters.Clear(); if (mustCloseConnection) connection.Close(); return retval; } /// <summary> /// 执行指定数据库事务的命令,指定参数,返回结果集中的第一行第一列. /// </summary> /// <remarks> /// 示例: /// int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="transaction">一个有效的连接事务</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <param name="commandParameters">分配给命令的SqlParamter参数数组</param> /// <returns>返回结果集中的第一行第一列</returns> public static object ExecuteScalar(DbTransaction transaction, CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (transaction == null) throw new ArgumentNullException("transaction"); if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction"); // 创建DbCommand命令,并进行预处理 DbCommand cmd = Factory.CreateCommand(); bool mustCloseConnection = false; PrepareCommand(transaction.Connection, cmd, transaction, commandType, commandText, commandParameters, out mustCloseConnection); // 执行DbCommand命令,并返回结果. object retval = cmd.ExecuteScalar(); // 清除参数,以便再次使用. cmd.Parameters.Clear(); return retval; } #endregion /// <summary> /// 执行指定数据库连接字符串的命令,返回结果集中的第一行第一列. /// </summary> /// <remarks> /// 示例: /// int orderCount = (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount"); /// </remarks> /// <param name="ConnectionString">一个有效的数据库连接字符串</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回结果集中的第一行第一列</returns> public static object ExecuteScalar(string commandText) { // 执行参数为空的方法 return ExecuteScalar(CommandType.Text, commandText, (DbParameter[])null); } /// <summary> /// 执行指定数据库连接字符串的命令,返回结果集中的第一行第一列. /// </summary> /// <remarks> /// 示例: /// int orderCount = (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount"); /// </remarks> /// <param name="ConnectionString">一个有效的数据库连接字符串</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回结果集中的第一行第一列</returns> public static object ExecuteScalar(CommandType commandType, string commandText) { // 执行参数为空的方法 return ExecuteScalar(commandType, commandText, (DbParameter[])null); } /// <summary> /// 执行指定数据库连接字符串的命令,指定参数,返回结果集中的第一行第一列. /// </summary> /// <remarks> /// 示例: /// int orderCount = (int)ExecuteScalar(connString, CommandType.StoredProcedure, "GetOrderCount", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="ConnectionString">一个有效的数据库连接字符串</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <param name="commandParameters">分配给命令的SqlParamter参数数组</param> /// <returns>返回结果集中的第一行第一列</returns> public static object ExecuteScalar(CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (ConnectionString == null || ConnectionString.Length == 0) throw new ArgumentNullException("ConnectionString"); // 创建并打开数据库连接对象,操作完成释放对象. using (DbConnection connection = Factory.CreateConnection()) { connection.ConnectionString = ConnectionString; // connection.Open(); // 调用指定数据库连接字符串重载方法. return ExecuteScalar(connection, commandType, commandText, commandParameters); } } /// <summary> /// 执行指定数据库连接对象的命令,返回结果集中的第一行第一列. /// </summary> /// <remarks> /// 示例: /// int orderCount = (int)ExecuteScalar(conn, CommandType.StoredProcedure, "GetOrderCount"); /// </remarks> /// <param name="connection">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回结果集中的第一行第一列</returns> public static object ExecuteScalar(DbConnection connection, CommandType commandType, string commandText) { // 执行参数为空的方法 return ExecuteScalar(connection, commandType, commandText, (DbParameter[])null); } /// <summary> /// 执行指定数据库事务的命令,返回结果集中的第一行第一列. /// </summary> /// <remarks> /// 示例: /// int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount"); /// </remarks> /// <param name="transaction">一个有效的连接事务</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回结果集中的第一行第一列</returns> public static object ExecuteScalar(DbTransaction transaction, CommandType commandType, string commandText) { // 执行参数为空的方法 return ExecuteScalar(transaction, commandType, commandText, (DbParameter[])null); } #region 执行ExecuteScalar,将结果以字符串类型输出。 public static string ExecuteScalarToStr(CommandType commandType, string commandText) { object ec = ExecuteScalar(commandType, commandText); if (ec == null) { return ""; } return ec.ToString(); } public static string ExecuteScalarToStr(CommandType commandType, string commandText, params DbParameter[] commandParameters) { object ec = ExecuteScalar(commandType, commandText, commandParameters); if (ec == null) { return ""; } return ec.ToString(); } #endregion #endregion #region ExecuteReader 数据阅读器 /// <summary> /// 枚举,标识数据库连接是由BaseDbHelper提供还是由调用者提供 /// </summary> private enum DbConnectionOwnership { /// <summary>由BaseDbHelper提供连接</summary> Internal, /// <summary>由调用者提供连接</summary> External } /// <summary> /// 执行指定数据库连接对象的数据阅读器. /// </summary> /// <remarks> /// 如果是BaseDbHelper打开连接,当连接关闭DataReader也将关闭. /// 如果是调用都打开连接,DataReader由调用都管理. /// </remarks> /// <param name="connection">一个有效的数据库连接对象</param> /// <param name="transaction">一个有效的事务,或者为 'null'</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名或SQL语句</param> /// <param name="commandParameters">DbParameters参数数组,如果没有参数则为'null'</param> /// <param name="connectionOwnership">标识数据库连接对象是由调用者提供还是由BaseDbHelper提供</param> /// <returns>返回包含结果集的DbDataReader</returns> private static DbDataReader ExecuteReader(DbConnection connection, DbTransaction transaction, CommandType commandType, string commandText, DbParameter[] commandParameters, DbConnectionOwnership connectionOwnership) { if (connection == null) throw new ArgumentNullException("connection"); //connection.Close(); connection.ConnectionString = ConnectionString; connection.Open(); bool mustCloseConnection = false; // 创建命令 DbCommand cmd = Factory.CreateCommand(); try { PrepareCommand(connection, cmd, transaction, commandType, commandText, commandParameters, out mustCloseConnection); // 创建数据阅读器 DbDataReader dataReader; if (connectionOwnership == DbConnectionOwnership.External) { dataReader = cmd.ExecuteReader(); } else { dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection); } // 清除参数,以便再次使用.. bool canClear = true; foreach (DbParameter commandParameter in cmd.Parameters) { if (commandParameter.Direction != ParameterDirection.Input) canClear = false; } if (canClear) { //cmd.Dispose(); cmd.Parameters.Clear(); } return dataReader; } catch { if (mustCloseConnection) connection.Close(); throw; } } /// <summary> /// 执行指定数据库连接字符串的数据阅读器. /// </summary> /// <remarks> /// 示例: /// DbDataReader dr = ExecuteReader(connString, CommandType.StoredProcedure, "GetOrders"); /// </remarks> /// <param name="ConnectionString">一个有效的数据库连接字符串</param> /// <param name="commandText">SQL语句</param> /// <returns>返回包含结果集的DbDataReader</returns> public static DbDataReader ExecuteReader(string commandText) { return ExecuteReader(CommandType.Text, commandText, (DbParameter[])null); } /// <summary> /// 执行指定数据库连接字符串的数据阅读器. /// </summary> /// <remarks> /// 示例: /// DbDataReader dr = ExecuteReader(connString, CommandType.StoredProcedure, "GetOrders"); /// </remarks> /// <param name="ConnectionString">一个有效的数据库连接字符串</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名或SQL语句</param> /// <returns>返回包含结果集的DbDataReader</returns> public static DbDataReader ExecuteReader(CommandType commandType, string commandText) { return ExecuteReader(commandType, commandText, (DbParameter[])null); } /// <summary> /// 执行指定数据库连接字符串的数据阅读器,指定参数. /// </summary> /// <remarks> /// 示例: /// DbDataReader dr = ExecuteReader(connString, CommandType.StoredProcedure, "GetOrders", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="ConnectionString">一个有效的数据库连接字符串</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名或SQL语句</param> /// <param name="commandParameters">SqlParamter参数数组(new DbParameter("@prodid", 24))</param> /// <returns>返回包含结果集的DbDataReader</returns> public static DbDataReader ExecuteReader(CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (ConnectionString == null || ConnectionString.Length == 0) throw new ArgumentNullException("ConnectionString"); DbConnection connection = null; try { connection = Factory.CreateConnection(); connection.ConnectionString = ConnectionString; //connection.Open(); return ExecuteReader(connection, null, commandType, commandText, commandParameters, DbConnectionOwnership.Internal); } catch { // If we fail to return the SqlDatReader, we need to close the connection ourselves if (connection != null) connection.Close(); throw; } } /// <summary> /// 执行指定数据库连接对象的数据阅读器. /// </summary> /// <remarks> /// 示例: /// DbDataReader dr = ExecuteReader(conn, CommandType.StoredProcedure, "GetOrders"); /// </remarks> /// <param name="connection">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名或SQL语句</param> /// <returns>返回包含结果集的DbDataReader</returns> public static DbDataReader ExecuteReader(DbConnection connection, CommandType commandType, string commandText) { return ExecuteReader(connection, commandType, commandText, (DbParameter[])null); } /// <summary> /// [调用者方式]执行指定数据库连接对象的数据阅读器,指定参数. /// </summary> /// <remarks> /// 示例: /// DbDataReader dr = ExecuteReader(conn, CommandType.StoredProcedure, "GetOrders", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="connection">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandParameters">SqlParamter参数数组</param> /// <returns>返回包含结果集的DbDataReader</returns> public static DbDataReader ExecuteReader(DbConnection connection, CommandType commandType, string commandText, params DbParameter[] commandParameters) { return ExecuteReader(connection, (DbTransaction)null, commandType, commandText, commandParameters, DbConnectionOwnership.External); } /// <summary> /// [调用者方式]执行指定数据库事务的数据阅读器,指定参数值. /// </summary> /// <remarks> /// 示例: /// DbDataReader dr = ExecuteReader(trans, CommandType.StoredProcedure, "GetOrders"); /// </remarks> /// <param name="transaction">一个有效的连接事务</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回包含结果集的DbDataReader</returns> public static DbDataReader ExecuteReader(DbTransaction transaction, CommandType commandType, string commandText) { return ExecuteReader(transaction, commandType, commandText, (DbParameter[])null); } /// <summary> /// [调用者方式]执行指定数据库事务的数据阅读器,指定参数. /// </summary> /// <remarks> /// 示例: /// DbDataReader dr = ExecuteReader(trans, CommandType.StoredProcedure, "GetOrders", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="transaction">一个有效的连接事务</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <param name="commandParameters">分配给命令的SqlParamter参数数组</param> /// <returns>返回包含结果集的DbDataReader</returns> public static DbDataReader ExecuteReader(DbTransaction transaction, CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (transaction == null) throw new ArgumentNullException("transaction"); if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction"); return ExecuteReader(transaction.Connection, transaction, commandType, commandText, commandParameters, DbConnectionOwnership.External); } #endregion ExecuteReader数据阅读器 #region ExecuteDataset方法 /// <summary> /// 执行指定数据库连接字符串的命令,返回DataSet. /// </summary> /// <remarks> /// 示例: /// DataSet ds = ExecuteDataset("SELECT * FROM [table1]"); /// </remarks> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回一个包含结果集的DataSet</returns> public static DataSet ExecuteDataset(string commandText) { return ExecuteDataset(CommandType.Text, commandText, (DbParameter[])null); } /// <summary> /// 执行指定数据库连接字符串的命令,返回DataSet. /// </summary> /// <remarks> /// 示例: /// DataSet ds = ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders"); /// </remarks> /// <param name="ConnectionString">一个有效的数据库连接字符串</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <returns>返回一个包含结果集的DataSet</returns> public static DataSet ExecuteDataset(CommandType commandType, string commandText) { return ExecuteDataset(commandType, commandText, (DbParameter[])null); } /// <summary> /// 执行指定数据库连接字符串的命令,返回DataSet. /// </summary> /// <remarks> /// 示例: /// DataSet ds = ExecuteDataset(connString, CommandType.StoredProcedure, "GetOrders", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="ConnectionString">一个有效的数据库连接字符串</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名称或SQL语句</param> /// <param name="commandParameters">SqlParamters参数数组</param> /// <returns>返回一个包含结果集的DataSet</returns> public static DataSet ExecuteDataset(CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (ConnectionString == null || ConnectionString.Length == 0) throw new ArgumentNullException("ConnectionString"); // 创建并打开数据库连接对象,操作完成释放对象. using (DbConnection connection = Factory.CreateConnection()) { connection.ConnectionString = ConnectionString; // connection.Open(); // 调用指定数据库连接字符串重载方法. return ExecuteDataset(connection, commandType, commandText, commandParameters); } } /// <summary> /// 执行指定数据库连接对象的命令,返回DataSet. /// </summary> /// <remarks> /// 示例: /// DataSet ds = ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders"); /// </remarks> /// <param name="connection">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名或SQL语句</param> /// <returns>返回一个包含结果集的DataSet</returns> public static DataSet ExecuteDataset(DbConnection connection, CommandType commandType, string commandText) { return ExecuteDataset(connection, commandType, commandText, (DbParameter[])null); } /// <summary> /// 执行指定数据库连接对象的命令,指定存储过程参数,返回DataSet. /// </summary> /// <remarks> /// 示例: /// DataSet ds = ExecuteDataset(conn, CommandType.StoredProcedure, "GetOrders", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="connection">一个有效的数据库连接对象</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名或SQL语句</param> /// <param name="commandParameters">SqlParamter参数数组</param> /// <returns>返回一个包含结果集的DataSet</returns> public static DataSet ExecuteDataset(DbConnection connection, CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (connection == null) throw new ArgumentNullException("connection"); // connection.Close(); connection.ConnectionString = ConnectionString; connection.Open(); // 预处理 DbCommand cmd = Factory.CreateCommand(); bool mustCloseConnection = false; PrepareCommand(connection, cmd, (DbTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection); // 创建DbDataAdapter和DataSet. using (DbDataAdapter da = Factory.CreateDataAdapter()) { da.SelectCommand = cmd; DataSet ds = new DataSet(); // 填充DataSet. da.Fill(ds); cmd.Parameters.Clear(); if (mustCloseConnection) connection.Close(); return ds; } } /// <summary> /// 执行指定事务的命令,返回DataSet. /// </summary> /// <remarks> /// 示例: /// DataSet ds = ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders"); /// </remarks> /// <param name="transaction">事务</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名或SQL语句</param> /// <returns>返回一个包含结果集的DataSet</returns> public static DataSet ExecuteDataset(DbTransaction transaction, CommandType commandType, string commandText) { return ExecuteDataset(transaction, commandType, commandText, (DbParameter[])null); } /// <summary> /// 执行指定事务的命令,指定参数,返回DataSet. /// </summary> /// <remarks> /// 示例: /// DataSet ds = ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders", new DbParameter("@prodid", 24)); /// </remarks> /// <param name="transaction">事务</param> /// <param name="commandType">命令类型 (存储过程,命令文本或其它)</param> /// <param name="commandText">存储过程名或SQL语句</param> /// <param name="commandParameters">SqlParamter参数数组</param> /// <returns>返回一个包含结果集的DataSet</returns> public static DataSet ExecuteDataset(DbTransaction transaction, CommandType commandType, string commandText, params DbParameter[] commandParameters) { if (transaction == null) throw new ArgumentNullException("transaction"); if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction"); // 预处理 DbCommand cmd = Factory.CreateCommand(); bool mustCloseConnection = false; PrepareCommand(transaction.Connection, cmd, transaction, commandType, commandText, commandParameters, out mustCloseConnection); // 创建 DataAdapter & DataSet using (DbDataAdapter da = Factory.CreateDataAdapter()) { da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds); cmd.Parameters.Clear(); return ds; } } #endregion ExecuteDataset数据集命令结束 #region 事务方法 执行多条SQL语句,实现数据库事务。 /// <summary> /// 执行多条SQL语句,实现数据库事务。 /// </summary> /// <param name="SQLStringList">SQL语句的哈希表(key为sql语句,value是该语句的SqlParameter[])</param> public static void ExecuteSqlTran(Hashtable SQLStringList) { using (DbConnection connection = Factory.CreateConnection()) { connection.ConnectionString = ConnectionString; connection.Open(); using (DbTransaction trans = connection.BeginTransaction()) { DbCommand cmd = Factory.CreateCommand(); bool mustCloseConnection = false; try { //循环 foreach (DictionaryEntry myDE in SQLStringList) { string cmdText = myDE.Key.ToString(); DbParameter[] cmdParms = (DbParameter[])myDE.Value; PrepareCommand(connection, cmd, trans, CommandType.Text, cmdText, cmdParms, out mustCloseConnection); int val = cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); } trans.Commit(); if (mustCloseConnection) connection.Close(); } catch { trans.Rollback(); throw; } } } } /// <summary> /// 执行多条SQL语句,实现数据库事务。 /// </summary> /// <param name="SQLStringList">SQL语句的哈希表(key为sql语句,value是该语句的SqlParameter[])</param> public static int ExecuteSqlTran(System.Collections.Generic.List<CommandInfo> cmdList) { using (DbConnection connection = Factory.CreateConnection()) { connection.ConnectionString = ConnectionString; connection.Open(); using (DbTransaction trans = connection.BeginTransaction()) { DbCommand cmd = Factory.CreateCommand(); try { int count = 0; bool mustCloseConnection = false; //循环 foreach (CommandInfo myDE in cmdList) { string cmdText = myDE.CommandText; DbParameter[] cmdParms = (DbParameter[])myDE.Parameters; PrepareCommand(connection, cmd, trans, CommandType.Text, cmdText, cmdParms, out mustCloseConnection); if (myDE.EffentNextType == EffentNextType.WhenHaveContine || myDE.EffentNextType == EffentNextType.WhenNoHaveContine) { if (myDE.CommandText.ToLower().IndexOf("count(") == -1) { trans.Rollback(); return 0; } object obj = cmd.ExecuteScalar(); bool isHave = false; if (obj == null && obj == DBNull.Value) { isHave = false; } isHave = Convert.ToInt32(obj) > 0; if (myDE.EffentNextType == EffentNextType.WhenHaveContine && !isHave) { trans.Rollback(); return 0; } if (myDE.EffentNextType == EffentNextType.WhenNoHaveContine && isHave) { trans.Rollback(); return 0; } continue; } int val = cmd.ExecuteNonQuery(); count += val; if (myDE.EffentNextType == EffentNextType.ExcuteEffectRows && val == 0) { trans.Rollback(); return 0; } cmd.Parameters.Clear(); } trans.Commit(); if (mustCloseConnection) connection.Close(); return count; } catch { trans.Rollback(); throw; } } } } /// <summary> /// 执行多条SQL语句,实现数据库事务。 /// </summary> /// <param name="SQLStringList">SQL语句的哈希表(key为sql语句,value是该语句的SqlParameter[])</param> public static void ExecuteSqlTranWithIndentity(System.Collections.Generic.List<CommandInfo> SQLStringList) { using (DbConnection connection = Factory.CreateConnection()) { connection.ConnectionString = ConnectionString; connection.Open(); using (DbTransaction trans = connection.BeginTransaction()) { DbCommand cmd = Factory.CreateCommand(); try { bool mustCloseConnection = false; int indentity = 0; //循环 foreach (CommandInfo myDE in SQLStringList) { string cmdText = myDE.CommandText; DbParameter[] cmdParms = (DbParameter[])myDE.Parameters; foreach (DbParameter q in cmdParms) { if (q.Direction == ParameterDirection.InputOutput) { q.Value = indentity; } } PrepareCommand(connection, cmd, trans, CommandType.Text, cmdText, cmdParms, out mustCloseConnection); int val = cmd.ExecuteNonQuery(); foreach (DbParameter q in cmdParms) { if (q.Direction == ParameterDirection.Output) { indentity = Convert.ToInt32(q.Value); } } cmd.Parameters.Clear(); } if (mustCloseConnection) connection.Close(); trans.Commit(); } catch { trans.Rollback(); throw; } } } } /// <summary> /// 执行多条SQL语句,实现数据库事务。 /// </summary> /// <param name="SQLStringList">SQL语句的哈希表(key为sql语句,value是该语句的SqlParameter[])</param> public static void ExecuteSqlTranWithIndentity(Hashtable SQLStringList) { using (DbConnection connection = Factory.CreateConnection()) { connection.ConnectionString = ConnectionString; connection.Open(); using (DbTransaction trans = connection.BeginTransaction()) { DbCommand cmd = Factory.CreateCommand(); try { int indentity = 0; bool mustCloseConnection = false; //循环 foreach (DictionaryEntry myDE in SQLStringList) { string cmdText = myDE.Key.ToString(); DbParameter[] cmdParms = (DbParameter[])myDE.Value; foreach (DbParameter q in cmdParms) { if (q.Direction == ParameterDirection.InputOutput) { q.Value = indentity; } } PrepareCommand(connection, cmd, trans, CommandType.Text, cmdText, cmdParms, out mustCloseConnection); int val = cmd.ExecuteNonQuery(); foreach (DbParameter q in cmdParms) { if (q.Direction == ParameterDirection.Output) { indentity = Convert.ToInt32(q.Value); } } cmd.Parameters.Clear(); } if (mustCloseConnection) connection.Close(); trans.Commit(); } catch { trans.Rollback(); throw; } } } } #endregion } public enum EffentNextType { /// <summary> /// 对其他语句无任何影响 /// </summary> None, /// <summary> /// 当前语句必须为"select count(1) from .."格式,如果存在则继续执行,不存在回滚事务 /// </summary> WhenHaveContine, /// <summary> /// 当前语句必须为"select count(1) from .."格式,如果不存在则继续执行,存在回滚事务 /// </summary> WhenNoHaveContine, /// <summary> /// 当前语句影响到的行数必须大于0,否则回滚事务 /// </summary> ExcuteEffectRows, /// <summary> /// 引发事件-当前语句必须为"select count(1) from .."格式,如果不存在则继续执行,存在回滚事务 /// </summary> SolicitationEvent } public class CommandInfo { public object ShareObject = null; public object OriginalData = null; event EventHandler _solicitationEvent; public event EventHandler SolicitationEvent { add { _solicitationEvent += value; } remove { _solicitationEvent -= value; } } public void OnSolicitationEvent() { if (_solicitationEvent != null) { _solicitationEvent(this, new EventArgs()); } } public string CommandText; public System.Data.Common.DbParameter[] Parameters; public EffentNextType EffentNextType = EffentNextType.None; public CommandInfo() { } public CommandInfo(string sqlText, DbParameter[] para) { this.CommandText = sqlText; this.Parameters = para; } public CommandInfo(string sqlText, DbParameter[] para, EffentNextType type) { this.CommandText = sqlText; this.Parameters = para; this.EffentNextType = type; } } }
10aaa-10aaa
trunk/TRECommerce/TREC.Data/DbHelper.cs
C#
oos
63,684
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using TREC.Entity; using TREC.Data; using TRECommon; namespace TREC.ECommerce { public class ECPromotionStage { #region Method-PromotionStage /// <summary> /// 更新对像 /// </summary> public static int EditPromotionStage(EnPromotionStage model) { return Promotions.EditPromotionStage(model); } /// <summary> /// 得到一个对象实体 /// </summary> public static EnPromotionStage GetPromotionStageInfo(string strWhere) { return Promotions.GetPromotionStageInfo(strWhere); } /// <summary> /// 获得数据列表 /// </summary> public static List<EnPromotionStage> GetPromotionStageList(int PageIndex, int PageSize, string strWhere, out int pageCount) { return Promotions.GetPromotionStageList(PageIndex, PageSize, strWhere, out pageCount); } ///获取数据列表 public static List<EnPromotionStage> GetPromotionStageList(string strWhere, out int pageCount) { return GetPromotionStageList(-1, 0, strWhere, out pageCount); } ///获取数据列表 public static List<EnPromotionStage> GetPromotionStageList(string strWhere) { int tmpPageCount = 0; return GetPromotionStageList(-1, 0, strWhere, out tmpPageCount); } //获取数据列表ToDataTable public static DataTable GetPromotionStageListToTable(int PageIndex, int PageSize, string strWhere, out int pageCount) { return DataCommon.GetPageDataTable(TableName.TBPromotionStage, PageIndex, PageSize, strWhere, "id", 1, out pageCount); } ///删除对象 public static int DeletePromotionStage(int id) { return DeletePromotionStage(" where id=" + id); } ///删除对象 public static int DeletePromotionStageByIdList(string idList) { return DeletePromotionStage(" where id in (" + idList + ")"); } ///删除对象 public static int DeletePromotionStage(string strWhere) { return DataCommon.Delete(TableName.TBPromotionStage, strWhere); } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.ECommerce/EnPromotionStage.cs
C#
oos
2,484
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using TREC.Entity; using TREC.Data; using TRECommon; namespace TREC.ECommerce { public class ECAppPromotion { #region Method-PromotionAppBrand public static int UpConFilePath(string con, int id) { return DataCommon.UpdateValue(TableName.TBPromotionAppBrand, "descript", con, " where id=" + id); } /// <summary> /// 更新对像 /// </summary> public static int EditPromotionAppBrand(EnPromotionAppBrand model) { return AppPromotions.EditPromotionAppBrand(model); } /// <summary> /// 得到一个对象实体 /// </summary> public static EnPromotionAppBrand GetPromotionAppBrandInfo(string strWhere) { return AppPromotions.GetPromotionAppBrandInfo(strWhere); } /// <summary> /// 获得数据列表 /// </summary> public static List<EnPromotionAppBrand> GetPromotionAppBrandList(int PageIndex, int PageSize, string strWhere, out int pageCount) { return AppPromotions.GetPromotionAppBrandList(PageIndex, PageSize, strWhere, out pageCount); } ///获取数据列表 public static List<EnPromotionAppBrand> GetPromotionAppBrandList(string strWhere, out int pageCount) { return GetPromotionAppBrandList(-1, 0, strWhere, out pageCount); } ///获取数据列表 public static List<EnPromotionAppBrand> GetPromotionAppBrandList(string strWhere) { int tmpPageCount = 0; return GetPromotionAppBrandList(-1, 0, strWhere, out tmpPageCount); } //获取数据列表ToDataTable public static DataTable GetPromotionAppBrandListToTable(int PageIndex, int PageSize, string strWhere, out int pageCount) { return DataCommon.GetPageDataTable(TableName.TBPromotionAppBrand, PageIndex, PageSize, strWhere, "id", 1, out pageCount); } public static string GetPromotionAppBrandIdListByCompany(string companyId) { List<EnPromotionAppBrand> list = GetPromotionAppBrandList(" companyid=" + companyId); StringBuilder sb = new StringBuilder(); foreach (EnPromotionAppBrand b in list) { sb.Append(b.id + ","); } return sb.ToString().Length > 0 && sb.ToString().EndsWith(",") ? sb.ToString().Substring(0, sb.ToString().Length - 1) : sb.ToString(); } ///删除对象 public static int UpPromotionAppBrand(int id) { return DataCommon.UpdateValue(TableName.TBPromotionAppBrand, "auditstatus", "1", " where id=" + id); } ///删除对象 public static int DeletePromotionAppBrand(int id) { return DeletePromotionAppBrand(" where id=" + id); } ///删除对象 public static int DeletePromotionAppBrandByIdList(string idList) { return DeletePromotionAppBrand(" where id in (" + idList + ")"); } ///删除对象 public static int DeletePromotionAppBrand(string strWhere) { return DataCommon.Delete(TableName.TBPromotionAppBrand, strWhere); } #endregion #region Method-AppBrandCustomer /// <summary> /// 更新对像 /// </summary> public static int EditAppBrandCustomer(EnAppBrandCustomer model) { return AppPromotions.EditAppBrandCustomer(model); } /// <summary> /// 得到一个对象实体 /// </summary> public static EnAppBrandCustomer GetAppBrandCustomerInfo(string strWhere) { return AppPromotions.GetAppBrandCustomerInfo(strWhere); } /// <summary> /// 获得数据列表 /// </summary> public static List<EnAppBrandCustomer> GetAppBrandCustomerList(int PageIndex, int PageSize, string strWhere, out int pageCount) { return AppPromotions.GetAppBrandCustomerList(PageIndex, PageSize, strWhere, out pageCount); } public static List<EnAppProduct> GetAppProductList(int PageIndex, int PageSize, string strWhere, out int pageCount) { return AppPromotions.GetAppBrandProductList(PageIndex, PageSize, strWhere, out pageCount); } public static DataTable GetAppProductListUsers() { return DataCommon.GetDataTable(TableName.TBAppBrandProduct,"mid,name"," group by mid,name",""); } public static DataTable GetAppCustomerListUsers() { return DataCommon.GetDataTable(TableName.TBAppBrandCustomer, "name", " group by name", ""); } public static DataTable GetAppCustomerListAreas() { return DataCommon.GetDataTable(TableName.TBAppBrandCustomer, "address", " where address<>'' and address is not null group by address", ""); } ///获取数据列表 public static List<EnAppBrandCustomer> GetAppBrandCustomerList(string strWhere, out int pageCount) { return GetAppBrandCustomerList(-1, 0, strWhere, out pageCount); } ///获取数据列表 public static List<EnAppBrandCustomer> GetAppBrandCustomerList(string strWhere) { int tmpPageCount = 0; return GetAppBrandCustomerList(-1, 0, strWhere, out tmpPageCount); } //获取数据列表ToDataTable public static DataTable GetAppBrandCustomerListToTable(int PageIndex, int PageSize, string strWhere, out int pageCount) { return DataCommon.GetPageDataTable(TableName.TBAppBrandCustomer, PageIndex, PageSize, strWhere, "id", 1, out pageCount); } public static string GetAppBrandCustomerIdListByCompany(string companyId) { List<EnAppBrandCustomer> list = GetAppBrandCustomerList(" companyid=" + companyId); StringBuilder sb = new StringBuilder(); foreach (EnAppBrandCustomer b in list) { sb.Append(b.id + ","); } return sb.ToString().Length > 0 && sb.ToString().EndsWith(",") ? sb.ToString().Substring(0, sb.ToString().Length - 1) : sb.ToString(); } ///删除对象 public static int UpAppBrandCustomer(int id) { return DataCommon.UpdateValue(TableName.TBAppBrandCustomer, "auditstatus", "1", " where id=" + id); } ///删除对象 public static int DeleteAppBrandCustomer(int id) { return DeleteAppBrandCustomer(" where id=" + id); } ///删除对象 public static int DeleteAppBrandCustomerByIdList(string idList) { return DeleteAppBrandCustomer(" where id in (" + idList + ")"); } ///删除对象 public static int DeleteAppBrandCustomer(string strWhere) { return DataCommon.Delete(TableName.TBAppBrandCustomer, strWhere); } #endregion ///删除对象 public static int DeleteAppProductCustomer(int id) { return DeleteAppBrandCustomer(" where id=" + id); } ///删除对象 public static int DeleteAppProductCustomerByIdList(string idList) { return DeleteAppProductCustomer(" where id in (" + idList + ")"); } ///删除对象 public static int DeleteAppProductCustomer(string strWhere) { return DataCommon.Delete(TableName.TBAppBrandProduct, strWhere); } } }
10aaa-10aaa
trunk/TRECommerce/TREC.ECommerce/ECAppPromotion.cs
C#
oos
7,998
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; namespace TREC.ECommerce { public class AdminPageBase : System.Web.UI.Page { public int tmpPageCount = 0; public int adminId = 0; public string adminName = "后台开发用户"; public int thisPageModule = 0; public int thisOperateActionId = 0; public AdminPageBase() { if (TRECommon.CookiesHelper.GetCookie("aadmin") != TRECommon.MyMD5.GetMD5("admin") && TRECommon.CookiesHelper.GetCookie("apwd") != TRECommon.MyMD5.GetMD5("jjks")) { HttpContext.Current.Response.Redirect("login.aspx"); } } } }
10aaa-10aaa
trunk/TRECommerce/TREC.ECommerce/AdminPageBase.cs
C#
oos
770
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using TREC.Entity; using TREC.Data; using TRECommon; namespace TREC.ECommerce { public class ECCompany { public static int ExitComapnyTitle(string title) { return Companys.ExitComapny(title); } public static EnWebCompany GetWebCompanyInfo(string strWhere) { return Companys.GetWebCompanyInfo(strWhere); } public static List<EnWebCompany> GetWebCompanyList(int PageIndex, int PageSize, string strWhere,string sortkey,string ordertype, out int pageCount) { return Companys.GetWebCompanyList(PageIndex, PageSize, strWhere,sortkey, ordertype, out pageCount); } public static List<EnWebCompanyBrand> GetWebCompanyBrandList(int PageIndex, int PageSize, string strWhere,string sortkey, string ordertype, out int pageCount) { return Companys.GetWebCompanyBrandList(PageIndex, PageSize, strWhere, sortkey, ordertype, out pageCount); } public static List<EnSearchItem> GetSearchItem() { List<EnSearchItem> list = new List<EnSearchItem>(); List<EnSearchItem> itemList= (List<EnSearchItem>)DataCache.GetCache(CacheKey.CompanySearchItemList); if (itemList == null) { itemList = Companys.GetCompanySearchItem(); DataCache.SetCache(CacheKey.CompanySearchItemList, itemList); } foreach (EnSearchItem item in itemList) { if (item.type == "brand" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchBrand != "" && ECommon.QuerySearchBrand.Split('_').Contains(item.value)) { item.isCur = true; list.Add(item); continue; } else { item.isCur = false; } } if (item.type == "style" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchStyle != "" && ECommon.QuerySearchStyle.Split('_').Contains(item.value)) { item.isCur = true; list.Add(item); continue; } else { item.isCur = false; } } if (item.type == "material" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchMaterial != "" && ECommon.QuerySearchMaterial.Split('_').Contains(item.value)) { item.isCur = true; list.Add(item); continue; } else { item.isCur = false; } } if (item.type == "spread" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchSpread != "" && ECommon.QuerySearchSpread.Split('_').Contains(item.value)) { item.isCur = true; list.Add(item); continue; } else { item.isCur = false; } } if (item.type == "staffsize" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchStaffsize != "" && ECommon.QuerySearchStaffsize.Split('_').Contains(item.value)) { item.isCur = true; list.Add(item); continue; } else { item.isCur = false; } } list.Add(item); } return list; } public static int UpConFilePath(string con, int id) { return DataCommon.UpdateValue(TableName.TBCompany, "descript", con, " where id=" + id); } #region Method-Company /// <summary> /// 更新对像 /// </summary> public static int EditCompany(EnCompany model) { return Companys.EditCompany(model); } /// <summary> /// 得到一个对象实体 /// </summary> public static EnCompany GetCompanyInfo(string strWhere) { return Companys.GetCompanyInfo(strWhere); } /// <summary> /// 获得数据列表 /// </summary> public static List<EnCompany> GetCompanyList(int PageIndex, int PageSize, string strWhere, out int pageCount) { return Companys.GetCompanyList(PageIndex, PageSize, strWhere, out pageCount); } ///获取数据列表 public static List<EnCompany> GetCompanyList(string strWhere, out int pageCount) { return GetCompanyList(-1, 0, strWhere, out pageCount); } ///获取数据列表 public static List<EnCompany> GetCompanyList(string strWhere) { int tmpPageCount = 0; return GetCompanyList(-1, 0, strWhere, out tmpPageCount); } //获取数据列表ToDataTable public static DataTable GetCompanyListToTable(int PageIndex, int PageSize, string strWhere, out int pageCount) { return DataCommon.GetPageDataTable(TableName.TBCompany, PageIndex, PageSize, strWhere, "id", 1, out pageCount); } ///删除对象 public static int DeleteCompany(int id) { return DeleteCompany(" where id=" + id); } ///删除对象 public static int DeleteCompanyByIdList(string idList) { return DeleteCompany(" where id in (" + idList + ")"); } ///删除对象 public static int DeleteCompany(string strWhere) { return DataCommon.Delete(TableName.TBCompany, strWhere); } #endregion #region Method-CompanyGroup /// <summary> /// 更新对像 /// </summary> public static int EditCompanyGroup(EnCompanyGroup model) { return Companys.EditCompanyGroup(model); } /// <summary> /// 得到一个对象实体 /// </summary> public static EnCompanyGroup GetCompanyGroupInfo(string strWhere) { return Companys.GetCompanyGroupInfo(strWhere); } /// <summary> /// 获得数据列表 /// </summary> public static List<EnCompanyGroup> GetCompanyGroupList(int PageIndex, int PageSize, string strWhere, out int pageCount) { return Companys.GetCompanyGroupList(PageIndex, PageSize, strWhere, out pageCount); } ///获取数据列表 public static List<EnCompanyGroup> GetCompanyGroupList(string strWhere, out int pageCount) { return GetCompanyGroupList(-1, 0, strWhere, out pageCount); } ///获取数据列表 public static List<EnCompanyGroup> GetCompanyGroupList(string strWhere) { int tmpPageCount = 0; return GetCompanyGroupList(-1, 0, strWhere, out tmpPageCount); } //获取数据列表ToDataTable public static DataTable GetCompanyGroupListToTable(int PageIndex, int PageSize, string strWhere, out int pageCount) { return DataCommon.GetPageDataTable(TableName.TBCompanyGroup, PageIndex, PageSize, strWhere, "id", 1, out pageCount); } ///删除对象 public static int DeletEnCompanyGroup(int id) { return DeletEnCompanyGroup(" where id=" + id); } ///删除对象 public static int DeletEnCompanyGroupByIdList(string idList) { return DeletEnCompanyGroup(" where id in (" + idList + ")"); } ///删除对象 public static int DeletEnCompanyGroup(string strWhere) { return DataCommon.Delete(TableName.TBCompanyGroup, strWhere); } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.ECommerce/ECCompany.cs
C#
oos
8,796
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using TREC.Entity; using TREC.Data; using TRECommon; namespace TREC.ECommerce { public class ECProduct { public static int ExitProductSku(string sku) { return Products.ExitBrandSku(sku); } public static List<EnSearchProductItem> GetProductSearchItemByCompanyId(int companyid) { return Products.GetProductSearchItem(" companyid=" + companyid); } public static List<EnSearchProductItem> GetProductSearchItemByShopId(int shopId) { return Products.GetProductSearchItem(" brandid in (select brandid from t_shopbrand where shopid=" + shopId + " ) "); } public static string GetMarketCategoryHtmlToNav(string marketid) { return GetCategoryHtmlToNav(marketid, "market"); } public static string GetCategoryHtmlToNav() { return GetCategoryHtmlToNav("",""); } public static string GetCategoryHtmlToNav(string value,string type) { StringBuilder sb = new StringBuilder(); DataTable dtCateogry = new DataTable(); if (type == "") { dtCateogry = Products.GetCategoryAndProductCountList(); } if (type == "market") { dtCateogry = Products.GetCategoryAndProductCountList(" brandid in (select brandid from t_shopbrand where shopid in (select shopid from t_marketstoreyshop where marketid=" + value + ") ) "); } int i = 1; DataRow[] parentDr = dtCateogry.Select(" parentid=0"); string qcategoryid = ""; if (ECommon.QuerySearchPCategory.Length > 0) { qcategoryid = ECommon.QuerySearchPCategory; } foreach (DataRow dr in parentDr) { if (dr["id"].ToString()==ECommon.QuerySearchPCategory) { sb.Append("<div class=\"productList221 cur\">"); } else { sb.Append("<div class=\"productList221\">"); } string pname = dr["id"].ToString() == ECommon.QuerySearchPCategory ? "<strong style=\"color:#a20320\">" + dr["title"] + "</strong>" : dr["title"].ToString(); sb.Append("<p><img src=\"" + ECommon.WebResourceUrlToWeb + "/images/product_16.gif\" />" + pname + "</p>"); sb.Append(" <ul>"); foreach (DataRow subDr in dtCateogry.Select(" parentid=" + dr["id"])) { string count = subDr["c"] != null && subDr["c"].ToString() != "" && subDr["c"].ToString() != "0" ? subDr["c"].ToString() : ""; if (ECommon.QuerySearchCategory != "") { if (ECommon.QuerySearchCategory == subDr["id"].ToString()) { if (type == "market") { sb.Append("<li><a href=\"" + string.Format(EnUrls.MarketInfoProductList, value, "", "", "", "", "", "", "", "", "1", "", subDr["parentid"], subDr["id"]) + "\" class=\"bold\"><strong>" + subDr["title"] + " " + count + "</strong></a></li>"); } else { sb.Append("<li><a href=\"" + string.Format(EnUrls.ProductListSearch, "", "", "", "", "", "", "", "", "1", "", subDr["parentid"], subDr["id"]) + "\" class=\"bold\"><strong>" + subDr["title"] + " " + count + "</strong></a></li>"); } } else { if (type == "market") { sb.Append("<li><a href=\"" + string.Format(EnUrls.MarketInfoProductList, value, "", "", "", "", "", "", "", "", "1", "", subDr["parentid"], subDr["id"]) + "\">" + subDr["title"] + " " + count + "</a></li>"); } else { sb.Append("<li><a href=\"" + string.Format(EnUrls.ProductListSearch, "", "", "", "", "", "", "", "", "1", "", subDr["parentid"], subDr["id"]) + "\">" + subDr["title"] + " " + count + "</a></li>"); } } } else { if (type == "market") { sb.Append("<li><a href=\"" + string.Format(EnUrls.MarketInfoProductList, value, "", "", "", "", "", "", "", "", "1", "", subDr["parentid"], subDr["id"]) + "\">" + subDr["title"] + " " + count + "</a></li>"); } else { sb.Append("<li><a href=\"" + string.Format(EnUrls.ProductListSearch, "", "", "", "", "", "", "", "", "1", "", subDr["parentid"], subDr["id"]) + "\">" + subDr["title"] + " " + count + "</a></li>"); } } } sb.Append("</ul></div>"); i++; } return sb.ToString(); } public static string GetCategoryHtmlToIndexNav() { StringBuilder sb = new StringBuilder(); DataTable dtCateogry = dtCateogry = Products.GetCategoryAndProductCountList(); int i = 1; DataRow[] parentDr = dtCateogry.Select(" parentid=0"); string qcategoryid = ""; if (ECommon.QuerySearchPCategory.Length > 0) { qcategoryid = ECommon.QuerySearchPCategory; } foreach (DataRow dr in parentDr) { string pname = dr["id"].ToString() == ECommon.QuerySearchPCategory ? "<strong style=\"color:#a20320\">" + dr["title"] + "</strong>" : dr["title"].ToString(); sb.Append("<dl class=\"dl" + i + "\"><dt class=\"dt" + i + "\">" + pname + "</dt><dd class=\"dd" + i + "\">"); foreach (DataRow subDr in dtCateogry.Select(" parentid=" + dr["id"])) { string count = subDr["c"] != null && subDr["c"].ToString() != "" && subDr["c"].ToString() != "0" ? subDr["c"].ToString() : ""; sb.Append("<a href=\"" + string.Format(EnUrls.ProductListSearch, "", "", "", "", "", "", "", "", "1", "", subDr["parentid"], subDr["id"]) + "\">" + subDr["title"] + " " + count + "</a>"); } sb.Append("</dd></dl>"); i++; } return sb.ToString(); } public static EnWebProduct GetWebProducInfo(string strWhere) { return Products.GetWebProducInfo(strWhere); } public static List<EnWebProduct> GetWebProductList(int PageIndex, int PageSize, string strWhere, string sortkey, string ordertype, out int pageCount) { return Products.GetWebProductList(PageIndex, PageSize, strWhere, sortkey, ordertype, out pageCount); } public static List<EnSearchItem> GetMarketProductSearchTypeItem(string marketid) { return GetProductSearchTypeItem("brandid in (select brandid from t_shopbrand where shopid in (select shopid from t_marketstoreyshop where marketid=" + marketid + "))"); } public static List<EnSearchItem> GetProductSearchTypeItem() { return GetProductSearchTypeItem(""); } public static List<EnSearchItem> GetProductSearchTypeItem(string str) { string strWhere = ""; string categoryItems = ""; if (ECommon.QuerySearchCategory != "") { foreach (string s in ECommon.QuerySearchCategory.Split('_')) { categoryItems += s + ","; } categoryItems = categoryItems.StartsWith(",") ? categoryItems.Substring(1, categoryItems.Length - 1) : categoryItems; categoryItems = categoryItems.EndsWith(",") ? categoryItems.Substring(0, categoryItems.Length - 1) : categoryItems; } if (categoryItems != "") { strWhere += " categoryid in(" + categoryItems + ")"; } if (str != "") { strWhere = strWhere != "" ? strWhere + " and " + str : str; } List<EnSearchItem> list = Products.GetProductSearchTypeItem(strWhere); List<EnSearchItem> templist = new List<EnSearchItem>(); foreach (EnSearchItem item in list) { if (item.type == "type" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchType != "" && ECommon.QuerySearchType.Split('_').Contains(item.value)) { item.isCur = true; continue; } else { if(templist.Find(x=>x.value=="0")==null && item.value=="0") { item.title="其它类型"; } item.isCur = false; templist.Add(item); } } } return templist; } public static List<EnSearchItem> GetSearchItem() { List<EnSearchItem> list = new List<EnSearchItem>(); List<EnSearchItem> itemList = (List<EnSearchItem>)DataCache.GetCache(CacheKey.ProductSearchItemList); if (itemList == null) { itemList = Products.GetProductSearchItem(); DataCache.SetCache(CacheKey.ProductSearchItemList, itemList); } foreach (EnSearchItem item in itemList) { if (item.type == "brand" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchBrand != "" && ECommon.QuerySearchBrand.Split('_').Contains(item.value)) { item.isCur = true; list.Add(item); continue; } else { item.isCur = false; } } if (item.type == "style" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchStyle != "" && ECommon.QuerySearchStyle.Split('_').Contains(item.value)) { item.isCur = true; list.Add(item); continue; } else { item.isCur = false; } } if (item.type == "material" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchMaterial != "" && ECommon.QuerySearchMaterial.Split('_').Contains(item.value)) { item.isCur = true; list.Add(item); continue; } else { item.isCur = false; } } if (item.type == "spread" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchSpread != "" && ECommon.QuerySearchSpread.Split('_').Contains(item.value)) { item.isCur = true; list.Add(item); continue; } else { item.isCur = false; } } if (item.type == "type" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchType != "" && ECommon.QuerySearchType.Split('_').Contains(item.value)) { if (list.Find(x => x.value == "0" && x.type == "type") == null && item.value == "0") { item.title = "其它类型"; item.value = "0"; item.isCur = true; list.Add(item); continue; } if (list.Find(x => x.value == "0" && x.type == "type") != null && item.value == "0") { continue; } item.isCur = true; } else { item.isCur = false; } } list.Add(item); } return list; } public static List<EnSearchItem> GetMarketSearchItem(string marketid) { List<EnSearchItem> list = new List<EnSearchItem>(); List<EnSearchItem> itemList = (List<EnSearchItem>)DataCache.GetCache(string.Format(CacheKey.MarketProductSearchItemTypeList,marketid)); if (itemList == null) { itemList = Products.GetMarketProductSearchItem(marketid); DataCache.SetCache(string.Format(CacheKey.MarketProductSearchItemTypeList, marketid), itemList); } foreach (EnSearchItem item in itemList) { if (item.type == "brand" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchBrand != "" && ECommon.QuerySearchBrand.Split('_').Contains(item.value)) { item.isCur = true; list.Add(item); continue; } else { item.isCur = false; } } if (item.type == "style" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchStyle != "" && ECommon.QuerySearchStyle.Split('_').Contains(item.value)) { item.isCur = true; list.Add(item); continue; } else { item.isCur = false; } } if (item.type == "material" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchMaterial != "" && ECommon.QuerySearchMaterial.Split('_').Contains(item.value)) { item.isCur = true; list.Add(item); continue; } else { item.isCur = false; } } if (item.type == "spread" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchSpread != "" && ECommon.QuerySearchSpread.Split('_').Contains(item.value)) { item.isCur = true; list.Add(item); continue; } else { item.isCur = false; } } if (item.type == "type" && !string.IsNullOrEmpty(item.value)) { if (ECommon.QuerySearchType != "" && ECommon.QuerySearchType.Split('_').Contains(item.value)) { if (list.Find(x => x.value == "0" && x.type == "type") == null && item.value == "0") { item.title = "其它类型"; item.value = "0"; item.isCur = true; list.Add(item); continue; } if (list.Find(x => x.value == "0" && x.type == "type") != null && item.value == "0") { continue; } item.isCur = true; } else { item.isCur = false; } } list.Add(item); } return list; } #region /// <summary> /// 更新对像 /// </summary> public static int EditProduct(EnProduct model) { return Products.EditProduct(model); } /// <summary> /// 得到一个对象实体 /// </summary> public static EnProduct GetProductInfo(string strWhere) { return Products.GetProductInfo(strWhere); } /// <summary> /// 获得数据列表 /// </summary> public static List<EnProduct> GetProductList(int PageIndex, int PageSize, string strWhere, out int pageCount) { return Products.GetProductList(PageIndex, PageSize, strWhere, out pageCount); } ///获取数据列表 public static List<EnProduct> GetProductList(string strWhere, out int pageCount) { return GetProductList(-1, 0, strWhere, out pageCount); } ///获取数据列表 public static List<EnProduct> GetProductList(string strWhere) { int tmpPageCount = 0; return GetProductList(-1, 0, strWhere, out tmpPageCount); } //获取数据列表ToDataTable public static DataTable GetProductListToTable(int PageIndex, int PageSize, string strWhere, out int pageCount) { return DataCommon.GetPageDataTable(TableName.TBProduct, PageIndex, PageSize, strWhere, "id", 1, out pageCount); } ///删除对象 public static int DeleteProduct(int id) { return DeleteProduct(" where id=" + id); } ///删除对象 public static int DeleteProductByIdList(string idList) { return DeleteProduct(" where id in (" + idList + ")"); } ///删除对象 public static int DeleteProduct(string strWhere) { return DataCommon.Delete(TableName.TBProduct, strWhere); } #endregion #region Method-ProductCon /// <summary> /// 更新对像 /// </summary> public static int EditProductCon(EnProductCon model) { return Products.EditProductCon(model); } /// <summary> /// 得到一个对象实体 /// </summary> public static EnProductCon GetProductConInfo(string strWhere) { return Products.GetProductConInfo(strWhere); } /// <summary> /// 获得数据列表 /// </summary> public static List<EnProductCon> GetProductConList(int PageIndex, int PageSize, string strWhere, out int pageCount) { return Products.GetProductConList(PageIndex, PageSize, strWhere, out pageCount); } ///获取数据列表 public static List<EnProductCon> GetProductConList(string strWhere, out int pageCount) { return GetProductConList(-1, 0, strWhere, out pageCount); } ///获取数据列表 public static List<EnProductCon> GetProductConList(string strWhere) { int tmpPageCount = 0; return GetProductConList(-1, 0, strWhere, out tmpPageCount); } ///获取数据列表 public static List<EnProductCon> GetProductConListByProductid(int productid) { int tmpPageCount = 0; return GetProductConList(-1, 0, " where productid=" + productid, out tmpPageCount); } //获取数据列表ToDataTable public static DataTable GetProductConListToTable(int PageIndex, int PageSize, string strWhere, out int pageCount) { return DataCommon.GetPageDataTable(TableName.TBProductCon, PageIndex, PageSize, strWhere, "id", 1, out pageCount); } ///删除对象 public static int DeleteProductCon(int id) { return DeleteProductCon(" where id=" + id); } ///删除对象 public static int DeleteProductConByIdList(string idList) { return DeleteProductCon(" where id in (" + idList + ")"); } ///删除对象 public static int DeleteProductCon(string strWhere) { return DataCommon.Delete(TableName.TBProductCon, strWhere); } #endregion } }
10aaa-10aaa
trunk/TRECommerce/TREC.ECommerce/ECProduct.cs
C#
oos
21,903