Ejemplo n.º 1
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (this.IsPass())
     {
         OAOfficeResPersonalApplicationDetail data = this.GetData();
         if (this.OperateType == "add")
         {
             int num = this.amAction.Add(data);
             if (num > 0)
             {
                 this.Page.RegisterStartupScript("", "<script>alert('添加成功!');returnValue=true;window.close();</script>");
             }
             else
             {
                 this.Page.RegisterStartupScript("", "<script>alert('没有相关数据可添加!');</script>");
             }
         }
         if (this.OperateType == "upd")
         {
             int num = this.amAction.Update(data);
             if (num > 0)
             {
                 this.Page.RegisterStartupScript("", "<script>alert('修改成功!');returnValue=true;window.close();</script>");
                 return;
             }
             this.Page.RegisterStartupScript("", "<script>alert('没有相关数据可更新!');</script>");
             return;
         }
     }
     else
     {
         this.Page.RegisterStartupScript("", "<script>alert('超出定额,不允许保存!');</script>");
     }
 }
        public OAOfficeResPersonalApplicationDetail GetModel(int PADRecordID)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("select *  ");
            builder.Append(" PADRecordID,PARecordID,MaterialID,ApplyNumber,IsPass ");
            builder.Append(" from OA_OfficeRes_PersonalApplicationDetail ");
            builder.Append(" where PADRecordID=" + PADRecordID);
            OAOfficeResPersonalApplicationDetail detail = new OAOfficeResPersonalApplicationDetail();
            DataSet set = publicDbOpClass.DataSetQuary(builder.ToString());

            if (set.Tables[0].Rows.Count <= 0)
            {
                return(null);
            }
            if (set.Tables[0].Rows[0]["PADRecordID"].ToString() != "")
            {
                detail.PADRecordID = int.Parse(set.Tables[0].Rows[0]["PADRecordID"].ToString());
            }
            if (set.Tables[0].Rows[0]["PARecordID"].ToString() != "")
            {
                detail.PARecordID = int.Parse(set.Tables[0].Rows[0]["PARecordID"].ToString());
            }
            if (set.Tables[0].Rows[0]["MaterialID"].ToString() != "")
            {
                detail.MaterialID = int.Parse(set.Tables[0].Rows[0]["MaterialID"].ToString());
            }
            if (set.Tables[0].Rows[0]["ApplyNumber"].ToString() != "")
            {
                detail.ApplyNumber = int.Parse(set.Tables[0].Rows[0]["ApplyNumber"].ToString());
            }
            detail.IsPass = set.Tables[0].Rows[0]["IsPass"].ToString();
            return(detail);
        }
        public int Update(OAOfficeResPersonalApplicationDetail model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update OA_OfficeRes_PersonalApplicationDetail set ");
            builder.Append("ApplyNumber=" + model.ApplyNumber);
            builder.Append(" where PADRecordID=" + model.PADRecordID);
            return(publicDbOpClass.ExecSqlString(builder.ToString()));
        }
        public int Add(OAOfficeResPersonalApplicationDetail model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into OA_OfficeRes_PersonalApplicationDetail(");
            builder.Append("PARecordID,MaterialID,ApplyNumber,IsPass");
            builder.Append(")");
            builder.Append(" values (");
            builder.Append(model.PARecordID + ",");
            builder.Append(model.MaterialID + ",");
            builder.Append(model.ApplyNumber + ",");
            builder.Append("'" + model.IsPass + "'");
            builder.Append(")");
            return(publicDbOpClass.ExecSqlString(builder.ToString()));
        }