Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(ECommerce.Admin.Model.OrgOrganize model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into OrgOrganize(");
            strSql.Append("AreaId,OrgName,OrgAddress,OrgPhone,EnName,OrgFax,OrgType,OrgParentId,AddTime,Status,EndDate,SortNum)");

            strSql.Append(" values (");
            strSql.Append("@AreaId,@OrgName,@OrgAddress,@OrgPhone,@EnName,@OrgFax,@OrgType,@OrgParentId,@AddTime,@Status,@EndDate,@SortNum)");
            strSql.Append(";select @@IDENTITY");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "AreaId", DbType.AnsiString, model.AreaId);
            db.AddInParameter(dbCommand, "OrgName", DbType.String, model.OrgName);
            db.AddInParameter(dbCommand, "OrgAddress", DbType.String, model.OrgAddress);
            db.AddInParameter(dbCommand, "OrgPhone", DbType.AnsiString, model.OrgPhone);
            db.AddInParameter(dbCommand, "EnName", DbType.String, model.EnName);
            db.AddInParameter(dbCommand, "OrgFax", DbType.AnsiString, model.OrgFax);
            db.AddInParameter(dbCommand, "OrgType", DbType.Byte, model.OrgType);
            db.AddInParameter(dbCommand, "OrgParentId", DbType.Int64, model.OrgParentId);
            db.AddInParameter(dbCommand, "AddTime", DbType.DateTime, model.AddTime);
            db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            db.AddInParameter(dbCommand, "EndDate", DbType.DateTime, model.EndDate);
            db.AddInParameter(dbCommand, "SortNum", DbType.Int32, model.SortNum);
            int    result;
            object obj = db.ExecuteScalar(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ECommerce.Admin.Model.OrgOrganize DataRowToModel(DataRow row)
 {
     ECommerce.Admin.Model.OrgOrganize model = new ECommerce.Admin.Model.OrgOrganize();
     if (row != null)
     {
         if (row["OrgId"] != null && row["OrgId"].ToString() != "")
         {
             model.OrgId = Convert.ToInt64(row["OrgId"].ToString());
         }
         if (row["AreaId"] != null)
         {
             model.AreaId = row["AreaId"].ToString();
         }
         if (row["OrgName"] != null)
         {
             model.OrgName = row["OrgName"].ToString();
         }
         if (row["OrgAddress"] != null)
         {
             model.OrgAddress = row["OrgAddress"].ToString();
         }
         if (row["OrgPhone"] != null)
         {
             model.OrgPhone = row["OrgPhone"].ToString();
         }
         if (row["EnName"] != null)
         {
             model.EnName = row["EnName"].ToString();
         }
         if (row["OrgFax"] != null)
         {
             model.OrgFax = row["OrgFax"].ToString();
         }
         if (row["OrgType"] != null && row["OrgType"].ToString() != "")
         {
             model.OrgType = Convert.ToInt32(row["OrgType"].ToString());
         }
         if (row["OrgParentId"] != null && row["OrgParentId"].ToString() != "")
         {
             model.OrgParentId = Convert.ToInt64(row["OrgParentId"].ToString());
         }
         if (row["AddTime"] != null && row["AddTime"].ToString() != "")
         {
             model.AddTime = Convert.ToDateTime(row["AddTime"].ToString());
         }
         if (row["Status"] != null && row["Status"].ToString() != "")
         {
             model.Status = Convert.ToInt32(row["Status"].ToString());
         }
         if (row["EndDate"] != null && row["EndDate"].ToString() != "")
         {
             model.EndDate = Convert.ToDateTime(row["EndDate"].ToString());
         }
         if (row["SortNum"] != null && row["SortNum"].ToString() != "")
         {
             model.SortNum = Convert.ToInt32(row["SortNum"].ToString());
         }
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public ECommerce.Admin.Model.OrgOrganize ReaderBind(IDataReader dataReader)
        {
            ECommerce.Admin.Model.OrgOrganize model = new ECommerce.Admin.Model.OrgOrganize();
            object ojb;

            ojb = dataReader["OrgId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.OrgId = Convert.ToInt64(ojb);
            }
            model.AreaId     = dataReader["AreaId"].ToString();
            model.OrgName    = dataReader["OrgName"].ToString();
            model.OrgAddress = dataReader["OrgAddress"].ToString();
            model.OrgPhone   = dataReader["OrgPhone"].ToString();
            model.EnName     = dataReader["EnName"].ToString();
            model.OrgFax     = dataReader["OrgFax"].ToString();
            ojb = dataReader["OrgType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.OrgType = Convert.ToInt32(ojb);
            }
            ojb = dataReader["OrgParentId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.OrgParentId = Convert.ToInt64(ojb);
            }
            ojb = dataReader["AddTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AddTime = Convert.ToDateTime(ojb);
            }
            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = Convert.ToInt32(ojb);
            }
            ojb = dataReader["EndDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.EndDate = Convert.ToDateTime(ojb);
            }
            ojb = dataReader["SortNum"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.SortNum = Convert.ToInt32(ojb);
            }
            return(model);
        }
Пример #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ECommerce.Admin.Model.OrgOrganize model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update OrgOrganize set ");
            strSql.Append("AreaId=@AreaId,");
            strSql.Append("OrgName=@OrgName,");
            strSql.Append("OrgAddress=@OrgAddress,");
            strSql.Append("OrgPhone=@OrgPhone,");
            strSql.Append("EnName=@EnName,");
            strSql.Append("OrgFax=@OrgFax,");
            strSql.Append("OrgType=@OrgType,");
            strSql.Append("OrgParentId=@OrgParentId,");
            strSql.Append("AddTime=@AddTime,");
            strSql.Append("Status=@Status,");
            strSql.Append("EndDate=@EndDate,");
            strSql.Append("SortNum=@SortNum");
            strSql.Append(" where OrgId=@OrgId ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "OrgId", DbType.Int64, model.OrgId);
            db.AddInParameter(dbCommand, "AreaId", DbType.AnsiString, model.AreaId);
            db.AddInParameter(dbCommand, "OrgName", DbType.String, model.OrgName);
            db.AddInParameter(dbCommand, "OrgAddress", DbType.String, model.OrgAddress);
            db.AddInParameter(dbCommand, "OrgPhone", DbType.AnsiString, model.OrgPhone);
            db.AddInParameter(dbCommand, "EnName", DbType.String, model.EnName);
            db.AddInParameter(dbCommand, "OrgFax", DbType.AnsiString, model.OrgFax);
            db.AddInParameter(dbCommand, "OrgType", DbType.Byte, model.OrgType);
            db.AddInParameter(dbCommand, "OrgParentId", DbType.Int64, model.OrgParentId);
            db.AddInParameter(dbCommand, "AddTime", DbType.DateTime, model.AddTime);
            db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            db.AddInParameter(dbCommand, "EndDate", DbType.DateTime, model.EndDate);
            db.AddInParameter(dbCommand, "SortNum", DbType.Int32, model.SortNum);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ECommerce.Admin.Model.OrgOrganize GetModel(long OrgId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select OrgId,AreaId,OrgName,OrgAddress,OrgPhone,EnName,OrgFax,OrgType,OrgParentId,AddTime,Status,EndDate,SortNum from OrgOrganize ");
            strSql.Append(" where OrgId=@OrgId ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "OrgId", DbType.Int64, OrgId);
            ECommerce.Admin.Model.OrgOrganize model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        protected void btnSub_Click(object sender, EventArgs e)
        {
            var name = txtName.Value.Trim();
            //var size = txtSize.Value.Trim();
            //var area = txtArea.Value.Trim();
            var manager      = txtManager.Value.Trim();
            var managerPhone = txtManPhone.Value.Trim();
            var enddate      = txtEndDate.Value.Trim();
            var enName       = txtEnName.Value.Trim();
            var sortNum      = txtSortNum.Value.Trim();

            if (string.IsNullOrEmpty(name))
            {
                //Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写姓名!');window.parent.$modal.destroy();</script>");
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写分站名称!');</script>");
                return;
            }
            if (string.IsNullOrEmpty(enName))
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写英文名称!');</script>");
                return;
            }
            //if (string.IsNullOrEmpty(size))
            //{
            //    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写规模!');</script>");
            //    return;
            //}
            //if (string.IsNullOrEmpty(area))
            //{
            //    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写面积!');</script>");
            //    return;
            //}
            if (string.IsNullOrEmpty(manager))
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写负责人!');</script>");
                return;
            }
            if (string.IsNullOrEmpty(managerPhone))
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写负责人电话!');</script>");
                return;
            }
            if ((!System.Text.RegularExpressions.Regex.IsMatch(managerPhone, @"^[1]+[3,4,5,8]+\d{9}")) && (!System.Text.RegularExpressions.Regex.IsMatch(managerPhone, @"^(\d{3,4}-)?\d{6,8}$")))
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('负责人电话格式错误,请重新输入!');</script>");
                return;
            }
            if (string.IsNullOrEmpty(enddate))
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请填写合同到期时间!');</script>");
                return;
            }
            //if (string.IsNullOrEmpty(orgId))
            //{
            //    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请选择分公司!');</script>");
            //    return;
            //}
            if (!string.IsNullOrEmpty(Request.QueryString["OrgId"]))
            {
                try
                {
                    List <SqlParameter> parameters = new List <SqlParameter>();
                    var parameter = new SqlParameter("@OrgId", DbType.AnsiString)
                    {
                        Value = Request.QueryString["OrgId"]
                    };
                    parameters.Add(parameter);
                    var str = " oo.[Status]=1 and oo.[OrgId]=@OrgId ";
                    var dt  = _dataDal.GetModel(Convert.ToInt32(Request.QueryString["OrgId"]));
                    if (null == dt)
                    {
                        Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('分站不存在!');</script>");
                        return;
                    }
                    dt.OrgName    = txtName.Value;
                    dt.EnName     = enName;
                    dt.OrgAddress = txtManager.Value;
                    dt.OrgPhone   = txtManPhone.Value;
                    dt.EndDate    = Convert.ToDateTime(enddate);
                    dt.SortNum    = Convert.ToInt32(sortNum);
                    if (_dataDal.Exists(Convert.ToInt32(Request.QueryString["OrgId"]), txtName.Value))
                    {
                        Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('分站已经存在!');</script>");
                        return;
                    }
                    var res = _dataDal.Update(dt);
                    if (res)
                    {
                        Page.ClientScript.RegisterStartupScript(GetType(), "",
                                                                "<script>window.top.$op.location=window.top.$op.location;window.top.$modal.destroy();</script>");
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('更新失败!');window.top.$modal.destroy();</script>");
                    }
                }
                catch (Exception)
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('操作失败!');window.top.$modal.destroy();</script>");
                }
            }
            else
            {
                var model = new ECommerce.Admin.Model.OrgOrganize
                {
                    AreaId     = "61000",
                    AddTime    = DateTime.Now,
                    OrgAddress = manager,
                    OrgPhone   = managerPhone,
                    OrgName    = name,
                    Status     = 1,
                    OrgType    = 1,
                    EndDate    = Convert.ToDateTime(enddate),
                    EnName     = enName,
                    SortNum    = Convert.ToInt32(sortNum)
                };
                if (_dataDal.Exists(0, name))
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('分站已经存在!');</script>");
                    return;
                }
                var resAdd = _dataDal.Add(model);
                if (resAdd > 0)
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "",
                                                            "<script>window.top.$op.location=window.top.$op.location;window.top.$modal.destroy();</script>");
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('新增失败!');window.top.$modal.destroy();</script>");
                }
            }
        }
