Example #1
0
        public ExhibitorEntity GetExhibitorEntity(int exhibitorID)
        {
            ExhibitorEntity item = null;
            DataSet         ds   = dao.GetExhibitorEntityDataSet(exhibitorID);

            if (ds != null && ds.Tables.Count == 2)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    item = this.GetConsoleExhibitorEntity(ds.Tables[0].Rows[0], ds.Tables[1]);
                }
            }

            return(item);
        }
Example #2
0
        /// <summary>
        /// 将后台的展商实例化
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="table_location"></param>
        /// <returns></returns>
        public List <ExhibitorEntity> GetConsoleExhibitorEntityList(DataTable dt, DataTable table_location)
        {
            List <ExhibitorEntity> list = null;

            if (dt != null)
            {
                list = new List <ExhibitorEntity>();

                foreach (DataRow dr in dt.Rows)
                {
                    ExhibitorEntity item = this.GetConsoleExhibitorEntity(dr, table_location);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }

            return(list);
        }
        private void InitExhibitor()
        {
            BCtrl_Exhibitor bll = new BCtrl_Exhibitor();

            item = bll.GetExhibitorEntity(id);
            if (item != null)
            {
                this.sel_exhibition.Value    = item.ExhibitionID.ToString();
                this.txt_exhibitorname.Value = item.ExhibitorName;
                if (item.ExhibitorLocationList != null)
                {
                    string tmploc = "";
                    foreach (ExhibitorLocationEntity loc in item.ExhibitorLocationList)
                    {
                        tmploc += loc.ExhibitorLocation + "\n";
                    }
                    this.txt_exhibitorlocations.Value = tmploc;
                }

                this.chk_ishadbooklist.Checked = item.IsHadBookList;
                this.chk_statetype.Checked     = item.StateTypeID == 1;
                this.hid_eid.Value             = item.ExhibitorID.ToString();
            }
        }
        public string ExhibitorEdit(HttpContext context)
        {
            int    id     = 0;
            int    eid    = 0;
            string ename  = "";
            string eloc   = "";
            bool   ebook  = false;
            bool   estate = false;

            //De(context.Request.Form["rdate"])
            if (int.TryParse(context.Request.Form["eid"], out eid) &&
                !string.IsNullOrEmpty(context.Request.Form["ename"]))
            {
                int.TryParse(context.Request.Form["id"], out id);
                bool.TryParse(context.Request.Form["ebook"], out ebook);
                bool.TryParse(context.Request.Form["estate"], out estate);
                ename = De(context.Request.Form["ename"]);
                eloc  = De(context.Request.Form["eloc"]);

                BCtrl_Exhibitor bll = new BCtrl_Exhibitor();

                ExhibitorEntity item = new ExhibitorEntity()
                {
                    ExhibitionID          = eid,
                    ExhibitorName         = ename,
                    ExhibitorPinYin       = Utils.Hz2Py.GetWholePinyin(ename),
                    IsHadBookList         = ebook,
                    OBCustomerID          = 0,
                    OBCustomerTypeID      = 0,
                    rowId                 = 0,
                    StateTypeID           = estate ? 1 : 0,
                    CreateTime            = DateTime.Now,
                    CreateUserID          = this.CurrentAdmin.Sys_UserID,
                    ExhibitorID           = id,
                    ExhibitorLocationList = new List <ExhibitorLocationEntity>()
                };

                string[] elocs = eloc.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                if (elocs != null)
                {
                    foreach (string loc in elocs)
                    {
                        ExhibitorLocationEntity locEntity = new ExhibitorLocationEntity()
                        {
                            ExhibitorID             = id,
                            CreateTime              = DateTime.Now,
                            CreateUserID            = this.CurrentAdmin.Sys_UserID,
                            ExhibitiorLocationOrder = 1000,
                            ExhibitorLocation       = loc,
                            ExhibitorLocationID     = 0,
                            StateTypeID             = estate ? 1 : 0
                        };
                        item.ExhibitorLocationList.Add(locEntity);
                    }
                }

                if (id > 0)
                {
                    if (bll.Update_Exhibitor(item))
                    {
                        return(string.Format(G.JSON_OK_STATE_STRING, "修改成功"));
                    }
                    else
                    {
                        return(string.Format(G.JSON_ERROR_STATE_STRING, "修改失败"));
                    }
                }
                else
                {
                    if (bll.Add_Exhibitor(item) > 0)
                    {
                        return(string.Format(G.JSON_OK_STATE_STRING, "添加成功"));
                    }
                    else
                    {
                        return(string.Format(G.JSON_ERROR_STATE_STRING, "添加失败"));
                    }
                }
            }
            else
            {
                return(string.Format(G.JSON_ERROR_STATE_STRING, "参数获取失败"));
            }
        }
Example #5
0
 /// <summary>
 /// 更新展商
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Update_Exhibitor(ExhibitorEntity item)
 {
     return(dao.Update_Exhibitor(item));
 }
Example #6
0
 /// <summary>
 /// 添加新展商
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public int Add_Exhibitor(ExhibitorEntity item)
 {
     return(dao.Add_Exhibitor(item));
 }
Example #7
0
        private ExhibitorEntity GetConsoleExhibitorEntity(DataRow dr, DataTable table_location)
        {
            ExhibitorEntity item = null;

            if (dr != null)
            {
                item = new ExhibitorEntity();
                if (dr["ExhibitorID"] != null && dr["ExhibitorID"].ToString() != "")
                {
                    item.ExhibitorID = int.Parse(dr["ExhibitorID"].ToString());
                }
                if (dr["ExhibitionID"] != null && dr["ExhibitionID"].ToString() != "")
                {
                    item.ExhibitionID = int.Parse(dr["ExhibitionID"].ToString());
                }
                if (dr["ExhibitorName"] != null)
                {
                    item.ExhibitorName = dr["ExhibitorName"].ToString();
                }
                if (dr["ExhibitorPinYin"] != null)
                {
                    item.ExhibitorPinYin = dr["ExhibitorPinYin"].ToString();
                }
                if (dr["OBCustomerID"] != null && dr["OBCustomerID"].ToString() != "")
                {
                    item.OBCustomerID = int.Parse(dr["OBCustomerID"].ToString());
                }
                if (dr["OBCustomerTypeID"] != null && dr["OBCustomerTypeID"].ToString() != "")
                {
                    item.OBCustomerTypeID = int.Parse(dr["OBCustomerTypeID"].ToString());
                }
                if (dr["IsHadBookList"] != null && dr["IsHadBookList"].ToString() != "")
                {
                    if ((dr["IsHadBookList"].ToString() == "1") || (dr["IsHadBookList"].ToString().ToLower() == "true"))
                    {
                        item.IsHadBookList = true;
                    }
                    else
                    {
                        item.IsHadBookList = false;
                    }
                }
                if (dr["StateTypeID"] != null && dr["StateTypeID"].ToString() != "")
                {
                    item.StateTypeID = int.Parse(dr["StateTypeID"].ToString());
                }
                if (dr["CreateUserID"] != null)
                {
                    item.CreateUserID = dr["CreateUserID"].ToString();
                }
                if (dr["CreateTime"] != null && dr["CreateTime"].ToString() != "")
                {
                    item.CreateTime = DateTime.Parse(dr["CreateTime"].ToString());
                }
                if (dr["rowId"] != null && dr["rowId"].ToString() != "")
                {
                    item.rowId = int.Parse(dr["rowId"].ToString());
                }

                if (table_location != null)
                {
                    DataRow[] drs = table_location.Select(string.Format(" ExhibitorID = {0} ", item.ExhibitorID.ToShort()));
                    if (drs != null)
                    {
                        item.ExhibitorLocationList = new List <ExhibitorLocationEntity>();
                        foreach (DataRow drl in drs)
                        {
                            ExhibitorLocationEntity locationEntity = this.GetConsoleExhibitorLocationEntity(drl);
                            if (locationEntity != null)
                            {
                                item.ExhibitorLocationList.Add(locationEntity);
                            }
                        }
                    }
                }
            }

            return(item);
        }
Example #8
0
        /// <summary>
        /// 更新展商
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool Update_Exhibitor(ExhibitorEntity item)
        {
            bool           returnValue = false;
            SqlTransaction trans       = null;

            using (SqlConnection con = new SqlConnection(SQlHelper.MyConnectStr))
            {
                try
                {
                    con.Open();
                    trans = con.BeginTransaction();
                    //清除位置记录
                    StringBuilder strDelLocSql = new StringBuilder();
                    strDelLocSql.AppendFormat(@"DELETE FROM dbo.M_Exhibition_Exhibitor_Location WHERE ExhibitorID = {0}", item.ExhibitorID.ToString());
                    SQlHelper.ExecuteNonQuery(trans, CommandType.Text, strDelLocSql.ToString(), null);

                    StringBuilder strSql = new StringBuilder();
                    strSql.Append("update M_Exhibition_Exhibitors set ");
                    strSql.Append("ExhibitionID=@ExhibitionID,");
                    strSql.Append("ExhibitorName=@ExhibitorName,");
                    strSql.Append("ExhibitorPinYin=@ExhibitorPinYin,");
                    strSql.Append("OBCustomerID=@OBCustomerID,");
                    strSql.Append("OBCustomerTypeID=@OBCustomerTypeID,");
                    strSql.Append("IsHadBookList=@IsHadBookList,");
                    strSql.Append("StateTypeID=@StateTypeID");
                    strSql.Append(" where ExhibitorID=@ExhibitorID");
                    SqlParameter[] parameters =
                    {
                        new SqlParameter("@ExhibitionID",     SqlDbType.Int,        4),
                        new SqlParameter("@ExhibitorName",    SqlDbType.NVarChar,  50),
                        new SqlParameter("@ExhibitorPinYin",  SqlDbType.NVarChar, 500),
                        new SqlParameter("@OBCustomerID",     SqlDbType.Int,        4),
                        new SqlParameter("@OBCustomerTypeID", SqlDbType.Int,        4),
                        new SqlParameter("@IsHadBookList",    SqlDbType.Bit,        1),
                        new SqlParameter("@StateTypeID",      SqlDbType.Int,        4),
                        new SqlParameter("@ExhibitorID",      SqlDbType.Int, 4)
                    };
                    parameters[0].Value = item.ExhibitionID;
                    parameters[1].Value = item.ExhibitorName;
                    parameters[2].Value = item.ExhibitorPinYin;
                    parameters[3].Value = item.OBCustomerID;
                    parameters[4].Value = item.OBCustomerTypeID;
                    parameters[5].Value = item.IsHadBookList;
                    parameters[6].Value = item.StateTypeID;
                    parameters[7].Value = item.ExhibitorID;

                    SQlHelper.ExecuteNonQuery(trans, CommandType.Text, strSql.ToString(), parameters);

                    //写入位置
                    if (item.ExhibitorLocationList != null)
                    {
                        foreach (ExhibitorLocationEntity _loc in item.ExhibitorLocationList)
                        {
                            StringBuilder strLocSql = new StringBuilder();
                            strLocSql.Append("insert into M_Exhibition_Exhibitor_Location(");
                            strLocSql.Append("ExhibitorID,ExhibitorLocation,StateTypeID,ExhibitiorLocationOrder,CreateUserID,CreateTime)");
                            strLocSql.Append(" values (");
                            strLocSql.Append("@ExhibitorID,@ExhibitorLocation,@StateTypeID,@ExhibitiorLocationOrder,@CreateUserID,@CreateTime)");
                            strLocSql.Append(";select @@IDENTITY");
                            SqlParameter[] locparameters =
                            {
                                new SqlParameter("@ExhibitorID",             SqlDbType.Int,        4),
                                new SqlParameter("@ExhibitorLocation",       SqlDbType.NVarChar, 100),
                                new SqlParameter("@StateTypeID",             SqlDbType.Int,        4),
                                new SqlParameter("@ExhibitiorLocationOrder", SqlDbType.Int,        4),
                                new SqlParameter("@CreateUserID",            SqlDbType.VarChar,   20),
                                new SqlParameter("@CreateTime",              SqlDbType.DateTime)
                            };
                            locparameters[0].Value = item.ExhibitorID;
                            locparameters[1].Value = _loc.ExhibitorLocation;
                            locparameters[2].Value = _loc.StateTypeID;
                            locparameters[3].Value = _loc.ExhibitiorLocationOrder;
                            locparameters[4].Value = _loc.CreateUserID;
                            locparameters[5].Value = _loc.CreateTime;

                            SQlHelper.ExecuteNonQuery(trans, CommandType.Text, strLocSql.ToString(), locparameters);
                        }

                        trans.Commit();
                        returnValue = true;
                    }
                }
                catch (Exception ex)
                {
                    if (trans != null)
                    {
                        trans.Rollback();
                    }
                    LogUtil.WriteLog(ex);
                }
            }

            return(returnValue);
        }
Example #9
0
        /// <summary>
        /// 添加新展商
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public int Add_Exhibitor(ExhibitorEntity item)
        {
            int returnValue = 0;

            SqlTransaction trans = null;

            using (SqlConnection con = new SqlConnection(SQlHelper.MyConnectStr))
            {
                try
                {
                    con.Open();
                    trans = con.BeginTransaction();

                    StringBuilder strSql = new StringBuilder();
                    strSql.Append("insert into M_Exhibition_Exhibitors(");
                    strSql.Append("ExhibitionID,ExhibitorName,ExhibitorPinYin,OBCustomerID,OBCustomerTypeID,IsHadBookList,StateTypeID,CreateUserID,CreateTime)");
                    strSql.Append(" values (");
                    strSql.Append("@ExhibitionID,@ExhibitorName,@ExhibitorPinYin,@OBCustomerID,@OBCustomerTypeID,@IsHadBookList,@StateTypeID,@CreateUserID,@CreateTime)");
                    strSql.Append(";select @@IDENTITY");
                    SqlParameter[] parameters =
                    {
                        new SqlParameter("@ExhibitionID",     SqlDbType.Int,        4),
                        new SqlParameter("@ExhibitorName",    SqlDbType.NVarChar,  50),
                        new SqlParameter("@ExhibitorPinYin",  SqlDbType.NVarChar, 500),
                        new SqlParameter("@OBCustomerID",     SqlDbType.Int,        4),
                        new SqlParameter("@OBCustomerTypeID", SqlDbType.Int,        4),
                        new SqlParameter("@IsHadBookList",    SqlDbType.Bit,        1),
                        new SqlParameter("@StateTypeID",      SqlDbType.Int,        4),
                        new SqlParameter("@CreateUserID",     SqlDbType.VarChar,   20),
                        new SqlParameter("@CreateTime",       SqlDbType.DateTime)
                    };
                    parameters[0].Value = item.ExhibitionID;
                    parameters[1].Value = item.ExhibitorName;
                    parameters[2].Value = item.ExhibitorPinYin;
                    parameters[3].Value = item.OBCustomerID;
                    parameters[4].Value = item.OBCustomerTypeID;
                    parameters[5].Value = item.IsHadBookList;
                    parameters[6].Value = item.StateTypeID;
                    parameters[7].Value = item.CreateUserID;
                    parameters[8].Value = item.CreateTime;

                    object objrec = SQlHelper.ExecuteScalar(trans, CommandType.Text, strSql.ToString(), parameters);
                    if (objrec != null)
                    {
                        //写入位置
                        if (item.ExhibitorLocationList != null)
                        {
                            foreach (ExhibitorLocationEntity _loc in item.ExhibitorLocationList)
                            {
                                StringBuilder strLocSql = new StringBuilder();
                                strLocSql.Append("insert into M_Exhibition_Exhibitor_Location(");
                                strLocSql.Append("ExhibitorID,ExhibitorLocation,StateTypeID,ExhibitiorLocationOrder,CreateUserID,CreateTime)");
                                strLocSql.Append(" values (");
                                strLocSql.Append("@ExhibitorID,@ExhibitorLocation,@StateTypeID,@ExhibitiorLocationOrder,@CreateUserID,@CreateTime)");
                                strLocSql.Append(";select @@IDENTITY");
                                SqlParameter[] locparameters =
                                {
                                    new SqlParameter("@ExhibitorID",             SqlDbType.Int,        4),
                                    new SqlParameter("@ExhibitorLocation",       SqlDbType.NVarChar, 100),
                                    new SqlParameter("@StateTypeID",             SqlDbType.Int,        4),
                                    new SqlParameter("@ExhibitiorLocationOrder", SqlDbType.Int,        4),
                                    new SqlParameter("@CreateUserID",            SqlDbType.VarChar,   20),
                                    new SqlParameter("@CreateTime",              SqlDbType.DateTime)
                                };
                                locparameters[0].Value = int.Parse(objrec.ToString());
                                locparameters[1].Value = _loc.ExhibitorLocation;
                                locparameters[2].Value = _loc.StateTypeID;
                                locparameters[3].Value = _loc.ExhibitiorLocationOrder;
                                locparameters[4].Value = _loc.CreateUserID;
                                locparameters[5].Value = _loc.CreateTime;

                                SQlHelper.ExecuteNonQuery(trans, CommandType.Text, strLocSql.ToString(), locparameters);
                            }
                        }

                        trans.Commit();
                        returnValue = int.Parse(objrec.ToString());
                    }
                }
                catch (Exception ex)
                {
                    if (trans != null)
                    {
                        trans.Rollback();
                    }
                    LogUtil.WriteLog(ex);
                }
            }

            return(returnValue);
        }