Exemplo n.º 1
0
        //发票接收
        protected void imgbtn_Receive_Click(object sender, EventArgs e)
        {
            var    invoice     = ((ImageButton)sender).CommandArgument;
            var    invoiceInfo = invoice.Split(',');
            string invoiceId   = invoiceInfo[0];
            string invoiceType = invoiceInfo[1];
            CompanyFundReceiptInvoiceInfo model =
                _companyFundReceiptInvoice.Getlmshop_CompanyFundReceiptInvoiceByInvoiceId(new Guid(invoiceId));

            if (model.InvoiceState.Equals((int)CompanyFundReceiptInvoiceState.Submit))
            {
                string remark = WebControl.RetrunUserAndTime("【接收发票】");
                if (invoiceType.Equals("1"))
                {
                    _companyFundReceiptInvoice.Updatelmshop_CompanyFundReceiptInvoiceByInvoiceId(remark, new Guid(invoiceId),
                                                                                                 (int)CompanyFundReceiptInvoiceState.Verification);
                }
                else
                {
                    _companyFundReceiptInvoice.Updatelmshop_CompanyFundReceiptInvoiceByInvoiceId(remark, new Guid(invoiceId),
                                                                                                 (int)CompanyFundReceiptInvoiceState.Receive);
                }
                MessageBox.AppendScript(this, "setTimeout(function(){ refreshGrid(); }, " + GlobalConfig.PageAutoRefreshDelayTime + ");");
            }
            else
            {
                MessageBox.Show(this, "状态已更新,不允许此操作!");
            }
        }
        /// <summary>
        /// 向lmshop_CompanyFundReceiptInvoice表插入一条数据
        /// </summary>
        /// <param name="lmshopCompanyFundReceiptInvoice">lmshop_CompanyFundReceiptInvoice</param>
        /// <returns></returns>
        public bool Addlmshop_CompanyFundReceiptInvoice(CompanyFundReceiptInvoiceInfo lmshopCompanyFundReceiptInvoice)
        {
            string sql = "insert into [lmshop_CompanyFundReceiptInvoice]([InvoiceId],[ReceiptID],[BillingUnit],[BillingDate],[InvoiceNo],[InvoiceCode],[NoTaxAmount],[Tax],[TaxAmount],[InvoiceState],[OperatingTime],[Memo],[Remark])values(@InvoiceId,@ReceiptID,@BillingUnit,@BillingDate,@InvoiceNo,@InvoiceCode,@NoTaxAmount,@Tax,@TaxAmount,@InvoiceState,@OperatingTime,@Memo,@Remark)";

            SqlParameter[] paras = PrepareCommandParameters(lmshopCompanyFundReceiptInvoice);
            return(SqlHelper.ExecuteNonQuery(GlobalConfig.ERP_DB_NAME, false, sql, paras) > 0);
        }
        /// <summary>
        /// 根据lmshop_CompanyFundReceiptInvoice表的InvoiceId字段更新数据
        /// </summary>
        /// <param name="lmshopCompanyFundReceiptInvoice">lmshopCompanyFundReceiptInvoice</param>
        /// <returns></returns>
        public bool Updatelmshop_CompanyFundReceiptInvoiceByInvoiceId(CompanyFundReceiptInvoiceInfo lmshopCompanyFundReceiptInvoice)
        {
            string sql = "update [lmshop_CompanyFundReceiptInvoice] set [ReceiptID] = @ReceiptID,[BillingUnit]=@BillingUnit,[BillingDate] = @BillingDate,[InvoiceNo] = @InvoiceNo,[InvoiceCode] = @InvoiceCode,[NoTaxAmount] = @NoTaxAmount,[Tax] = @Tax,[TaxAmount] = @TaxAmount,[InvoiceState] = @InvoiceState,[OperatingTime] = @OperatingTime,[Memo] = @Memo,[Remark]=@Remark where [InvoiceId] = @InvoiceId";

            SqlParameter[] paras = PrepareCommandParameters(lmshopCompanyFundReceiptInvoice);
            return(SqlHelper.ExecuteNonQuery(GlobalConfig.ERP_DB_NAME, false, sql, paras) > 0);
        }
        /// <summary>
        /// 返回lmshop_CompanyFundReceiptInvoice表的所有数据
        /// </summary>
        /// <returns></returns>
        public List <CompanyFundReceiptInvoiceInfo> GetAlllmshop_CompanyFundReceiptInvoice()
        {
            List <CompanyFundReceiptInvoiceInfo> lmshopCompanyFundReceiptInvoiceList = new List <CompanyFundReceiptInvoiceInfo>();

            string sql    = SQL_SELECT;
            var    reader = SqlHelper.ExecuteReader(GlobalConfig.ERP_DB_NAME, true, sql, null);

            while (reader.Read())
            {
                CompanyFundReceiptInvoiceInfo lmshopCompanyFundReceiptInvoice = new CompanyFundReceiptInvoiceInfo(reader);
                lmshopCompanyFundReceiptInvoiceList.Add(lmshopCompanyFundReceiptInvoice);
            }
            reader.Close();
            return(lmshopCompanyFundReceiptInvoiceList);
        }
        /// <summary>
        /// 根据lmshop_CompanyFundReceiptInvoice表的InvoiceId字段返回数据
        /// </summary>
        /// <param name="invoiceId">InvoiceId</param>
        /// <returns></returns>
        public CompanyFundReceiptInvoiceInfo Getlmshop_CompanyFundReceiptInvoiceByInvoiceId(Guid invoiceId)
        {
            CompanyFundReceiptInvoiceInfo lmshopCompanyFundReceiptInvoice = null;

            string sql = SQL_SELECT + "where [InvoiceId] = @InvoiceId";

            SqlParameter[] paras = new SqlParameter[] {
                new SqlParameter("@InvoiceId", invoiceId)
            };
            var reader = SqlHelper.ExecuteReader(GlobalConfig.ERP_DB_NAME, true, sql, paras);

            if (reader.Read())
            {
                lmshopCompanyFundReceiptInvoice = new CompanyFundReceiptInvoiceInfo(reader);
            }
            reader.Close();
            return(lmshopCompanyFundReceiptInvoice);
        }
