Beispiel #1
0
 /// <summary>
 /// 保存(传入事务处理)
 /// </summary>
 /// <param name="p_Entity"></param>
 /// <param name="p_BE"></param>
 /// <param name="sqlTrans"></param>
 public void RSave(LYGL p_Entity, BaseEntity[] p_BE, IDBTransAccess sqlTrans)
 {
     try
     {
         string sql = "DELETE FROM Dev_LYGLDts WHERE MainID=" + p_Entity.ID.ToString();
         sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(p_BE));
         sqlTrans.ExecuteNonQuery(sql);//删除原单据里应该删除的明细数据,即数据库里有但是UI里已经删除的数据
         for (int i = 0; i < p_BE.Length; i++)
         {
             LYGLDts entitydts = (LYGLDts)p_BE[i];
             if (entitydts.ID != 0)//ID不为0说明数据库中已经存在
             {
                 this.RUpdate(entitydts, sqlTrans);
             }
             else
             {
                 entitydts.MainID = p_Entity.ID;
                 entitydts.LYType = (int)EnumLYType.新单;
                 this.RAdd(entitydts, sqlTrans);
             }
         }
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Beispiel #2
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Delete(BaseEntity p_Entity)
        {
            try
            {
                LYGLDts MasterEntity = (LYGLDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //删除主表数据
                string Sql = "";
                Sql = "DELETE FROM Dev_LYGLDts 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);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 获得数据库里没有被删除的ID(即数据库里有而且UI里也没有删除的数据)
        /// </summary>
        /// <param name="p_BE"></param>
        /// <returns></returns>
        private string GetIDExist(BaseEntity[] p_BE)
        {
            string outstr = "0";

            for (int i = 0; i < p_BE.Length; i++)
            {
                LYGLDts entitydts = (LYGLDts)p_BE[i];
                if (entitydts.ID != 0)
                {
                    outstr += "," + entitydts.ID;
                }
            }
            return(outstr);
        }
Beispiel #4
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);
         LYGLDts    entity  = (LYGLDts)p_BE;
         LYGLDtsCtl control = new LYGLDtsCtl(sqlTrans);
         control.Delete(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Beispiel #5
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);
         LYGLDts    entity  = (LYGLDts)p_BE;
         LYGLDtsCtl control = new LYGLDtsCtl(sqlTrans);
         entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Dev_LYGLDts, sqlTrans);
         control.AddNew(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Beispiel #6
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);
                LYGL      entity = (LYGL)p_BE;
                string    sql    = "SELECT FormNo FROM Dev_LYGL WHERE FormNo=" + SysString.ToDBString(entity.FormNo);
                DataTable dt     = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("留样单单号已存在,请双击重新生成");
                }
                LYGLCtl control = new LYGLCtl(sqlTrans);
                entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Dev_LYGL, sqlTrans);

                control.AddNew(entity);
                for (int i = 0; i < p_BE2.Length; i++)
                {
                    LYGLDtsRule rule      = new LYGLDtsRule();
                    LYGLDts     entityDts = (LYGLDts)p_BE2[i];
                    entityDts.MainID = entity.ID;
                    entityDts.Seq    = i + 1;
                    entityDts.LYType = (int)EnumLYType.新单;
                    rule.RAdd(entityDts, sqlTrans);
                }
                FormNoControlRule rulest = new FormNoControlRule();
                //rulest.RAddSort((int)FormNoControlEnum.留样单号, sqlTrans);
                rulest.RAddSort("Dev_LYGL", "FormNo", 0, sqlTrans);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private LYGLDts[] EntityDtsGet()
        {
            int index = GetDataCompleteNum();

            LYGLDts[] entitydts = new LYGLDts[index];
            index = 0;
            for (int i = 0; i < gridView1.RowCount; i++)
            {
                if (CheckDataCompleteDts(i))
                {
                    entitydts[index]    = new LYGLDts();
                    entitydts[index].ID = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "ID"));
                    entitydts[index].SelectByID();
                    entitydts[index].MainID = HTDataID;
                    entitydts[index].Seq    = i + 1;

                    entitydts[index].GBCode        = SysConvert.ToString(gridView1.GetRowCellValue(i, "GBCode"));
                    entitydts[index].JQDesc        = SysConvert.ToString(gridView1.GetRowCellValue(i, "JQDesc"));
                    entitydts[index].PBFlag        = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "PBFlag"));
                    entitydts[index].Remark        = SysConvert.ToString(gridView1.GetRowCellValue(i, "Remark"));
                    entitydts[index].SalePriceDate = SysConvert.ToDateTime(gridView1.GetRowCellValue(i, "SalePriceDate"));
                    entitydts[index].SalePrice     = SysConvert.ToDecimal(gridView1.GetRowCellValue(i, "SalePrice"));
                    entitydts[index].SaleQYSource  = SysConvert.ToString(gridView1.GetRowCellValue(i, "SaleQYSource"));

                    entitydts[index].ColorNum   = SysConvert.ToString(gridView1.GetRowCellValue(i, "ColorNum"));
                    entitydts[index].ColorName  = SysConvert.ToString(gridView1.GetRowCellValue(i, "ColorName"));
                    entitydts[index].MWidth     = SysConvert.ToDecimal(gridView1.GetRowCellValue(i, "MWidth"));
                    entitydts[index].MWeight    = SysConvert.ToDecimal(gridView1.GetRowCellValue(i, "MWeight"));
                    entitydts[index].WeightUnit = SysConvert.ToString(gridView1.GetRowCellValue(i, "WeightUnit"));
                    entitydts[index].GoodsCode  = SysConvert.ToString(gridView1.GetRowCellValue(i, "GoodsCode"));
                    entitydts[index].ItemName   = SysConvert.ToString(gridView1.GetRowCellValue(i, "ItemName"));
                    entitydts[index].JYFlag     = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "JYFlag"));
                    index++;
                }
            }
            return(entitydts);
        }
