コード例 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public IndustryPlatform.Model.SYS_PositionEntity GetModel(string PositionCode)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 PositionCode,PositionName,Remark,IsForbid from Sys_Position ");
            strSql.Append(" where PositionCode=@PositionCode ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PositionCode", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = PositionCode;

            IndustryPlatform.Model.SYS_PositionEntity model = new IndustryPlatform.Model.SYS_PositionEntity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.PositionCode = ds.Tables[0].Rows[0]["PositionCode"].ToString();
                model.PositionName = ds.Tables[0].Rows[0]["PositionName"].ToString();
                model.Remark       = ds.Tables[0].Rows[0]["Remark"].ToString();
                model.IsForbid     = ds.Tables[0].Rows[0]["IsForbid"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        public int Add(SYS_PositionEntity operEntity)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into Sys_Position(");
            strSql.Append("PositionCode,PositionName,Remark,IsForbid)");
            strSql.Append(" values (");
            strSql.Append("@PositionCode,@PositionName,@Remark,@IsForbid)");
            SqlParameter[] parameters = {
                    new SqlParameter("@PositionCode", SqlDbType.VarChar,10),
                    new SqlParameter("@PositionName", SqlDbType.NVarChar,50),
                    new SqlParameter("@Remark", SqlDbType.NVarChar,200),
                    new SqlParameter("@IsForbid", SqlDbType.VarChar,1)};
            parameters[0].Value = operEntity.PositionCode;
            parameters[1].Value = operEntity.PositionName;
            parameters[2].Value = operEntity.Remark;
            parameters[3].Value = operEntity.IsForbid;

            return DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
コード例 #3
0
 public int Add(SYS_PositionEntity operEntity)
 {
     return dal.Add(operEntity);
 }
コード例 #4
0
 public int Update(SYS_PositionEntity operEntity)
 {
     return dal.Update(operEntity);
 }
コード例 #5
0
        public int Update(SYS_PositionEntity operEntity)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update Sys_Position set ");
            strSql.Append("PositionName=@PositionName,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("IsForbid=@IsForbid");
            strSql.Append(" where PositionCode=@PositionCode ");
            SqlParameter[] parameters = {
                    new SqlParameter("@PositionCode", SqlDbType.VarChar,10),
                    new SqlParameter("@PositionName", SqlDbType.NVarChar,50),
                    new SqlParameter("@Remark", SqlDbType.NVarChar,200),
                    new SqlParameter("@IsForbid", SqlDbType.VarChar,1)};
            parameters[0].Value = operEntity.PositionCode;
            parameters[1].Value = operEntity.PositionName;
            parameters[2].Value = operEntity.Remark;
            parameters[3].Value = operEntity.IsForbid;

               return DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
コード例 #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public IndustryPlatform.Model.SYS_PositionEntity GetModel(string PositionCode)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 PositionCode,PositionName,Remark,IsForbid from Sys_Position ");
            strSql.Append(" where PositionCode=@PositionCode ");
            SqlParameter[] parameters = {
                    new SqlParameter("@PositionCode", SqlDbType.VarChar,50)};
            parameters[0].Value = PositionCode;

            IndustryPlatform.Model.SYS_PositionEntity model = new IndustryPlatform.Model.SYS_PositionEntity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                model.PositionCode = ds.Tables[0].Rows[0]["PositionCode"].ToString();
                model.PositionName = ds.Tables[0].Rows[0]["PositionName"].ToString();
                model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                model.IsForbid = ds.Tables[0].Rows[0]["IsForbid"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }
コード例 #7
0
    protected void btn_Save_Click(object sender, ImageClickEventArgs e)
    {
        SYS_PositionEntity Entity = new SYS_PositionEntity();
        if (Request.QueryString["PositonID"] != null)
        {
            Entity = position.GetModel(Request.QueryString["PositonID"].ToString());
        }
        Entity.PositionName = this.txt_PositionName.Text;
        Entity.Remark = this.txt_Remark.Text;
        Entity.IsForbid = "0";

        if (Request.QueryString["PositonID"] != null)//修改保存
        {
            DataSet pDs = position.GetPositionList(" PositionName='" + CommonMethod.RepChar(Entity.PositionName) + "' and PositionCode<>'" + Request.QueryString["PositonID"] .ToString()+ "'");
            if (pDs.Tables[0].Rows.Count > 0)
            {
                MessageBox.Show(this.upDepartAdd, this, "您输入的职位名称已经存在!");
                return;
            }
            if (position.Update(Entity) == 1)
            {
                #region 数据同步
                if (ConfigurationManager.AppSettings["IsSync"] == "1")
                {
                    try
                    {
                        //添加成功,数据同步到各个磅房
                        IndustryPlatform.DBUtility.MsmqManage msm =   MsmqManage.GetMsmq();
                        string strSQL = "update Sys_Position set " +
                                      "[PositionCode] = '" + Entity.PositionCode + "'," +
                                      "[PositionName] = '" + CommonMethod.RepChar(Entity.PositionName) + "'," +
                                      "[Remark] = '" + CommonMethod.RepChar(Entity.Remark) + "'," +
                                      "[IsForbid] = '" + Entity.IsForbid + "' where [PositionCode]='" + Entity.PositionCode + "'";

                        strSQL = msm.AllStation + msm.Prefix + "Sys_Position" + msm.Prefix + msm.EditFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL;
                        msm.AddMsmq(strSQL);
                    }
                    catch
                    { }
                }
                #endregion

                ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('修改成功!'); top.currForm.close();", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('修改失败!');", true);
            }
        }
        else//新增保存
        {
            DataSet pDs = position.GetPositionList(" PositionName='" + CommonMethod.RepChar(Entity.PositionName) + "'");
            if (pDs.Tables[0].Rows.Count > 0)
            {
                MessageBox.Show(this.upDepartAdd, this, "您输入的职位名称已经存在!");
                return;
            }
            lock (this)
            {
                Entity.PositionCode = DbHelperSQL.GetBaseMaxID("PositionCode", "SYS_Position", " PositionCode<>'0'");
                Entity.IsForbid = "0";
                if (position.Add(Entity) == 1)
                {
                    #region 数据同步
                    if (ConfigurationManager.AppSettings["IsSync"] == "1")
                    {
                        try
                        {
                            //添加成功,数据同步到各个磅房
                            IndustryPlatform.DBUtility.MsmqManage msm =  MsmqManage.GetMsmq();
                            string strSQL = "INSERT INTO Sys_Position ( " +
                                          "[PositionCode] ," +
                                          "[PositionName] ," +
                                          "[Remark] ," +
                                          "[IsForbid] ) VALUES ('" + Entity.PositionCode + "','" + CommonMethod.RepChar(Entity.PositionName) + "','" + CommonMethod.RepChar(Entity.Remark) + "','" + Entity.IsForbid + "')";
                            strSQL = msm.AllStation + msm.Prefix + "Sys_Position" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL;
                            msm.AddMsmq(strSQL);
                        }
                        catch
                        { }
                    }
                    #endregion

                    SetText();
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('添加成功!');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('添加失败!');", true);
                }
            }
        }
    }
コード例 #8
0
 /// <summary>
 /// 初始化数据
 /// </summary>
 void SetText()
 {
     if (Request.QueryString["PositonID"] != null)
     {
         Emtity = position.GetModel(Request.QueryString["PositonID"].ToString());
         if (Emtity != null)
         {
             this.txt_PositionName.Text = Emtity.PositionName;
             this.txt_Remark.Text = Emtity.Remark;
             //this.h_orgID.Value = Emtity.orgID.ToString();
             //this.ddl_IsForbid.SelectedValue = Emtity.IsForbid;
             // this.txt_orgName.Text = position.Getresult("orgName", "SYS_Organization", " orgID=" + Emtity.orgID + "");
         }
     }
     else
     {
         this.txt_PositionName.Text = "";
         this.txt_Remark.Text = "";
     }
 }