Exemplo n.º 6
0
        //发票认证完成
        protected void imgbtn_Verification_Click(object sender, EventArgs e)
        {
            var invoiceId = ((ImageButton)sender).CommandArgument;
            CompanyFundReceiptInvoiceInfo model =
                _companyFundReceiptInvoice.Getlmshop_CompanyFundReceiptInvoiceByInvoiceId(new Guid(invoiceId));

            if (model.InvoiceState.Equals((int)CompanyFundReceiptInvoiceState.Authenticate))
            {
                string remark = WebControl.RetrunUserAndTime("【发票认证完成】");
                _companyFundReceiptInvoice.Updatelmshop_CompanyFundReceiptInvoiceByInvoiceId(remark, new Guid(invoiceId),
                                                                                             (int)CompanyFundReceiptInvoiceState.Verification);
                MessageBox.AppendScript(this, "setTimeout(function(){ refreshGrid(); }, " + GlobalConfig.PageAutoRefreshDelayTime + ");");
            }
            else
            {
                MessageBox.Show(this, "状态已更新,不允许此操作!");
            }
        }
        /// <summary>
        /// 根据lmshop_CompanyFundReceiptInvoice表的receiptId字段返回数据
        /// </summary>
        /// <param name="receiptId">receiptId</param>
        /// <returns></returns>
        public List <CompanyFundReceiptInvoiceInfo> Getlmshop_CompanyFundReceiptInvoiceByReceiptID(Guid receiptId)
        {
            List <CompanyFundReceiptInvoiceInfo> lmshopCompanyFundReceiptInvoiceList = new List <CompanyFundReceiptInvoiceInfo>();

            string sql = SQL_SELECT + "where [ReceiptID] = @ReceiptID";

            SqlParameter[] paras = new SqlParameter[] {
                new SqlParameter("@ReceiptID", receiptId)
            };
            var reader = SqlHelper.ExecuteReader(GlobalConfig.ERP_DB_NAME, true, sql, paras);

            while (reader.Read())
            {
                CompanyFundReceiptInvoiceInfo lmshopCompanyFundReceiptInvoice = new CompanyFundReceiptInvoiceInfo(reader);
                lmshopCompanyFundReceiptInvoiceList.Add(lmshopCompanyFundReceiptInvoice);
            }
            reader.Close();
            return(lmshopCompanyFundReceiptInvoiceList);
        }
 /// <summary>
 /// prepare parameters
 /// </summary>
 public static SqlParameter[] PrepareCommandParameters(CompanyFundReceiptInvoiceInfo lmshopCompanyFundReceiptInvoice)
 {
     SqlParameter[] paras = new SqlParameter[] {
         new SqlParameter("@InvoiceId", lmshopCompanyFundReceiptInvoice.InvoiceId),
         new SqlParameter("@ReceiptID", lmshopCompanyFundReceiptInvoice.ReceiptID),
         new SqlParameter("@BillingUnit", lmshopCompanyFundReceiptInvoice.BillingUnit),
         new SqlParameter("@BillingDate", lmshopCompanyFundReceiptInvoice.BillingDate),
         new SqlParameter("@InvoiceNo", lmshopCompanyFundReceiptInvoice.InvoiceNo),
         new SqlParameter("@InvoiceCode", lmshopCompanyFundReceiptInvoice.InvoiceCode),
         new SqlParameter("@NoTaxAmount", lmshopCompanyFundReceiptInvoice.NoTaxAmount),
         new SqlParameter("@Tax", lmshopCompanyFundReceiptInvoice.Tax),
         new SqlParameter("@TaxAmount", lmshopCompanyFundReceiptInvoice.TaxAmount),
         new SqlParameter("@InvoiceState", lmshopCompanyFundReceiptInvoice.InvoiceState),
         new SqlParameter("@OperatingTime", lmshopCompanyFundReceiptInvoice.OperatingTime),
         new SqlParameter("@Memo", lmshopCompanyFundReceiptInvoice.Memo),
         new SqlParameter("@Remark", lmshopCompanyFundReceiptInvoice.Remark)
     };
     return(paras);
 }
