Ejemplo n.º 1
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private PayMethodDts[] EntityDtsGet()
        {
            int index = GetDataCompleteNum();

            PayMethodDts[] entitydts = new PayMethodDts[index];
            index = 0;
            for (int i = 0; i < gridView1.RowCount; i++)
            {
                if (CheckDataCompleteDts(i))
                {
                    entitydts[index]        = new PayMethodDts();
                    entitydts[index].MainID = HTDataID;
                    entitydts[index].Seq    = i + 1;
                    entitydts[index].SelectByID();

                    entitydts[index].Name           = SysConvert.ToString(gridView1.GetRowCellValue(i, "Name"));
                    entitydts[index].PayPer         = SysConvert.ToDecimal(gridView1.GetRowCellValue(i, "PayPer"));
                    entitydts[index].PayDateTypeInt = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "PayDateTypeInt"));
                    entitydts[index].DelayDayNum    = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "DelayDayNum"));
                    entitydts[index].Remark         = SysConvert.ToString(gridView1.GetRowCellValue(i, "Remark"));
                    entitydts[index].PayStepTypeID  = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "PayStepTypeID"));

                    index++;
                }
            }
            return(entitydts);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Delete(BaseEntity p_Entity)
        {
            try
            {
                PayMethodDts MasterEntity = (PayMethodDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //删除主表数据
                string Sql = "";
                Sql = "DELETE FROM Data_PayMethodDts WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID);
                //执行
                int AffectedRows = 0;
                if (!this.sqlTransFlag)
                {
                    AffectedRows = this.ExecuteNonQuery(Sql);
                }
                else
                {
                    AffectedRows = sqlTrans.ExecuteNonQuery(Sql);
                }

                return(AffectedRows);
            }
            catch (BaseException E)
            {
                throw new BaseException(E.Message, E);
            }
            catch (Exception E)
            {
                throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBDelete), E);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 检验字段值是否已存在
        /// </summary>
        /// <param name="p_TableName">表名</param>
        /// <param name="p_FieldName">字段名</param>
        /// <param name="p_FieldValue">字段值</param>
        /// <param name="p_KeyField">主键(只考虑主键为ID的情况)</param>
        /// <param name="p_KeyValue">主键值</param>
        /// <param name="p_sqlTrans"></param>
        /// <returns></returns>
        private bool CheckFieldValueIsExist(BaseEntity p_BE, string p_FieldName, string p_FieldValue, IDBTransAccess p_sqlTrans)
        {
            PayMethodDts entity = (PayMethodDts)p_BE;
            bool         ret    = false;
            string       sql    = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, PayMethodDts.TableName, SysString.ToDBString(p_FieldValue), "ID", entity.ID);
            DataTable    dt     = p_sqlTrans.Fill(sql);

            if (dt.Rows.Count != 0)
            {
                ret = true;
            }

            return(ret);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 新增(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RAdd(BaseEntity p_BE, BaseEntity[] p_BE2, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                PayMethod entity = (PayMethod)p_BE;
                string    sql    = "SELECT * FROM Data_PayMethod WHERE ID=" + SysString.ToDBString(entity.ID);
                DataTable dt     = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("ID已存在,请检查后重新输入!");
                }
                sql = "SELECT * FROM Data_PayMethod WHERE Code=" + SysString.ToDBString(entity.Code);
                dt  = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("付款方式编码已存在,请检查后重新输入!");
                }
                sql = "SELECT * FROM Data_PayMethod WHERE Name=" + SysString.ToDBString(entity.Name);
                dt  = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("付款方式的名称已存在,请检查后重新输入!");
                }
                PayMethodCtl control = new PayMethodCtl(sqlTrans);
                //entity.ID=(int)EntityIDTable.GetID((long)SysEntity.Data_PayMethod,sqlTrans);
                control.AddNew(entity);

                for (int i = 0; i < p_BE2.Length; i++)
                {
                    PayMethodDtsRule rule      = new PayMethodDtsRule();
                    PayMethodDts     entityDts = (PayMethodDts)p_BE2[i];
                    entityDts.MainID = entity.ID;
                    entityDts.Seq    = i + 1;
                    rule.RAdd(entityDts, sqlTrans);
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="p_BE">要删除的实体</param>
 /// <param name="sqlTrans">事务类</param>
 public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans)
 {
     try
     {
         this.CheckCorrect(p_BE);
         PayMethodDts    entity  = (PayMethodDts)p_BE;
         PayMethodDtsCtl control = new PayMethodDtsCtl(sqlTrans);
         control.Delete(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 新增(传入事务处理)
 /// </summary>
 /// <param name="p_BE">要新增的实体</param>
 /// <param name="sqlTrans">事务类</param>
 public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans)
 {
     try
     {
         this.CheckCorrect(p_BE);
         PayMethodDts    entity  = (PayMethodDts)p_BE;
         PayMethodDtsCtl control = new PayMethodDtsCtl(sqlTrans);
         entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Data_PayMethodDts, sqlTrans);
         control.AddNew(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_BE">要修改的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RUpdate(BaseEntity p_BE, BaseEntity[] p_BE2, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                PayMethod entity = (PayMethod)p_BE;
                string    sql    = "SELECT * FROM Data_PayMethod WHERE Code=" + SysString.ToDBString(entity.Code) + " AND ID<>" + entity.ID;
                DataTable dt     = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("付款方式编码已存在,请检查后重新输入!");
                }
                sql = "SELECT * FROM Data_PayMethod WHERE Name=" + SysString.ToDBString(entity.Name) + " AND ID<>" + entity.ID;
                dt  = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("付款方式的名称已存在,请检查后重新输入!");
                }
                PayMethodCtl control = new PayMethodCtl(sqlTrans);
                control.Update(entity);

                sql = "DELETE Data_PayMethodDts WHERE MainID=" + SysString.ToDBString(entity.ID);
                sqlTrans.ExecuteNonQuery(sql);

                for (int i = 0; i < p_BE2.Length; i++)
                {
                    PayMethodDtsRule rule      = new PayMethodDtsRule();
                    PayMethodDts     entityDts = (PayMethodDts)p_BE2[i];
                    entityDts.MainID = entity.ID;
                    entityDts.Seq    = i + 1;
                    rule.RAdd(entityDts, sqlTrans);
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// 检查将要操作的数据是否符合业务规则
 /// </summary>
 /// <param name="p_BE"></param>
 private void CheckCorrect(BaseEntity p_BE)
 {
     PayMethodDts entity = (PayMethodDts)p_BE;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                PayMethodDts MasterEntity = (PayMethodDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //新增主表数据
                StringBuilder MasterField = new StringBuilder();
                StringBuilder MasterValue = new StringBuilder();
                MasterField.Append("INSERT INTO Data_PayMethodDts(");
                MasterValue.Append(" VALUES(");
                MasterField.Append("ID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ",");
                MasterField.Append("MainID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.MainID) + ",");
                MasterField.Append("Seq" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Seq) + ",");
                MasterField.Append("Name" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Name) + ",");
                MasterField.Append("PayPer" + ",");
                if (MasterEntity.PayPer != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.PayPer) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("PayDateTypeInt" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.PayDateTypeInt) + ",");
                MasterField.Append("DelayDayNum" + ",");
                if (MasterEntity.DelayDayNum != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.DelayDayNum) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("Remark" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ",");
                MasterField.Append("PayStepTypeID" + ")");
                MasterValue.Append(SysString.ToDBString(MasterEntity.PayStepTypeID) + ")");



                //执行
                int AffectedRows = 0;
                if (!this.sqlTransFlag)
                {
                    AffectedRows = this.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString());
                }
                else
                {
                    AffectedRows = sqlTrans.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString());
                }
                return(AffectedRows);
            }
            catch (BaseException E)
            {
                throw new BaseException(E.Message, E);
            }
            catch (Exception E)
            {
                throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBInsert), E);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Update(BaseEntity p_Entity)
        {
            try
            {
                PayMethodDts MasterEntity = (PayMethodDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //更新主表数据
                StringBuilder UpdateBuilder = new StringBuilder();
                UpdateBuilder.Append("UPDATE Data_PayMethodDts SET ");
                UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ",");
                UpdateBuilder.Append(" MainID=" + SysString.ToDBString(MasterEntity.MainID) + ",");
                UpdateBuilder.Append(" Seq=" + SysString.ToDBString(MasterEntity.Seq) + ",");
                UpdateBuilder.Append(" Name=" + SysString.ToDBString(MasterEntity.Name) + ",");

                if (MasterEntity.PayPer != 0)
                {
                    UpdateBuilder.Append(" PayPer=" + SysString.ToDBString(MasterEntity.PayPer) + ",");
                }
                else
                {
                    UpdateBuilder.Append(" PayPer=null,");
                }

                UpdateBuilder.Append(" PayDateTypeInt=" + SysString.ToDBString(MasterEntity.PayDateTypeInt) + ",");

                if (MasterEntity.DelayDayNum != 0)
                {
                    UpdateBuilder.Append(" DelayDayNum=" + SysString.ToDBString(MasterEntity.DelayDayNum) + ",");
                }
                else
                {
                    UpdateBuilder.Append(" DelayDayNum=null,");
                }

                UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ",");
                UpdateBuilder.Append(" PayStepTypeID=" + SysString.ToDBString(MasterEntity.PayStepTypeID));

                UpdateBuilder.Append(" WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID));



                //执行
                int AffectedRows = 0;
                if (!this.sqlTransFlag)
                {
                    AffectedRows = this.ExecuteNonQuery(UpdateBuilder.ToString());
                }
                else
                {
                    AffectedRows = sqlTrans.ExecuteNonQuery(UpdateBuilder.ToString());
                }
                return(AffectedRows);
            }
            catch (BaseException E)
            {
                throw new BaseException(E.Message, E);
            }
            catch (Exception E)
            {
                throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBUpdate), E);
            }
        }