Пример #7
0
 /// <summary>
 /// 对象实体绑定数据
 /// </summary>
 public ECommerce.Admin.Model.OrgOrganize ReaderBind(IDataReader dataReader)
 {
     ECommerce.Admin.Model.OrgOrganize model=new ECommerce.Admin.Model.OrgOrganize();
     object ojb;
     ojb = dataReader["OrgId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.OrgId=Convert.ToInt64(ojb);
     }
     model.AreaId=dataReader["AreaId"].ToString();
     model.OrgName=dataReader["OrgName"].ToString();
     model.OrgAddress=dataReader["OrgAddress"].ToString();
     model.OrgPhone=dataReader["OrgPhone"].ToString();
     model.EnName=dataReader["EnName"].ToString();
     model.OrgFax=dataReader["OrgFax"].ToString();
     ojb = dataReader["OrgType"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.OrgType=Convert.ToInt32(ojb);
     }
     ojb = dataReader["OrgParentId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.OrgParentId=Convert.ToInt64(ojb);
     }
     ojb = dataReader["AddTime"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.AddTime=Convert.ToDateTime(ojb);
     }
     ojb = dataReader["Status"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.Status=Convert.ToInt32(ojb);
     }
     ojb = dataReader["EndDate"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.EndDate=Convert.ToDateTime(ojb);
     }
     ojb = dataReader["SortNum"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.SortNum=Convert.ToInt32(ojb);
     }
     return model;
 }
