/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); SaleGroup entity = (SaleGroup)p_BE; string sql = string.Empty; sql = "select 1 from Enum_SaleGroup where Code = " + SysString.ToDBString(entity.Code); DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count != 0) { throw new Exception("该编码已存在,请重新输入"); } sql = "select 1 from Enum_SaleGroup where Name = " + SysString.ToDBString(entity.Name); DataTable dt1 = sqlTrans.Fill(sql); if (dt1.Rows.Count != 0) { throw new Exception("该组别已存在,请重新输入"); } SaleGroupCtl control = new SaleGroupCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Enum_SaleGroup, sqlTrans); control.AddNew(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 修改 /// </summary> /// <param name="p_BE">要修改的实体</param> /// <param name="sqlTrans">事务类</param> public void RUpdate(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); SaleGroup entity = (SaleGroup)p_BE; string sql = string.Empty; sql = "select 1 from Enum_SaleGroup where Code =" + SysString.ToDBString(entity.Code); sql += "AND ID<>" + entity.ID; DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count != 0) { throw new Exception("该编码已存在,请重新输入"); } SaleGroupCtl control = new SaleGroupCtl(sqlTrans); control.Update(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private SaleGroup EntityGet() { SaleGroup entity = new SaleGroup(); entity.ID = HTDataID; entity.SelectByID(); entity.Code = SysConvert.ToInt32(txtCode.Text.Trim()); entity.Name = SysConvert.ToString(txtName.Text.Trim()); //entity.Name = txtName.Text.Trim(); //if (txtOPName.Text.Trim() == "") //{ // entity.OPName = FParamConfig.LoginName; //} //else //{ // entity.OPName = txtOPName.Text.Trim(); //} //entity.Rate = SysConvert.ToDecimal(txtRate.Text.Trim()); //entity.Symbol = txtSymbol.Text.Trim(); entity.Remark = txtRemark.Text.Trim(); //if (txtRDate.DateTime.ToString() != "") //{ // entity.RDate = SysConvert.ToDateTime(txtRDate.DateTime.Date.ToString("yyyy-MM-dd")); //} //else //{ // entity.RDate = SysConvert.ToDateTime(DateTime.Now.Date.ToString("yyyy-mm-dd")); //} //entity.BaseName = SysConvert.ToString(drpBaseName.EditValue); return(entity); }
/// <summary> /// 删除 /// </summary> public override void EntityDelete() { SaleGroupRule rule = new SaleGroupRule(); SaleGroup entity = EntityGet(); rule.RDelete(entity); }
/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { SaleGroup MasterEntity = (SaleGroup)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Enum_SaleGroup 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); } }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private SaleGroup EntityGet() { SaleGroup entity = new SaleGroup(); entity.ID = HTDataID; return(entity); }
/// <summary> /// 新增 /// </summary> public override int EntityAdd() { SaleGroupRule rule = new SaleGroupRule(); SaleGroup entity = EntityGet(); rule.RAdd(entity); return(entity.ID); }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { SaleGroup MasterEntity = (SaleGroup)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Enum_SaleGroup("); MasterValue.Append(" VALUES("); MasterField.Append("ID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ","); MasterField.Append("Code" + ","); if (MasterEntity.Code != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.Code) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Name" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Name) + ","); MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("DelFlag" + ")"); MasterValue.Append(SysString.ToDBString(MasterEntity.DelFlag) + ")"); //执行 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); } }
/// <summary> /// 修改 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Update(BaseEntity p_Entity) { try { SaleGroup MasterEntity = (SaleGroup)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Enum_SaleGroup SET "); UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ","); if (MasterEntity.Code != 0) { UpdateBuilder.Append(" Code=" + SysString.ToDBString(MasterEntity.Code) + ","); } else { UpdateBuilder.Append(" Code=null,"); } UpdateBuilder.Append(" Name=" + SysString.ToDBString(MasterEntity.Name) + ","); UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); UpdateBuilder.Append(" DelFlag=" + SysString.ToDBString(MasterEntity.DelFlag)); 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); } }
/// <summary> /// 删除 /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); SaleGroup entity = (SaleGroup)p_BE; SaleGroupCtl control = new SaleGroupCtl(sqlTrans); control.Delete(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 设置 /// </summary> public override void EntitySet() { SaleGroup entity = new SaleGroup(); entity.ID = HTDataID; bool findFlag = entity.SelectByID(); txtCode.Text = entity.Code.ToString(); txtName.Text = SysConvert.ToString(entity.Name); //drpName.EditValue = SysConvert.ToString(entity.Name ); //txtName.Text = SysConvert.ToString(entity.Name); //txtRate.Text = SysConvert.ToString(entity.Rate); txtRemark.Text = SysConvert.ToString(entity.Remark); //drpBaseName.EditValue = SysConvert.ToString(entity.b); //txtSymbol.Text = SysConvert.ToString(entity.Symbol); //txtOPName.Text = SysConvert.ToString(entity.OPName); //txtRDate.DateTime = SysConvert.ToDateTime(entity.r); }
/// <summary> /// 检查将要操作的数据是否符合业务规则 /// </summary> /// <param name="p_BE"></param> private void CheckCorrect(BaseEntity p_BE) { SaleGroup entity = (SaleGroup)p_BE; }
protected override void Seed(ApplicationDbContext db) { var progr1 = new ProgressState { Name = "Not Started" }; var progr2 = new ProgressState { Name = "Started" }; var progr3 = new ProgressState { Name = "Complete" }; var filial1 = new Filial { Name = "Kiev 01 region" }; var filial2 = new Filial { Name = "Kiev 02 region" }; var filial3 = new Filial { Name = "Dnipro 01 region" }; var filial4 = new Filial { Name = "Kharkiv 01 region" }; var jobPosition1 = new JobPosition { Name = "Продавец" }; var jobPosition2 = new JobPosition { Name = "Консультант" }; var saleGroup1 = new SaleGroup { Code = "SG_INTEL", Name = "Группа продаж Intel" }; var saleGroup2 = new SaleGroup { Code = "SG_IBM", Name = "Группа продаж IBM" }; var category1 = new CourseCategory { Name = "Технические курсы", Description = "Технические направления" }; var category2 = new CourseCategory { Name = "Экономические курсы", Description = "Экономические направления" }; var course1 = new Course { Code = "TECH0001", CourseCategory = category1, Title = "C#. Advanced.", SaleGroup = saleGroup1 }; var course2 = new Course { Code = "ECON0001", CourseCategory = category2, Title = "Маркетинг. Продажа RAID-массивов.", SaleGroup = saleGroup2 }; var lo1 = new LearningObject { Course = course1, Name = "C# Intro", Description = "KPI", Order = 0 }; var lo2 = new LearningObject { Course = course1, Name = "Math Functions", Description = "KPI", Order = 1 }; var lo3 = new LearningObject { Course = course1, Name = "String Operations", Description = "KPI", Order = 2 }; var lo4 = new LearningObject { Course = course2, Name = "Маркетинг IBM", Description = "eco", Order = 0 }; var lo5 = new LearningObject { Course = course2, Name = "Карта потребительского рынка", Description = "eco", Order = 1 }; var lo6 = new LearningObject { Course = course2, Name = "Стратегия продаж", Description = "eco", Order = 2 }; var q1 = new Question { QuestionTypeId = 1, Content = "Who am I?" }; db.Questions.Add(q1); db.Filials.Add(filial1); db.Filials.Add(filial2); db.Filials.Add(filial3); db.Filials.Add(filial4); db.JobPositions.Add(jobPosition1); db.JobPositions.Add(jobPosition2); db.SaleGroups.Add(saleGroup1); db.SaleGroups.Add(saleGroup2); db.CourseCategories.Add(category1); db.CourseCategories.Add(category2); db.Courses.Add(course1); db.Courses.Add(course2); db.LearningObjects.Add(lo1); db.LearningObjects.Add(lo2); db.LearningObjects.Add(lo3); db.LearningObjects.Add(lo4); db.LearningObjects.Add(lo5); db.LearningObjects.Add(lo6); //db.SaveChanges(); }