Beispiel #8
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                LYGLDts MasterEntity = (LYGLDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //新增主表数据
                StringBuilder MasterField = new StringBuilder();
                StringBuilder MasterValue = new StringBuilder();
                MasterField.Append("INSERT INTO Dev_LYGLDts(");
                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("GBCode" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.GBCode) + ",");
                MasterField.Append("JQDesc" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.JQDesc) + ",");
                MasterField.Append("PBFlag" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.PBFlag) + ",");
                MasterField.Append("Remark" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ",");
                MasterField.Append("SalePriceDate" + ",");
                if (MasterEntity.SalePriceDate != SystemConfiguration.DateTimeDefaultValue)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.SalePriceDate.ToString("yyyy-MM-dd HH:mm:ss")) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

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

                MasterField.Append("SaleQYSource" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.SaleQYSource) + ",");
                MasterField.Append("ColorNum" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ColorNum) + ",");
                MasterField.Append("ColorName" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ColorName) + ",");
                MasterField.Append("MWidth" + ",");
                if (MasterEntity.MWidth != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.MWidth) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

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

                MasterField.Append("WeightUnit" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.WeightUnit) + ",");
                MasterField.Append("GoodsCode" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.GoodsCode) + ",");
                MasterField.Append("ItemName" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ItemName) + ",");
                MasterField.Append("JYFlag" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.JYFlag) + ",");
                MasterField.Append("LYType" + ")");
                MasterValue.Append(SysString.ToDBString(MasterEntity.LYType) + ")");



                //执行
                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);
            }
        }
Beispiel #9
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Update(BaseEntity p_Entity)
        {
            try
            {
                LYGLDts MasterEntity = (LYGLDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //更新主表数据
                StringBuilder UpdateBuilder = new StringBuilder();
                UpdateBuilder.Append("UPDATE Dev_LYGLDts SET ");
                UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ",");
                UpdateBuilder.Append(" MainID=" + SysString.ToDBString(MasterEntity.MainID) + ",");
                UpdateBuilder.Append(" Seq=" + SysString.ToDBString(MasterEntity.Seq) + ",");
                UpdateBuilder.Append(" GBCode=" + SysString.ToDBString(MasterEntity.GBCode) + ",");
                UpdateBuilder.Append(" JQDesc=" + SysString.ToDBString(MasterEntity.JQDesc) + ",");
                UpdateBuilder.Append(" PBFlag=" + SysString.ToDBString(MasterEntity.PBFlag) + ",");
                UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ",");

                if (MasterEntity.SalePriceDate != SystemConfiguration.DateTimeDefaultValue)
                {
                    UpdateBuilder.Append(" SalePriceDate=" + SysString.ToDBString(MasterEntity.SalePriceDate.ToString("yyyy-MM-dd HH:mm:ss")) + ",");
                }
                else
                {
                    UpdateBuilder.Append(" SalePriceDate=null,");
                }


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

                UpdateBuilder.Append(" SaleQYSource=" + SysString.ToDBString(MasterEntity.SaleQYSource) + ",");
                UpdateBuilder.Append(" ColorNum=" + SysString.ToDBString(MasterEntity.ColorNum) + ",");
                UpdateBuilder.Append(" ColorName=" + SysString.ToDBString(MasterEntity.ColorName) + ",");

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


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

                UpdateBuilder.Append(" WeightUnit=" + SysString.ToDBString(MasterEntity.WeightUnit) + ",");
                UpdateBuilder.Append(" GoodsCode=" + SysString.ToDBString(MasterEntity.GoodsCode) + ",");
                UpdateBuilder.Append(" ItemName=" + SysString.ToDBString(MasterEntity.ItemName) + ",");
                UpdateBuilder.Append(" JYFlag=" + SysString.ToDBString(MasterEntity.JYFlag) + ",");
                UpdateBuilder.Append(" LYType=" + SysString.ToDBString(MasterEntity.LYType));

                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);
            }
        }
Beispiel #10
0
 /// <summary>
 /// 检查将要操作的数据是否符合业务规则
 /// </summary>
 /// <param name="p_BE"></param>
 private void CheckCorrect(BaseEntity p_BE)
 {
     LYGLDts entity = (LYGLDts)p_BE;
 }