/// <summary>
        /// 撤销核销处理
        /// </summary>
        public void RHXCancel(InvoiceOperation entity, int p_DtsID, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = string.Empty;
                //First 处理发票主表数据
                InvoiceOperation entityinvoice = new InvoiceOperation(sqlTrans);//处理收付款主表数据
                entityinvoice.ID = entity.ID;
                entityinvoice.SelectByID();


                //Second 删除发票核销明细数据
                InvoiceOperationDtsRule dtsRule   = new InvoiceOperationDtsRule();
                InvoiceOperationDts     entityDts = new InvoiceOperationDts(sqlTrans);
                entityDts.ID = p_DtsID;
                entityDts.SelectByID();
                if (entityDts.PayAmount != 0)
                {
                    throw new Exception("不能操作,数据有收付款数据了,不能进行撤销");
                }

                dtsRule.RDelete(entityDts, sqlTrans);//删除明细实体


                //First 处理发票主表数据
                entityinvoice.PreHXFlag    = (int)YesOrNo.No;
                entityinvoice.PreHXQty    -= entityDts.DInvoiceQty;
                entityinvoice.PreHXAmount -= entityDts.DInvoiceAmount;
                this.RUpdate(entityinvoice, sqlTrans);



                IOFormDtsRule ioformdtsRule = new IOFormDtsRule();     //处理出入库单据明细数据
                IOFormDts     entityIOF     = new IOFormDts(sqlTrans); //出入库单据明细
                entityIOF.ID = entityDts.DLOADDtsID;
                entityIOF.SelectByID();
                //处理发票明细数据;出入库明细数据
                if (entityIOF.PayAmount != 0)
                {
                    throw new Exception("不能操作,数据已有收付款数据 ID:" + entityDts.DLOADDtsID + " " + entityIOF.ItemCode + " " + entityIOF.ColorNum);
                }

                sql  = "UPDATE WH_IOFormDts SET InvoiceQty=ISNULL(InvoiceQty,0)-" + "(" + SysString.ToDBString(entityDts.DInvoiceQty) + ")";
                sql += ",InvoiceAmount=ISNULL(InvoiceAmount,0)-" + "(" + SysString.ToDBString(entityDts.DInvoiceAmount) + ")";
                sql += ",DtsInvoiceDelOPID=" + SysString.ToDBString(entity.SaleOPID);
                sql += ",DtsInvoiceDelTime=null";
                sql += ",DtsInvoiceNo=''";
                sql += ",DtsInvoiceDelFlag=0";//开票完成标志
                sql += " WHERE ID=" + SysString.ToDBString(entityDts.DLOADDtsID);
                sqlTrans.ExecuteNonQuery(sql);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
        /// <summary>
        /// 保存(传入事务处理)
        /// </summary>
        /// <param name="p_Entity"></param>
        /// <param name="p_BE"></param>
        /// <param name="sqlTrans"></param>
        public void RSave(InvoiceOperation p_Entity, BaseEntity[] p_BE, 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
                    }
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Delete(BaseEntity p_Entity)
        {
            try
            {
                InvoiceOperationDts MasterEntity = (InvoiceOperationDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //删除主表数据
                string Sql = "";
                Sql = "DELETE FROM Finance_InvoiceOperationDts 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 void RHX(InvoiceOperation entity, InvoiceOperationDts entityDts)
        {
            try
            {
                IDBTransAccess sqlTrans = TransSysUtils.GetDBTransAccess();
                try
                {
                    sqlTrans.OpenTrans();

                    this.RHX(entity, entityDts, sqlTrans);

                    sqlTrans.CommitTrans();
                }
                catch (Exception TE)
                {
                    sqlTrans.RollbackTrans();
                    throw TE;
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
示例#5
0
        /// <summary>
        /// 获得核销明细实体
        /// </summary>
        /// <returns></returns>
        private InvoiceOperationDts EntityDtsGetOne()
        {
            InvoiceOperationDts entitydts = new InvoiceOperationDts();

            entitydts.MainID     = HTDataID;
            entitydts.DLOADID    = SysConvert.ToInt32(gridView2.GetRowCellValue(gridView2.FocusedRowHandle, "ID"));
            entitydts.DLOADDtsID = SysConvert.ToInt32(gridView2.GetRowCellValue(gridView2.FocusedRowHandle, "DtsID"));
            entitydts.DLOADSEQ   = SysConvert.ToInt32(gridView2.GetRowCellValue(gridView2.FocusedRowHandle, "Seq"));
            entitydts.DLOADNO    = SysConvert.ToString(gridView2.GetRowCellValue(gridView2.FocusedRowHandle, "FormNo"));

            entitydts.DInvoiceQty         = SysConvert.ToDecimal(txtPreHXQty.Text.Trim());
            entitydts.DInvoiceSinglePrice = SysConvert.ToDecimal(txtPreHXSingPrice.Text.Trim());
            entitydts.DInvoiceAmount      = entitydts.DInvoiceQty * entitydts.DInvoiceSinglePrice;
            entitydts.Remark = txtPreHXRemark.Text.Trim();

            entitydts.DInvoiceTaxAmount = SysConvert.ToDecimal(entitydts.DInvoiceAmount - entitydts.DInvoiceAmount / 1.17m, 5);

            entitydts.ItemCode  = SysConvert.ToString(gridView2.GetRowCellValue(gridView2.FocusedRowHandle, "ItemCode"));
            entitydts.ColorNum  = SysConvert.ToString(gridView2.GetRowCellValue(gridView2.FocusedRowHandle, "ColorNum"));
            entitydts.ColorName = SysConvert.ToString(gridView2.GetRowCellValue(gridView2.FocusedRowHandle, "ColorName"));



            return(entitydts);
        }
示例#6
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private InvoiceOperationDts[] EntityDtsGet()
        {
            int index = GetDataCompleteNum();

            InvoiceOperationDts[] entitydts = new InvoiceOperationDts[index];
            index = 0;
            for (int i = 0; i < gridView1.RowCount; i++)
            {
                if (CheckDataCompleteDts(i))
                {
                    entitydts[index]        = new InvoiceOperationDts();
                    entitydts[index].MainID = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "MainID"));
                    if (entitydts[index].MainID == HTDataID && HTDataID != 0)//已存在表示修改
                    {
                        entitydts[index].ID = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "ID"));
                        entitydts[index].SelectByID();
                    }
                    else//新增
                    {
                        entitydts[index].MainID = HTDataID;
                        entitydts[index].Seq    = i + 1;
                    }

                    entitydts[index].DLOADID             = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "DLOADID"));
                    entitydts[index].DLOADSEQ            = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "DLOADSEQ"));
                    entitydts[index].DLOADNO             = SysConvert.ToString(gridView1.GetRowCellValue(i, "DLOADNO"));
                    entitydts[index].DInvoiceQty         = SysConvert.ToDecimal(gridView1.GetRowCellValue(i, "DInvoiceQty"));
                    entitydts[index].DInvoiceSinglePrice = SysConvert.ToDecimal(gridView1.GetRowCellValue(i, "DInvoiceSinglePrice"));
                    entitydts[index].DInvoiceDYPrice     = SysConvert.ToDecimal(gridView1.GetRowCellValue(i, "DInvoiceDYPrice"));
                    entitydts[index].ItemCode            = SysConvert.ToString(gridView1.GetRowCellValue(i, "ItemCode"));
                    entitydts[index].ColorNum            = SysConvert.ToString(gridView1.GetRowCellValue(i, "ColorNum"));
                    entitydts[index].ColorName           = SysConvert.ToString(gridView1.GetRowCellValue(i, "ColorName"));
                    if (entitydts[index].DInvoiceSinglePrice != 0)
                    {
                        entitydts[index].DInvoiceAmount = entitydts[index].DInvoiceQty * entitydts[index].DInvoiceSinglePrice + entitydts[index].DInvoiceDYPrice;
                    }
                    else
                    {
                        entitydts[index].DInvoiceAmount = SysConvert.ToDecimal(gridView1.GetRowCellValue(i, "DInvoiceAmount")) + entitydts[index].DInvoiceDYPrice;
                    }
                    entitydts[index].Remark          = SysConvert.ToString(gridView1.GetRowCellValue(i, "Remark"));
                    entitydts[index].PayAmount       = SysConvert.ToDecimal(gridView1.GetRowCellValue(i, "PayAmount"));
                    entitydts[index].DLOADDtsID      = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "DLOADDtsID"));
                    entitydts[index].DLoadCheckDtsID = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "DLoadCheckDtsID"));
                    entitydts[index].Unit            = SysConvert.ToString(gridView1.GetRowCellValue(i, "Unit"));
                    entitydts[index].GoodsCode       = SysConvert.ToString(gridView1.GetRowCellValue(i, "GoodsCode"));

                    entitydts[index].DInvoiceTaxAmount = SysConvert.ToDecimal(entitydts[index].DInvoiceAmount - entitydts[index].DInvoiceAmount / 1.17m, 5);
                    entitydts[index].MergeFlage        = SysConvert.ToInt32(gridView1.GetRowCellValue(i, "MergeFlage"));
                    index++;
                }
            }
            return(entitydts);
        }
        /// <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++)
            {
                InvoiceOperationDts entitydts = (InvoiceOperationDts)p_BE[i];
                if (entitydts.ID != 0)
                {
                    outstr += "," + entitydts.ID;
                }
            }
            return(outstr);
        }
