コード例 #1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Delete(BaseEntity p_Entity)
        {
            try
            {
                ProductionPlanDts2 MasterEntity = (ProductionPlanDts2)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //删除主表数据
                string Sql = "";
                Sql = "DELETE FROM WO_ProductionPlanDts2 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);
            }
        }
コード例 #2
0
        public void RSave(ProductionPlan p_Entity, BaseEntity[] p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = "DELETE FROM WO_ProductionPlanDts2 WHERE MainID=" + p_Entity.ID.ToString();
                sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(p_BE));
                sqlTrans.ExecuteNonQuery(sql);                                                                                 //删除原单据里应该删除的明细数据,即数据库里有但是UI里已经删除的数据
                sql = "SELECT ISNULL(MAX(Seq),0)+1 As MSEQ FROM WO_ProductionPlanDts2 WHERE MainID=" + p_Entity.ID.ToString(); ////找到最大的Seq    将获得最大Seq的语句放到循环外更高效(多人操作时会有问题吗?)
                int MSEQ = SysConvert.ToInt32(sqlTrans.Fill(sql).Rows[0][0].ToString());
                for (int i = 0; i < p_BE.Length; i++)
                {
                    ProductionPlanDts2 entitydts = (ProductionPlanDts2)p_BE[i];
                    if (entitydts.ID != 0)//ID不为0说明数据库中已经存在
                    {
                        this.RUpdate(entitydts, sqlTrans);
                    }
                    else
                    {
                        entitydts.Seq    = MSEQ;
                        entitydts.MainID = p_Entity.ID;
                        this.RAdd(entitydts, sqlTrans);

                        MSEQ++;//最大值加1
                    }
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
コード例 #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)
        {
            ProductionPlanDts2 entity = (ProductionPlanDts2)p_BE;
            bool      ret             = false;
            string    sql             = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, ProductionPlanDts2.TableName, SysString.ToDBString(p_FieldValue), "ID", entity.ID);
            DataTable dt = p_sqlTrans.Fill(sql);

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

            return(ret);
        }
コード例 #4
0
        private string GetIDExist(BaseEntity[] p_BE)
        {
            string outstr = "0";

            for (int i = 0; i < p_BE.Length; i++)
            {
                ProductionPlanDts2 entitydts = (ProductionPlanDts2)p_BE[i];
                if (entitydts.ID != 0)
                {
                    outstr += "," + entitydts.ID;
                }
            }
            return(outstr);
        }
コード例 #5
0
        private ProductionPlanDts2[] EntityDtsGet2()
        {
            int index = 0;

            for (int i = 0; i < gridView2.RowCount; i++)
            {
                if (SysConvert.ToString(gridView2.GetRowCellValue(i, "WagonNo")) != string.Empty)
                {
                    index++;
                }
            }

            ProductionPlanDts2[] entitydts = new ProductionPlanDts2[index];
            index = 0;
            for (int i = 0; i < gridView2.RowCount; i++)
            {
                if (SysConvert.ToString(gridView2.GetRowCellValue(i, "WagonNo")) != string.Empty)
                {
                    entitydts[index]        = new ProductionPlanDts2();
                    entitydts[index].MainID = SysConvert.ToInt32(gridView2.GetRowCellValue(i, "MainID"));
                    if (entitydts[index].MainID == HTDataID && HTDataID != 0)//已存在表示修改
                    {
                        entitydts[index].ID = SysConvert.ToInt32(gridView2.GetRowCellValue(i, "ID"));
                        entitydts[index].SelectByID();
                    }
                    else//新增
                    {
                        entitydts[index].MainID = HTDataID;
                        entitydts[index].Seq    = i + 1;
                    }
                    entitydts[index].WagonNo    = SysConvert.ToString(gridView2.GetRowCellValue(i, "WagonNo"));
                    entitydts[index].PBFormDate = SysConvert.ToDateTime(gridView2.GetRowCellValue(i, "PBFormDate"));
                    entitydts[index].PBieceQty  = SysConvert.ToInt32(gridView2.GetRowCellValue(i, "PBieceQty"));
                    entitydts[index].PBQty      = SysConvert.ToDecimal(gridView2.GetRowCellValue(i, "PBQty"));
                    entitydts[index].CPFormDate = SysConvert.ToDateTime(gridView2.GetRowCellValue(i, "CPFormDate"));
                    entitydts[index].CPQty      = SysConvert.ToDecimal(gridView2.GetRowCellValue(i, "CPQty"));
                    entitydts[index].Shrinkage  = SysConvert.ToDecimal(gridView2.GetRowCellValue(i, "Shrinkage"));
                    entitydts[index].Remark     = SysConvert.ToString(gridView2.GetRowCellValue(i, "Remark"));
                    entitydts[index].ZPQty      = SysConvert.ToDecimal(gridView2.GetRowCellValue(i, "ZPQty"));
                    entitydts[index].MWidth     = SysConvert.ToString(gridView2.GetRowCellValue(i, "MWidth"));
                    entitydts[index].MWeight    = SysConvert.ToString(gridView2.GetRowCellValue(i, "MWeight"));
                    entitydts[index].ColorName  = SysConvert.ToString(gridView2.GetRowCellValue(i, "ColorName"));
                    entitydts[index].ColorNum   = SysConvert.ToString(gridView2.GetRowCellValue(i, "ColorNum"));
                    entitydts[index].Batch      = SysConvert.ToString(gridView2.GetRowCellValue(i, "Batch"));
                    entitydts[index].HuiXiu     = SysConvert.ToString(gridView2.GetRowCellValue(i, "HuiXiu"));
                    index++;
                }
            }
            return(entitydts);
        }
コード例 #6
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);
         ProductionPlanDts2    entity  = (ProductionPlanDts2)p_BE;
         ProductionPlanDts2Ctl control = new ProductionPlanDts2Ctl(sqlTrans);
         control.Delete(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
コード例 #7
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);
         ProductionPlanDts2    entity  = (ProductionPlanDts2)p_BE;
         ProductionPlanDts2Ctl control = new ProductionPlanDts2Ctl(sqlTrans);
         entity.ID = (int)EntityIDTable.GetID((long)SysEntity.WO_ProductionPlanDts2, sqlTrans);
         control.AddNew(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
コード例 #8
0
 /// <summary>
 /// 检查将要操作的数据是否符合业务规则
 /// </summary>
 /// <param name="p_BE"></param>
 private void CheckCorrect(BaseEntity p_BE)
 {
     ProductionPlanDts2 entity = (ProductionPlanDts2)p_BE;
 }
コード例 #9
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                ProductionPlanDts2 MasterEntity = (ProductionPlanDts2)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

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

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

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

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

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

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

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

                MasterField.Append("Batch" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Batch) + ",");
                MasterField.Append("ColorNum" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ColorNum) + ",");
                MasterField.Append("ColorName" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ColorName) + ",");
                MasterField.Append("HuiXiu" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.HuiXiu) + ",");
                MasterField.Append("MWidth" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.MWidth) + ",");
                MasterField.Append("MWeight" + ")");
                MasterValue.Append(SysString.ToDBString(MasterEntity.MWeight) + ")");



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

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

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


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


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


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


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


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

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

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

                UpdateBuilder.Append(" Batch=" + SysString.ToDBString(MasterEntity.Batch) + ",");
                UpdateBuilder.Append(" ColorNum=" + SysString.ToDBString(MasterEntity.ColorNum) + ",");
                UpdateBuilder.Append(" ColorName=" + SysString.ToDBString(MasterEntity.ColorName) + ",");
                UpdateBuilder.Append(" HuiXiu=" + SysString.ToDBString(MasterEntity.HuiXiu) + ",");
                UpdateBuilder.Append(" MWidth=" + SysString.ToDBString(MasterEntity.MWidth) + ",");
                UpdateBuilder.Append(" MWeight=" + SysString.ToDBString(MasterEntity.MWeight));

                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);
            }
        }