Exemplo n.º 9
0
        //发票删除
        protected void imgbtn_Del_Click(object sender, EventArgs e)
        {
            var invoiceId = ((ImageButton)sender).CommandArgument;
            CompanyFundReceiptInvoiceInfo model =
                _companyFundReceiptInvoice.Getlmshop_CompanyFundReceiptInvoiceByInvoiceId(new Guid(invoiceId));

            if (model.InvoiceState.Equals((int)CompanyFundReceiptInvoiceState.UnSubmit))
            {
                var result =
                    _companyFundReceiptInvoice.Deletelmshop_CompanyFundReceiptInvoiceByInvoiceId(new Guid(invoiceId));
                if (result)
                {
                    MessageBox.AppendScript(this, "setTimeout(function(){ refreshGrid(); }, " + GlobalConfig.PageAutoRefreshDelayTime + ");");
                }
            }
            else
            {
                MessageBox.Show(this, "状态已更新,不允许此操作!");
            }
        }
Exemplo n.º 10
0
 //发票批量认证完成
 protected void btn_BatchVerification_Click(object sender, EventArgs e)
 {
     if (Request["ckId"] != null)
     {
         var errorMsg   = new StringBuilder();
         var invoiceIds = Request["ckId"].Split(',');
         foreach (var item in invoiceIds)
         {
             CompanyFundReceiptInvoiceInfo model =
                 _companyFundReceiptInvoice.Getlmshop_CompanyFundReceiptInvoiceByInvoiceId(new Guid(item));
             if (model.InvoiceState != (int)CompanyFundReceiptInvoiceState.Authenticate)
             {
                 errorMsg.Append("发票号码“").Append(model.InvoiceNo).Append("”状态已更新,不允许此操作!").Append("\\n");
                 continue;
             }
             try
             {
                 string remark = WebControl.RetrunUserAndTime("【发票认证完成】");
                 _companyFundReceiptInvoice.Updatelmshop_CompanyFundReceiptInvoiceByInvoiceId(remark,
                                                                                              new Guid(item), (int)CompanyFundReceiptInvoiceState.Verification);
             }
             catch
             {
                 errorMsg.Append("发票号码“").Append(model.InvoiceNo).Append("”保存失败!").Append("\\n");
             }
         }
         if (!string.IsNullOrEmpty(errorMsg.ToString()))
         {
             MessageBox.Show(this, errorMsg.ToString());
         }
         MessageBox.AppendScript(this, "setTimeout(function(){ refreshGrid(); }, " + GlobalConfig.PageAutoRefreshDelayTime + ");");
     }
     else
     {
         MessageBox.Show(this, "请选择相关数据!");
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// 根据lmshop_CompanyFundReceiptInvoice表的InvoiceId字段更新数据
 /// </summary>
 /// <param name="lmshopCompanyFundReceiptInvoice">lmshopCompanyFundReceiptInvoice</param>
 /// <returns>返回受影响的行数</returns>
 public bool Updatelmshop_CompanyFundReceiptInvoiceByInvoiceId(CompanyFundReceiptInvoiceInfo lmshopCompanyFundReceiptInvoice)
 {
     return(_companyFundReceiptInvoiceDao.Updatelmshop_CompanyFundReceiptInvoiceByInvoiceId(lmshopCompanyFundReceiptInvoice));
 }
Exemplo n.º 12
0
 /// <summary>
 /// 向lmshop_CompanyFundReceiptInvoice表插入一条数据,插入成功则返回自增列数值,插入不成功则返回-1
 /// </summary>
 /// <param name="lmshopCompanyFundReceiptInvoice">lmshop_CompanyFundReceiptInvoice</param>
 /// <returns></returns>
 public bool Addlmshop_CompanyFundReceiptInvoice(CompanyFundReceiptInvoiceInfo lmshopCompanyFundReceiptInvoice)
 {
     return(_companyFundReceiptInvoiceDao.Addlmshop_CompanyFundReceiptInvoice(lmshopCompanyFundReceiptInvoice));
 }
Exemplo n.º 13
0
        public ResultInfo InvoicePass(Guid receiptId, string invoiceUnit, List <InvoiceRelationInfo> invoiceRelations, string remark, Guid personnelId)
        {
            try
            {
                if (invoiceRelations.All(ent => !ent.IsCanEdit))
                {
                    return(new ResultInfo(false, "请录入需新增的发票信息!"));
                }
                var companyFundReceiot = _companyFundReceiptDao.GetCompanyFundReceiptInfo(receiptId);
                if (companyFundReceiot == null)
                {
                    return(new ResultInfo(false, "未找到对应的申请单据信息!"));
                }
                if (companyFundReceiot.ReceiptStatus != (int)CompanyFundReceiptState.WaitInvoice)
                {
                    return(new ResultInfo(false, "只有待开票/开票中状态下的往来账收款才允许开票操作!"));
                }
                if (Math.Abs(invoiceRelations.Sum(ent => ent.TotalFee)) > companyFundReceiot.RealityBalance)
                {
                    return(new ResultInfo(false, "开票金额不能大于收款金额!"));
                }
                bool isEqual = Math.Abs(invoiceRelations.Sum(ent => ent.TotalFee)) == companyFundReceiot.RealityBalance;
                using (var tran = new TransactionScope(TransactionScopeOption.Required))
                {
                    var result = _companyFundReceiptDao.UpdateInvoice(receiptId,
                                                                      isEqual ?(int)CompanyFundReceiptState.Audited:(int)CompanyFundReceiptState.WaitInvoice, invoiceUnit,
                                                                      isEqual ? (int)ApplyInvoiceState.Finished
                            : (int)ApplyInvoiceState.Invoicing, remark, isEqual?personnelId:Guid.Empty);
                    if (!result)
                    {
                        return(new ResultInfo(result, "往来账收款单开票失败!"));
                    }
                    bool success = true;
                    foreach (var invoiceGroup in invoiceRelations.Where(ent => ent.IsCanEdit).GroupBy(ent => ent.InvoiceNo))
                    {
                        if (invoiceGroup.Count() > 1)
                        {
                            return(new ResultInfo(false, string.Format("发票添加重复【票据号码{0}】", invoiceGroup.Key)));
                        }
                        var item = invoiceGroup.First();
                        CompanyFundReceiptInvoiceInfo companyFundReceiptInvoiceInfo = new CompanyFundReceiptInvoiceInfo();
                        companyFundReceiptInvoiceInfo.BillingDate = item.RequestTime;
                        companyFundReceiptInvoiceInfo.BillingUnit = invoiceUnit;
                        companyFundReceiptInvoiceInfo.InvoiceCode = item.InvoiceCode;
                        companyFundReceiptInvoiceInfo.InvoiceNo   = item.InvoiceNo;
                        companyFundReceiptInvoiceInfo.InvoiceId   = item.InvoiceId;
                        companyFundReceiptInvoiceInfo.Remark      = item.Remark;
                        companyFundReceiptInvoiceInfo.TaxAmount   = item.TotalFee;
                        companyFundReceiptInvoiceInfo.ReceiptID   = item.ApplyId;

                        success = _companyFundReceiptInvoice.Addlmshop_CompanyFundReceiptInvoice(companyFundReceiptInvoiceInfo);
                        if (!success)
                        {
                            break;
                        }
                    }
                    if (success)
                    {
                        tran.Complete();
                        return(new ResultInfo(true, ""));
                    }
                    return(new ResultInfo(false, "插入发票失败"));
                }
            }
            catch (Exception ex)
            {
                return(new ResultInfo(false, ex.Message));
            }
        }