Esempio n. 1
0
 /// <summary>
 /// 保存(传入事务处理)
 /// </summary>
 /// <param name="p_Entity"></param>
 /// <param name="p_BE"></param>
 /// <param name="sqlTrans"></param>
 public void RSave(ItemGYFlowDts p_Entity, BaseEntity[] p_BE, IDBTransAccess sqlTrans)
 {
     try
     {
         string sql = "DELETE FROM Data_ItemGYFlowItemDts 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++)
         {
             ItemGYFlowItemDts entitydts = (ItemGYFlowItemDts)p_BE[i];
             if (entitydts.ID != 0)//ID不为0说明数据库中已经存在
             {
                 this.RUpdate(entitydts, sqlTrans);
             }
             else
             {
                 entitydts.MainID = p_Entity.ID;
                 this.RAdd(entitydts, sqlTrans);
             }
         }
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Delete(BaseEntity p_Entity)
        {
            try
            {
                ItemGYFlowDts MasterEntity=(ItemGYFlowDts)p_Entity;
                if (MasterEntity.ID==0)
                {
                    return 0;
                }

                //删除主表数据
                string Sql="";
                Sql="DELETE FROM Data_ItemGYFlowDts 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);
            }
        }
Esempio n. 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++)
            {
                ItemGYFlowDts entitydts = (ItemGYFlowDts)p_BE[i];
                if (entitydts.ID != 0)
                {
                    outstr += "," + entitydts.ID;
                }
            }
            return(outstr);
        }
Esempio n. 4
0
		/// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                ItemGYFlowDts MasterEntity=(ItemGYFlowDts)p_Entity;
                if (MasterEntity.ID==0)
                {
                    return 0;
                }

                //新增主表数据
                StringBuilder MasterField=new StringBuilder();
                StringBuilder MasterValue=new StringBuilder();
                MasterField.Append("INSERT INTO Data_ItemGYFlowDts(");
                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("ItemGYTypeID"+")"); 
  				MasterValue.Append(SysString.ToDBString(MasterEntity.ItemGYTypeID)+")"); 
 
                
                

                //执行
                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);
            }
        }
Esempio 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);
         ItemGYFlowDts    entity  = (ItemGYFlowDts)p_BE;
         ItemGYFlowDtsCtl control = new ItemGYFlowDtsCtl(sqlTrans);
         control.Delete(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Update(BaseEntity p_Entity)
        {
            try
            {
                ItemGYFlowDts MasterEntity=(ItemGYFlowDts)p_Entity;
                if (MasterEntity.ID==0)
                {
                    return 0;
                }

                //更新主表数据
                StringBuilder UpdateBuilder=new StringBuilder();
                UpdateBuilder.Append("UPDATE Data_ItemGYFlowDts SET ");
                UpdateBuilder.Append(" ID="+SysString.ToDBString(MasterEntity.ID)+","); 
  				UpdateBuilder.Append(" MainID="+SysString.ToDBString(MasterEntity.MainID)+","); 
  				UpdateBuilder.Append(" Seq="+SysString.ToDBString(MasterEntity.Seq)+","); 
  				UpdateBuilder.Append(" ItemGYTypeID="+SysString.ToDBString(MasterEntity.ItemGYTypeID)); 
 
                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);
            }
        }
Esempio n. 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);
         ItemGYFlowDts    entity  = (ItemGYFlowDts)p_BE;
         ItemGYFlowDtsCtl control = new ItemGYFlowDtsCtl(sqlTrans);
         entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Data_ItemGYFlowDts, sqlTrans);
         control.AddNew(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        ItemGYFlowDts[] EntitFlowDtsyGet(out ArrayList alFlowItem)
        {
            ItemGYFlowDts[] entityDts;
            int             Num = 0;

            for (int i = 0; i < gridView1.RowCount; i++)
            {
                if (SysConvert.ToString(gridView1.GetRowCellValue(i, "ItemGYTypeID")) != string.Empty)
                {
                    Num++;
                }
            }
            alFlowItem = new ArrayList();
            ItemGYFlowDts[] entitydts = new ItemGYFlowDts[Num];
            int             index     = 0;

            for (int i = 0; i < gridView1.RowCount; i++)
            {
                if (SysConvert.ToString(gridView1.GetRowCellValue(i, "ItemGYTypeID")) != string.Empty)
                {
                    entitydts[index]    = new ItemGYFlowDts();
                    entitydts[index].ID = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "ID"));
                    entitydts[index].SelectByID();
                    entitydts[index].MainID = _WPItemID;
                    entitydts[index].Seq    = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "Seq"));
                    if (entitydts[index].Seq == 0)
                    {
                        entitydts[index].Seq = i + 1;
                    }
                    entitydts[index].ItemGYTypeID = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "ItemGYTypeID"));


                    //开始处理工艺明细
                    DataTable dtItemDts = saveDtGYItemDts[i];
                    if (dtItemDts != null)
                    {
                        int dtsnum = 0;
                        foreach (DataRow dr in dtItemDts.Rows)
                        {
                            if (dr["GYItemName"].ToString() != string.Empty)
                            {
                                dtsnum++;
                            }
                        }
                        ItemGYFlowItemDts[] entityFlowItemDts = new ItemGYFlowItemDts[dtsnum];
                        dtsnum = 0;
                        foreach (DataRow dr in dtItemDts.Rows)
                        {
                            if (dr["GYItemName"].ToString() != string.Empty)
                            {
                                entityFlowItemDts[dtsnum]        = new ItemGYFlowItemDts();
                                entityFlowItemDts[dtsnum].ID     = SysConvert.ToInt32(dr["ID"]);
                                entityFlowItemDts[dtsnum].MainID = SysConvert.ToInt32(dr["MainID"]);
                                entityFlowItemDts[dtsnum].Seq    = SysConvert.ToInt32(dr["Seq"]);
                                entityFlowItemDts[dtsnum].TopID  = _WPItemID;
                                if (entityFlowItemDts[dtsnum].Seq == 0)
                                {
                                    entityFlowItemDts[dtsnum].Seq = dtsnum + 1;
                                }

                                entityFlowItemDts[dtsnum].GYItemName  = SysConvert.ToString(dr["GYItemName"]);
                                entityFlowItemDts[dtsnum].GYItemValue = SysConvert.ToString(dr["GYItemValue"]);

                                dtsnum++;
                            }
                        }

                        alFlowItem.Add(entityFlowItemDts);
                    }
                    else
                    {
                        alFlowItem.Add(new ItemGYFlowItemDts[] { });
                    }


                    index++;
                }
            }
            return(entitydts);
        }
Esempio n. 9
0
 /// <summary>
 /// 检查将要操作的数据是否符合业务规则
 /// </summary>
 /// <param name="p_BE"></param>
 private void CheckCorrect(BaseEntity p_BE)
 {
     ItemGYFlowDts entity = (ItemGYFlowDts)p_BE;
 }