Example #1
0
        private InvoiceYOperationDts[] EntityDtsGet()
        {
            int index = GetDataCompleteNum();

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

                    entitydts[index].MainID     = HTDataID;
                    entitydts[index].Seq        = i + 1;
                    entitydts[index].ItemCode   = SysConvert.ToString(gridView1.GetRowCellValue(i, "ItemCode"));
                    entitydts[index].GoodsCode  = SysConvert.ToString(gridView1.GetRowCellValue(i, "GoodsCode"));
                    entitydts[index].ColorNum   = SysConvert.ToString(gridView1.GetRowCellValue(i, "ColorNum"));
                    entitydts[index].ColorName  = SysConvert.ToString(gridView1.GetRowCellValue(i, "ColorName"));
                    entitydts[index].ItemName   = SysConvert.ToString(gridView1.GetRowCellValue(i, "ItemName"));
                    entitydts[index].DtsOrderNo = SysConvert.ToString(gridView1.GetRowCellValue(i, "DtsOrderNo"));
                    entitydts[index].Qty        = SysConvert.ToDecimal(gridView1.GetRowCellValue(i, "Qty"));

                    entitydts[index].SinglePrice = SysConvert.ToDecimal(gridView1.GetRowCellValue(i, "SinglePrice"));
                    entitydts[index].Amount      = entitydts[index].SinglePrice * entitydts[index].Qty;



                    index++;
                }
            }
            return(entitydts);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Delete(BaseEntity p_Entity)
        {
            try
            {
                InvoiceYOperationDts MasterEntity = (InvoiceYOperationDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //删除主表数据
                string Sql = "";
                Sql = "DELETE FROM Finance_InvoiceYOperationDts 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);
            }
        }
Example #3
0
        private InvoiceYOperationDts[] EntityDtsGet2()
        {
            int index = 0;

            for (int j = 0; j < gridView2.RowCount; j++)
            {
                if (SysConvert.ToString(gridView2.GetRowCellValue(j, "ItemCode")) != "")
                {
                    index++;
                }
            }
            InvoiceYOperationDts[] entitydts = new InvoiceYOperationDts[index];
            index = 0;
            for (int i = 0; i < gridView2.RowCount; i++)
            {
                if (SysConvert.ToString(gridView2.GetRowCellValue(i, "ItemCode")) != "")
                {
                    entitydts[index]        = new InvoiceYOperationDts();
                    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].ItemCode   = SysConvert.ToString(gridView2.GetRowCellValue(i, "ItemCode"));
                    entitydts[index].GoodsCode  = SysConvert.ToString(gridView2.GetRowCellValue(i, "GoodsCode"));
                    entitydts[index].ColorNum   = SysConvert.ToString(gridView2.GetRowCellValue(i, "ColorNum"));
                    entitydts[index].ColorName  = SysConvert.ToString(gridView2.GetRowCellValue(i, "ColorName"));
                    entitydts[index].ItemName   = SysConvert.ToString(gridView2.GetRowCellValue(i, "ItemName"));
                    entitydts[index].DtsOrderNo = SysConvert.ToString(gridView2.GetRowCellValue(i, "DtsOrderNo"));
                    entitydts[index].Qty        = SysConvert.ToDecimal(gridView2.GetRowCellValue(i, "Qty"));
                    entitydts[index].Unit       = SysConvert.ToString(gridView2.GetRowCellValue(i, "Unit"));

                    entitydts[index].SinglePrice = SysConvert.ToDecimal(gridView2.GetRowCellValue(i, "SinglePrice"));
                    if (entitydts[index].SinglePrice != 0)
                    {
                        entitydts[index].Amount = entitydts[index].SinglePrice * entitydts[index].Qty;
                    }
                    else
                    {
                        entitydts[index].Amount = SysConvert.ToDecimal(gridView2.GetRowCellValue(i, "Amount"));
                    }
                    entitydts[index].DInvoiceTaxAmount = SysConvert.ToDecimal(entitydts[index].Amount - entitydts[index].Amount / 1.17m, 5);



                    index++;
                }
            }
            return(entitydts);
        }
        /// <summary>
        /// 保存(传入事务处理)
        /// </summary>
        /// <param name="p_Entity"></param>
        /// <param name="p_BE"></param>
        /// <param name="sqlTrans"></param>
        public void RSave2(InvoiceOperation p_Entity, BaseEntity[] p_BE, BaseEntity[] p_BE2, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = "DELETE FROM Finance_InvoiceOperationDts 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 Finance_InvoiceOperationDts 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++)
                {
                    InvoiceOperationDts entitydts = (InvoiceOperationDts)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
                    }
                }

                sql  = "SELECT ISNULL(MAX(Seq),0)+1 As MSEQ FROM Finance_InvoiceYOperationDts WHERE MainID=" + p_Entity.ID.ToString();////找到最大的Seq    将获得最大Seq的语句放到循环外更高效(多人操作时会有问题吗?)
                MSEQ = SysConvert.ToInt32(sqlTrans.Fill(sql).Rows[0][0].ToString());
                InvoiceYOperationDtsRule rule2 = new InvoiceYOperationDtsRule();
                for (int i = 0; i < p_BE2.Length; i++)
                {
                    InvoiceYOperationDts entitydts2 = (InvoiceYOperationDts)p_BE2[i];
                    if (entitydts2.ID != 0)//ID不为0说明数据库中已经存在
                    {
                        rule2.RUpdate(entitydts2, sqlTrans);
                    }
                    else
                    {
                        entitydts2.Seq    = MSEQ;
                        entitydts2.MainID = p_Entity.ID;
                        rule2.RAdd(entitydts2, sqlTrans);

                        MSEQ++;//最大值加1
                    }
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Example #5
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)
        {
            InvoiceYOperationDts entity = (InvoiceYOperationDts)p_BE;
            bool      ret = false;
            string    sql = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, InvoiceYOperationDts.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 RUpdate2(BaseEntity p_BE, BaseEntity[] p_BE2, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                InvoiceOperation entity = (InvoiceOperation)p_BE;
                string           sql    = "SELECT FormNo FROM Finance_InvoiceOperation WHERE FormNo=" + SysString.ToDBString(entity.FormNo);
                sql += " AND ID<>" + entity.ID;
                DataTable dt = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("单号已存在,异常操作,请联系管理员检查");
                }

                if (entity.InvoiceNO != "")
                {
                    sql  = "SELECT ID FROM Finance_InvoiceOperation WHERE InvoiceNO=" + SysString.ToDBString(entity.InvoiceNO);
                    sql += " AND ID<>" + entity.ID;
                    dt   = sqlTrans.Fill(sql);
                    if (dt.Rows.Count > 0)
                    {
                        throw new BaseException("发票号已存在,请重新输入");
                    }
                }



                InvoiceOperationCtl control = new InvoiceOperationCtl(sqlTrans);
                control.Update(entity);

                sql = "DELETE Finance_InvoiceYOperationDts WHERE MainID=" + SysString.ToDBString(entity.ID);
                sqlTrans.ExecuteNonQuery(sql);
                for (int i = 0; i < p_BE2.Length; i++)
                {
                    InvoiceYOperationDtsRule rule      = new InvoiceYOperationDtsRule();
                    InvoiceYOperationDts     entityDts = (InvoiceYOperationDts)p_BE2[i];
                    entityDts.MainID = entity.ID;
                    entityDts.Seq    = i + 1;
                    rule.RAdd(entityDts, sqlTrans);
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
        /// <summary>
        /// 新增(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RAdd2(BaseEntity p_BE, BaseEntity[] p_BE2, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                InvoiceOperation entity = (InvoiceOperation)p_BE;
                string           sql    = "SELECT FormNo FROM Finance_InvoiceOperation WHERE FormNo=" + SysString.ToDBString(entity.FormNo);
                DataTable        dt     = sqlTrans.Fill(sql);
                if (dt.Rows.Count > 0)
                {
                    throw new BaseException("单号已存在,请重新生成");
                }

                if (entity.InvoiceNO != "")
                {
                    sql = "SELECT ID FROM Finance_InvoiceOperation WHERE InvoiceNO=" + SysString.ToDBString(entity.InvoiceNO);
                    dt  = sqlTrans.Fill(sql);
                    if (dt.Rows.Count > 0)
                    {
                        throw new BaseException("发票号已存在,请重新输入");
                    }
                }

                InvoiceOperationCtl control = new InvoiceOperationCtl(sqlTrans);
                entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Finance_InvoiceOperation, sqlTrans);
                control.AddNew(entity);

                for (int i = 0; i < p_BE2.Length; i++)
                {
                    InvoiceYOperationDtsRule rule      = new InvoiceYOperationDtsRule();
                    InvoiceYOperationDts     entityDts = (InvoiceYOperationDts)p_BE2[i];
                    entityDts.MainID = entity.ID;
                    entityDts.Seq    = i + 1;
                    rule.RAdd(entityDts, sqlTrans);
                }

                FormNoControlRule rulest = new FormNoControlRule();
                rulest.RAddSort((int)FormNoControlEnum.发票单号, sqlTrans);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Example #8
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);
         InvoiceYOperationDts    entity  = (InvoiceYOperationDts)p_BE;
         InvoiceYOperationDtsCtl control = new InvoiceYOperationDtsCtl(sqlTrans);
         control.Delete(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Example #9
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);
         InvoiceYOperationDts    entity  = (InvoiceYOperationDts)p_BE;
         InvoiceYOperationDtsCtl control = new InvoiceYOperationDtsCtl(sqlTrans);
         entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Finance_InvoiceYOperationDts, sqlTrans);
         control.AddNew(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                InvoiceYOperationDts MasterEntity = (InvoiceYOperationDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //新增主表数据
                StringBuilder MasterField = new StringBuilder();
                StringBuilder MasterValue = new StringBuilder();
                MasterField.Append("INSERT INTO Finance_InvoiceYOperationDts(");
                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("DtsOrderNo" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.DtsOrderNo) + ",");
                MasterField.Append("ItemCode" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ItemCode) + ",");
                MasterField.Append("ItemName" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ItemName) + ",");
                MasterField.Append("ColorNum" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ColorNum) + ",");
                MasterField.Append("ColorName" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ColorName) + ",");
                MasterField.Append("GoodsCode" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.GoodsCode) + ",");
                MasterField.Append("Qty" + ",");
                if (MasterEntity.Qty != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.Qty) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

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

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

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

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



                //执行
                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
            {
                InvoiceYOperationDts MasterEntity = (InvoiceYOperationDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //更新主表数据
                StringBuilder UpdateBuilder = new StringBuilder();
                UpdateBuilder.Append("UPDATE Finance_InvoiceYOperationDts SET ");
                UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ",");
                UpdateBuilder.Append(" MainID=" + SysString.ToDBString(MasterEntity.MainID) + ",");
                UpdateBuilder.Append(" Seq=" + SysString.ToDBString(MasterEntity.Seq) + ",");
                UpdateBuilder.Append(" DtsOrderNo=" + SysString.ToDBString(MasterEntity.DtsOrderNo) + ",");
                UpdateBuilder.Append(" ItemCode=" + SysString.ToDBString(MasterEntity.ItemCode) + ",");
                UpdateBuilder.Append(" ItemName=" + SysString.ToDBString(MasterEntity.ItemName) + ",");
                UpdateBuilder.Append(" ColorNum=" + SysString.ToDBString(MasterEntity.ColorNum) + ",");
                UpdateBuilder.Append(" ColorName=" + SysString.ToDBString(MasterEntity.ColorName) + ",");
                UpdateBuilder.Append(" GoodsCode=" + SysString.ToDBString(MasterEntity.GoodsCode) + ",");

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


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


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


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

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

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


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