Пример #8
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ECommerce.Admin.Model.OrgOrganize DataRowToModel(DataRow row)
 {
     ECommerce.Admin.Model.OrgOrganize model=new ECommerce.Admin.Model.OrgOrganize();
     if (row != null)
     {
         if(row["OrgId"]!=null && row["OrgId"].ToString()!="")
         {
             model.OrgId=Convert.ToInt64(row["OrgId"].ToString());
         }
         if(row["AreaId"]!=null)
         {
             model.AreaId=row["AreaId"].ToString();
         }
         if(row["OrgName"]!=null)
         {
             model.OrgName=row["OrgName"].ToString();
         }
         if(row["OrgAddress"]!=null)
         {
             model.OrgAddress=row["OrgAddress"].ToString();
         }
         if(row["OrgPhone"]!=null)
         {
             model.OrgPhone=row["OrgPhone"].ToString();
         }
         if(row["EnName"]!=null)
         {
             model.EnName=row["EnName"].ToString();
         }
         if(row["OrgFax"]!=null)
         {
             model.OrgFax=row["OrgFax"].ToString();
         }
         if(row["OrgType"]!=null && row["OrgType"].ToString()!="")
         {
             model.OrgType=Convert.ToInt32(row["OrgType"].ToString());
         }
         if(row["OrgParentId"]!=null && row["OrgParentId"].ToString()!="")
         {
             model.OrgParentId=Convert.ToInt64(row["OrgParentId"].ToString());
         }
         if(row["AddTime"]!=null && row["AddTime"].ToString()!="")
         {
             model.AddTime=Convert.ToDateTime(row["AddTime"].ToString());
         }
         if(row["Status"]!=null && row["Status"].ToString()!="")
         {
             model.Status=Convert.ToInt32(row["Status"].ToString());
         }
         if(row["EndDate"]!=null && row["EndDate"].ToString()!="")
         {
             model.EndDate=Convert.ToDateTime(row["EndDate"].ToString());
         }
         if(row["SortNum"]!=null && row["SortNum"].ToString()!="")
         {
             model.SortNum=Convert.ToInt32(row["SortNum"].ToString());
         }
     }
     return model;
 }