示例#8
0
        /// <summary>
        /// 核销操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPreHXExcute_Click(object sender, EventArgs e)
        {
            try
            {
                if (!FCommon.RightCheck(this.FormID, this.RightFormID, this.FormListAID, this.FormListBID, RightSub.新增))
                {
                    this.ShowMessage("你没有此操作权限");
                    return;
                }
                if (HTDataID == 0)
                {
                    this.ShowMessage("请定位主记录");
                    return;
                }
                if (HTDataSubmitFlag != (int)YesOrNo.Yes)
                {
                    this.ShowMessage("单据未提交,不能操作");
                    return;
                }

                if (saveIOFormDtsID == 0)
                {
                    this.ShowMessage("请选择对账记录");
                    return;
                }
                if (SysConvert.ToDecimal(txtPreHXQty.Text.Trim()) == 0)
                {
                    this.ShowMessage("请输入核销数量");
                    txtPreHXQty.Focus();
                    return;
                }

                InvoiceOperationRule rule      = new InvoiceOperationRule();
                InvoiceOperation     entity    = EntityGet();
                InvoiceOperationDts  entitydts = EntityDtsGetOne();

                rule.RHX(entity, entitydts);

                FCommon.AddDBLog(this.Text, "核销", "ID:" + HTDataID, "");
                this.SetPosStatus(HTDataID);

                this.BindGrid();
            }
            catch (Exception E)
            {
                this.ShowMessage(E.Message);
            }
        }
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="p_BE">要删除的实体</param>
 /// <param name="sqlTrans">事务类</param>
 public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans)
 {
     try
     {
         this.CheckCorrect(p_BE);
         InvoiceOperationDts    entity  = (InvoiceOperationDts)p_BE;
         InvoiceOperationDtsCtl control = new InvoiceOperationDtsCtl(sqlTrans);
         control.Delete(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
 /// <summary>
 /// 新增(传入事务处理)
 /// </summary>
 /// <param name="p_BE">要新增的实体</param>
 /// <param name="sqlTrans">事务类</param>
 public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans)
 {
     try
     {
         this.CheckCorrect(p_BE);
         InvoiceOperationDts    entity  = (InvoiceOperationDts)p_BE;
         InvoiceOperationDtsCtl control = new InvoiceOperationDtsCtl(sqlTrans);
         entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Finance_InvoiceOperationDts, sqlTrans);
         control.AddNew(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
 /// <summary>
 /// 检查将要操作的数据是否符合业务规则
 /// </summary>
 /// <param name="p_BE"></param>
 private void CheckCorrect(BaseEntity p_BE)
 {
     InvoiceOperationDts entity = (InvoiceOperationDts)p_BE;
 }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                InvoiceOperationDts MasterEntity = (InvoiceOperationDts)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //新增主表数据
                StringBuilder MasterField = new StringBuilder();
                StringBuilder MasterValue = new StringBuilder();
                MasterField.Append("INSERT INTO Finance_InvoiceOperationDts(");
                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("DLOADID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.DLOADID) + ",");
                MasterField.Append("DLOADSEQ" + ",");
                if (MasterEntity.DLOADSEQ != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.DLOADSEQ) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

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

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

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

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

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

                MasterField.Append("ItemCode" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ItemCode) + ",");
                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("DLoadCheckDtsID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.DLoadCheckDtsID) + ",");
                MasterField.Append("DInvoiceDYPrice" + ",");
                if (MasterEntity.DInvoiceDYPrice != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.DInvoiceDYPrice) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("Unit" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Unit) + ",");
                MasterField.Append("MergeFlage" + ")");
                MasterValue.Append(SysString.ToDBString(MasterEntity.MergeFlage) + ")");



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

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

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

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

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


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


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

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

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


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

                UpdateBuilder.Append(" ItemCode=" + SysString.ToDBString(MasterEntity.ItemCode) + ",");
                UpdateBuilder.Append(" ColorNum=" + SysString.ToDBString(MasterEntity.ColorNum) + ",");
                UpdateBuilder.Append(" ColorName=" + SysString.ToDBString(MasterEntity.ColorName) + ",");
                UpdateBuilder.Append(" GoodsCode=" + SysString.ToDBString(MasterEntity.GoodsCode) + ",");
                UpdateBuilder.Append(" DLoadCheckDtsID=" + SysString.ToDBString(MasterEntity.DLoadCheckDtsID) + ",");

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

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

                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);
            }
        }
示例#14
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="p_FormID"></param>
        /// <param name="p_Type"></param>
        /// <param name="sqlTrans"></param>
        private void SetInvoiceOperation(int p_FormID, int p_Type, IDBTransAccess sqlTrans)
        {
            string sql = "SELECT ID,MainID,Seq FROM Finance_InvoiceOperationDts WHERE MainID=" + SysString.ToDBString(p_FormID);

            sql += " ORDER BY Seq";
            DataTable dt = sqlTrans.Fill(sql);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    //对账单
                    InvoiceOperation entity = new InvoiceOperation(sqlTrans);
                    entity.ID = p_FormID;
                    entity.SelectByID();

                    ///对账单明细
                    InvoiceOperationDts entityDts = new InvoiceOperationDts(sqlTrans);
                    entityDts.ID = SysConvert.ToInt32(dr["ID"]);
                    entityDts.SelectByID();

                    ///仓库单据明细
                    IOFormDts entityIOF = new IOFormDts(sqlTrans);
                    if (entityDts.MergeFlage == 1)
                    {
                        if (entityDts.DLOADID > 0)
                        {
                            IOForm entityNoDts = new IOForm(sqlTrans);
                            entityNoDts.ID = entityDts.DLOADID;
                            entityNoDts.SelectByID();
                            if (entityNoDts.SelectByID())
                            {
                            }
                            else
                            {
                                throw new Exception("操作异常,没有找到出入库记录 ID:" + entityDts.DLOADID);
                            }
                            if (p_Type == (int)YesOrNo.Yes)//提交
                            {
                                //if (entityDts.DInvoiceQty + entityIOF.InvoiceQty > entityIOF.DZQty || entityDts.DInvoiceAmount + entityIOF.InvoiceAmount > entityIOF.DZAmount)//开票溢出
                                //{
                                //    throw new Exception("不能操作,开票数超过对账数 或 开票金额超过对账金额 ID:" + entityDts.DLOADDtsID + " " + entityIOF.ItemCode + " " + entityIOF.ColorNum);
                                //}
                                if (entityNoDts.InvoiceDelFlag == (int)YesOrNo.Yes && entityNoDts.TotalQty == entityNoDts.InvoiceQty)
                                {
                                    throw new Exception("不能操作,数据已开票结束 ID:" + entityDts.DLOADID);
                                    //+ " " + SysConvert.ToString(drs["ItemCode"]) + " " + SysConvert.ToString(drs["ColorNum"])
                                }
                                sql  = "UPDATE WH_IOForm SET InvoiceQty=ISNULL(InvoiceQty,0)+" + "(" + SysString.ToDBString(entityDts.DInvoiceQty) + ")";
                                sql += ",InvoiceAmount=ISNULL(InvoiceAmount,0)+" + "(" + SysString.ToDBString(SysConvert.ToDecimal(entityDts.DInvoiceAmount)) + ")";
                                sql += ",InvoiceDelOPID=" + SysString.ToDBString(entity.SaleOPID);
                                sql += ",InvoiceDelTime=" + SysString.ToDBString(entity.FormDate.ToString("yyyy-MM-dd"));
                                sql += ",InvoiceNo=" + SysString.ToDBString(entity.InvoiceNO);
                                if (entityDts.DInvoiceAmount + entityNoDts.InvoiceAmount >= entityNoDts.DZAmount) //开票完成
                                {
                                    sql += ",InvoiceDelFlag=1";
                                }
                                else
                                {
                                    sql += ",InvoiceDelFlag=0";
                                }
                                sql += " WHERE ID=" + SysString.ToDBString(entityNoDts.ID);
                                sqlTrans.ExecuteNonQuery(sql);

                                if (entityDts.DLoadCheckDtsID > 0)
                                {
                                    sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=1 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID);
                                    sqlTrans.ExecuteNonQuery(sql);
                                }
                            }
                            else//撤销提交
                            {
                                if (entityNoDts.PayAmount != 0)
                                {
                                    throw new Exception("不能操作,数据已有收付款数据 ID:" + entityDts.DLOADID);
                                }
                                sql  = "UPDATE WH_IOForm SET InvoiceQty=ISNULL(InvoiceQty,0)-" + "(" + SysString.ToDBString(entityDts.DInvoiceQty) + ")";
                                sql += ",InvoiceAmount=ISNULL(InvoiceAmount,0)-" + "(" + SysString.ToDBString(entityDts.DInvoiceAmount) + ")";
                                sql += ",InvoiceDelOPID=" + SysString.ToDBString(entity.SaleOPID);
                                sql += ",InvoiceDelTime=null";
                                sql += ",InvoiceNo=''";
                                if (entityNoDts.InvoiceQty == entityDts.DInvoiceQty)
                                {
                                    sql += ",InvoiceDelFlag=0";//开票完成标志
                                }
                                sql += " WHERE ID=" + SysString.ToDBString(entityNoDts.ID);
                                sqlTrans.ExecuteNonQuery(sql);

                                if (entityDts.DLoadCheckDtsID > 0)
                                {
                                    sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=0 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID);
                                    sqlTrans.ExecuteNonQuery(sql);
                                }
                            }
                        }
                        else
                        {
                            if (p_Type == (int)YesOrNo.Yes)//提交
                            {
                                if (entityDts.DLoadCheckDtsID > 0)
                                {
                                    sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=1 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID);
                                    sqlTrans.ExecuteNonQuery(sql);
                                }
                            }
                            else
                            {
                                if (entityDts.DLoadCheckDtsID > 0)
                                {
                                    sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=0 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID);
                                    sqlTrans.ExecuteNonQuery(sql);
                                }
                            }
                        }
                    }
                    else
                    {
                        entityIOF.ID = entityDts.DLOADDtsID;
                        if (entityDts.DLOADDtsID > 0)
                        {
                            if (entityIOF.SelectByID())
                            {
                            }
                            else
                            {
                                throw new Exception("操作异常,没有找到出入库记录 ID:" + entityDts.DLOADDtsID);
                            }
                            if (p_Type == (int)YesOrNo.Yes)//提交
                            {
                                if (entityIOF.DtsInvoiceDelFlag == (int)YesOrNo.Yes && entityIOF.Qty == entityIOF.InvoiceQty)
                                {
                                    throw new Exception("不能操作,数据已开票结束 ID:" + entityDts.DLOADDtsID + " " + entityIOF.ItemCode + " " + entityIOF.ColorNum);
                                }
                                //if (entityDts.DInvoiceQty + entityIOF.InvoiceQty > entityIOF.DZQty || entityDts.DInvoiceAmount + entityIOF.InvoiceAmount > entityIOF.DZAmount)//开票溢出
                                //{
                                //    throw new Exception("不能操作,开票数超过对账数 或 开票金额超过对账金额 ID:" + entityDts.DLOADDtsID + " " + entityIOF.ItemCode + " " + entityIOF.ColorNum);
                                //}

                                sql  = "UPDATE WH_IOFormDts SET InvoiceQty=ISNULL(InvoiceQty,0)+" + "(" + SysString.ToDBString(entityDts.DInvoiceQty) + ")";
                                sql += ",InvoiceAmount=ISNULL(InvoiceAmount,0)+" + "(" + SysString.ToDBString(entityDts.DInvoiceAmount) + ")";
                                sql += ",DtsInvoiceDelOPID=" + SysString.ToDBString(entity.SaleOPID);
                                sql += ",DtsInvoiceDelTime=" + SysString.ToDBString(entity.FormDate.ToString("yyyy-MM-dd"));
                                sql += ",DtsInvoiceNo=" + SysString.ToDBString(entity.InvoiceNO);
                                if (entityDts.DInvoiceAmount + entityIOF.InvoiceAmount >= entityIOF.DZAmount)//开票完成
                                {
                                    sql += ",DtsInvoiceDelFlag=1";
                                }
                                else
                                {
                                    sql += ",DtsInvoiceDelFlag=0";
                                }
                                sql += " WHERE ID=" + SysString.ToDBString(entityDts.DLOADDtsID);
                                sqlTrans.ExecuteNonQuery(sql);

                                if (entityDts.DLoadCheckDtsID > 0)
                                {
                                    sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=1 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID);
                                    sqlTrans.ExecuteNonQuery(sql);
                                }
                            }
                            else//撤销提交
                            {
                                if (entityIOF.PayAmount != 0)
                                {
                                    throw new Exception("不能操作,数据已有收付款数据 ID:" + entityDts.DLOADDtsID + " " + entityIOF.ItemCode + " " + entityIOF.ColorNum);
                                }

                                sql  = "UPDATE WH_IOFormDts SET InvoiceQty=ISNULL(InvoiceQty,0)-" + "(" + SysString.ToDBString(entityDts.DInvoiceQty) + ")";
                                sql += ",InvoiceAmount=ISNULL(InvoiceAmount,0)-" + "(" + SysString.ToDBString(entityDts.DInvoiceAmount) + ")";
                                sql += ",DtsInvoiceDelOPID=" + SysString.ToDBString(entity.SaleOPID);
                                sql += ",DtsInvoiceDelTime=null";
                                sql += ",DtsInvoiceNo=''";
                                if (entityIOF.InvoiceQty == entityDts.DInvoiceQty)
                                {
                                    sql += ",DtsInvoiceDelFlag=0";//开票完成标志
                                }
                                sql += " WHERE ID=" + SysString.ToDBString(entityDts.DLOADDtsID);
                                sqlTrans.ExecuteNonQuery(sql);

                                if (entityDts.DLoadCheckDtsID > 0)
                                {
                                    sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=0 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID);
                                    sqlTrans.ExecuteNonQuery(sql);
                                }
                            }
                        }
                        else
                        {
                            if (p_Type == (int)YesOrNo.Yes)//提交
                            {
                                if (entityDts.DLoadCheckDtsID > 0)
                                {
                                    sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=1 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID);
                                    sqlTrans.ExecuteNonQuery(sql);
                                }
                            }
                            else
                            {
                                if (entityDts.DLoadCheckDtsID > 0)
                                {
                                    sql = "UPDATE Finance_CheckOperationDts SET InvoiceFlag=0 WHERE ID=" + SysString.ToDBString(entityDts.DLoadCheckDtsID);
                                    sqlTrans.ExecuteNonQuery(sql);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#15
0
        /// <summary>
        /// 核销处理
        /// </summary>
        public void RHX(InvoiceOperation entity, InvoiceOperationDts entityDts, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = string.Empty;
                //First 处理发票主表数据
                InvoiceOperation entityinvoice = new InvoiceOperation(sqlTrans);//处理收付款主表数据
                entityinvoice.ID = entity.ID;
                entityinvoice.SelectByID();

                if (entityinvoice.PreHXAmount + entityDts.DInvoiceAmount > entityinvoice.TotalAmount)
                {
                    throw new Exception("不能操作,核销金额超过了开票未核金额");
                }
                if (entityinvoice.PreHXQty + entityDts.DInvoiceQty > entityinvoice.TotalQty)
                {
                    throw new Exception("不能操作,核销数量超过了开票未核数量");
                }
                if (entityinvoice.PreHXAmount + entityDts.DInvoiceAmount == entityinvoice.TotalAmount)
                {
                    entityinvoice.PreHXFlag = (int)YesOrNo.Yes;
                }
                entityinvoice.PreHXQty    += entityDts.DInvoiceQty;
                entityinvoice.PreHXAmount += entityDts.DInvoiceAmount;
                this.RUpdate(entityinvoice, sqlTrans);


                //Second

                IOFormDtsRule ioformdtsRule = new IOFormDtsRule();     //处理出入库单据明细数据
                IOFormDts     entityIOF     = new IOFormDts(sqlTrans); //出入库单据明细
                entityIOF.ID = entityDts.DLOADDtsID;
                entityIOF.SelectByID();

                if (entityIOF.DtsInvoiceDelFlag == (int)YesOrNo.Yes)
                {
                    throw new Exception("不能操作,数据已开票结束 ID:" + entityDts.DLOADDtsID + " " + entityIOF.ItemCode + " " + entityIOF.ColorNum);
                }
                if (entityDts.DInvoiceQty + entityIOF.InvoiceQty > entityIOF.DZQty || entityDts.DInvoiceAmount + entityIOF.InvoiceAmount > entityIOF.DZAmount)//开票溢出
                {
                    throw new Exception("不能操作,开票数超过对账数 或 开票金额超过对账金额 ID:" + entityDts.DLOADDtsID + " " + entityIOF.ItemCode + " " + entityIOF.ColorNum);
                }

                sql  = "UPDATE WH_IOFormDts SET InvoiceQty=ISNULL(InvoiceQty,0)+" + "(" + SysString.ToDBString(entityDts.DInvoiceQty) + ")";
                sql += ",InvoiceAmount=ISNULL(InvoiceAmount,0)+" + "(" + SysString.ToDBString(entityDts.DInvoiceAmount) + ")";
                sql += ",DtsInvoiceDelOPID=" + SysString.ToDBString(entity.SaleOPID);
                sql += ",DtsInvoiceDelTime=" + SysString.ToDBString(entity.FormDate.ToString("yyyy-MM-dd"));
                sql += ",DtsInvoiceNo=" + SysString.ToDBString(entity.InvoiceNO);
                if (entityDts.DInvoiceAmount + entityIOF.InvoiceAmount >= entityIOF.DZAmount)//开票完成
                {
                    sql += ",DtsInvoiceDelFlag=1";
                }
                else
                {
                    sql += ",DtsInvoiceDelFlag=0";
                }
                sql += " WHERE ID=" + SysString.ToDBString(entityDts.DLOADDtsID);
                sqlTrans.ExecuteNonQuery(sql);


                InvoiceOperationDtsRule dtsRule = new InvoiceOperationDtsRule();
                entityDts.MainID = entity.ID;
                entityDts.Seq    = SysConvert.ToInt32(sqlTrans.Fill("SELECT ISNULL(MAX(Seq),0)+1 FROM Finance_InvoiceOperationDts WHERE MainID=" + entity.ID).Rows[0][0]);//取最大的MAXSEQ值

                dtsRule.RAdd(entityDts, sqlTrans);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }