/// <summary> /// 删除 /// </summary> public override void EntityDelete() { SendSampleRule rule = new SendSampleRule(); SendSample entity = EntityGet(); rule.RDelete(entity); }
/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); SendSample entity = (SendSample)p_BE; string sql = "SELECT * FROM Sale_SendSample WHERE FormNo=" + SysString.ToDBString(entity.FormNo); DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { throw new BaseException("单号已存在,请双击单号重新生成!"); } SendSampleCtl control = new SendSampleCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Sale_SendSample, sqlTrans); control.AddNew(entity); FormNoControlRule frule = new FormNoControlRule(); frule.RAddSort((int)FormNoControlEnum.寄样编号, sqlTrans); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private SendSample EntityGet() { SendSample entity = new SendSample(); entity.ID = HTDataID; entity.SelectByID(); entity.MakeDate = txtMakeDate.DateTime.Date; entity.MakeOPName = txtMakeOPName.Text.Trim(); entity.FormNo = txtFormNo.Text.Trim(); entity.FormDate = txtFormDate.DateTime.Date; entity.VendorID = SysConvert.ToString(drpVendorID.EditValue); entity.FactoryID = txtFactoryID.Text.Trim(); entity.VendorOPName = txtVendorOPName.Text.Trim(); entity.ItemCode = txtItemCode.Text.Trim(); entity.ItemName = txtItemName.Text.Trim(); entity.ItemStd = txtItemStd.Text.Trim(); entity.ItemModel = txtItemModel.Text.Trim(); entity.MWidth = txtMWidth.Text.Trim(); entity.MWeight = txtMWeight.Text.Trim(); entity.MWeight2 = txtMWeight2.Text.Trim(); entity.ColorNum = txtColorNum.Text.Trim(); entity.ColorName = txtColorName.Text.Trim(); entity.Density = txtDensity.Text.Trim(); entity.FacricPrice = txtFacricPrice.Text.Trim(); entity.Remark = txtRemark.Text.Trim(); entity.GYOPName = txtGYOPName.Text.Trim(); entity.FinishDate = txtFinishDate.DateTime.Date; entity.Flower = txtFlower.Text.Trim(); entity.SampTypeID = this.FormListAID; return(entity); }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private SendSample EntityGet() { SendSample entity = new SendSample(); entity.ID = HTDataID; return(entity); }
/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { SendSample MasterEntity = (SendSample)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Sale_SendSample 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> public override int EntityAdd() { SendSampleRule rule = new SendSampleRule(); SendSample entity = EntityGet(); rule.RAdd(entity); return(entity.ID); }
/// <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) { SendSample entity = (SendSample)p_BE; bool ret = false; string sql = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, SendSample.TableName, SysString.ToDBString(p_FieldValue), "ID", entity.ID); DataTable dt = p_sqlTrans.Fill(sql); if (dt.Rows.Count != 0) { ret = true; } return(ret); }
/// <summary> /// 删除 /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); SendSample entity = (SendSample)p_BE; SendSampleCtl control = new SendSampleCtl(sqlTrans); control.Delete(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 设置 /// </summary> public override void EntitySet() { SendSample entity = new SendSample(); entity.ID = HTDataID; bool findFlag = entity.SelectByID(); txtMakeDate.DateTime = entity.MakeDate; txtMakeOPName.Text = entity.MakeOPName.ToString(); txtFormNo.Text = entity.FormNo.ToString(); txtFormDate.DateTime = entity.FormDate; drpVendorID.EditValue = entity.VendorID.ToString(); txtFactoryID.Text = entity.FactoryID.ToString(); txtVendorOPName.Text = entity.VendorOPName.ToString(); txtItemCode.Text = entity.ItemCode.ToString(); txtItemName.Text = entity.ItemName.ToString(); txtItemStd.Text = entity.ItemStd.ToString(); txtItemModel.Text = entity.ItemModel.ToString(); txtMWidth.Text = entity.MWidth.ToString(); txtMWeight.Text = entity.MWeight.ToString(); txtMWeight2.Text = entity.MWeight2.ToString(); txtColorNum.Text = entity.ColorNum.ToString(); txtColorName.Text = entity.ColorName.ToString(); txtDensity.Text = entity.Density.ToString(); txtFacricPrice.Text = entity.FacricPrice.ToString(); txtRemark.Text = entity.Remark.ToString(); txtGYOPName.Text = entity.GYOPName.ToString(); txtFinishDate.DateTime = entity.FinishDate; txtFlower.Text = entity.Flower.ToString(); txtSampTypeID.Text = entity.SampTypeID.ToString(); if (!findFlag) { } }
/// <summary> /// 检查将要操作的数据是否符合业务规则 /// </summary> /// <param name="p_BE"></param> private void CheckCorrect(BaseEntity p_BE) { SendSample entity = (SendSample)p_BE; }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { SendSample MasterEntity = (SendSample)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Sale_SendSample("); MasterValue.Append(" VALUES("); MasterField.Append("ID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ","); MasterField.Append("MakeDate" + ","); if (MasterEntity.MakeDate != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.MakeDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("MakeOPName" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MakeOPName) + ","); MasterField.Append("SubmitFlag" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SubmitFlag) + ","); MasterField.Append("DelFlag" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.DelFlag) + ","); MasterField.Append("FormNo" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.FormNo) + ","); MasterField.Append("FormDate" + ","); if (MasterEntity.FormDate != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.FormDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("VendorID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.VendorID) + ","); MasterField.Append("FactoryID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.FactoryID) + ","); MasterField.Append("VendorOPName" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.VendorOPName) + ","); MasterField.Append("ItemCode" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ItemCode) + ","); MasterField.Append("ItemName" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ItemName) + ","); MasterField.Append("ItemStd" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ItemStd) + ","); MasterField.Append("ItemModel" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ItemModel) + ","); MasterField.Append("MWidth" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MWidth) + ","); MasterField.Append("MWeight" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MWeight) + ","); MasterField.Append("MWeight2" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MWeight2) + ","); MasterField.Append("ColorNum" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ColorNum) + ","); MasterField.Append("ColorName" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ColorName) + ","); MasterField.Append("Density" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Density) + ","); MasterField.Append("FacricPrice" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.FacricPrice) + ","); MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("GYOPName" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.GYOPName) + ","); MasterField.Append("FinishDate" + ","); if (MasterEntity.FinishDate != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.FinishDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Flower" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Flower) + ","); MasterField.Append("SampTypeID" + ")"); MasterValue.Append(SysString.ToDBString(MasterEntity.SampTypeID) + ")"); //执行 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 { SendSample MasterEntity = (SendSample)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Sale_SendSample SET "); UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ","); if (MasterEntity.MakeDate != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" MakeDate=" + SysString.ToDBString(MasterEntity.MakeDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" MakeDate=null,"); } UpdateBuilder.Append(" MakeOPName=" + SysString.ToDBString(MasterEntity.MakeOPName) + ","); UpdateBuilder.Append(" SubmitFlag=" + SysString.ToDBString(MasterEntity.SubmitFlag) + ","); UpdateBuilder.Append(" DelFlag=" + SysString.ToDBString(MasterEntity.DelFlag) + ","); UpdateBuilder.Append(" FormNo=" + SysString.ToDBString(MasterEntity.FormNo) + ","); if (MasterEntity.FormDate != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" FormDate=" + SysString.ToDBString(MasterEntity.FormDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" FormDate=null,"); } UpdateBuilder.Append(" VendorID=" + SysString.ToDBString(MasterEntity.VendorID) + ","); UpdateBuilder.Append(" FactoryID=" + SysString.ToDBString(MasterEntity.FactoryID) + ","); UpdateBuilder.Append(" VendorOPName=" + SysString.ToDBString(MasterEntity.VendorOPName) + ","); UpdateBuilder.Append(" ItemCode=" + SysString.ToDBString(MasterEntity.ItemCode) + ","); UpdateBuilder.Append(" ItemName=" + SysString.ToDBString(MasterEntity.ItemName) + ","); UpdateBuilder.Append(" ItemStd=" + SysString.ToDBString(MasterEntity.ItemStd) + ","); UpdateBuilder.Append(" ItemModel=" + SysString.ToDBString(MasterEntity.ItemModel) + ","); UpdateBuilder.Append(" MWidth=" + SysString.ToDBString(MasterEntity.MWidth) + ","); UpdateBuilder.Append(" MWeight=" + SysString.ToDBString(MasterEntity.MWeight) + ","); UpdateBuilder.Append(" MWeight2=" + SysString.ToDBString(MasterEntity.MWeight2) + ","); UpdateBuilder.Append(" ColorNum=" + SysString.ToDBString(MasterEntity.ColorNum) + ","); UpdateBuilder.Append(" ColorName=" + SysString.ToDBString(MasterEntity.ColorName) + ","); UpdateBuilder.Append(" Density=" + SysString.ToDBString(MasterEntity.Density) + ","); UpdateBuilder.Append(" FacricPrice=" + SysString.ToDBString(MasterEntity.FacricPrice) + ","); UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); UpdateBuilder.Append(" GYOPName=" + SysString.ToDBString(MasterEntity.GYOPName) + ","); if (MasterEntity.FinishDate != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" FinishDate=" + SysString.ToDBString(MasterEntity.FinishDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" FinishDate=null,"); } UpdateBuilder.Append(" Flower=" + SysString.ToDBString(MasterEntity.Flower) + ","); UpdateBuilder.Append(" SampTypeID=" + SysString.ToDBString(MasterEntity.SampTypeID)); 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); } }