Exemple #1
0
        /// <summary>
        /// 收款作废
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BarButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            int      rowHandle = gridView1.FocusedRowHandle;
            DateTime dt_fa200;                 //收费日期



            if (rowHandle >= 0)
            {
                //只能作废当日收费记录
                DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
                dtFormat.ShortDatePattern = "yyyy-MM-dd";
                dt_fa200 = Convert.ToDateTime(gridView1.GetRowCellValue(rowHandle, "FA200").ToString(), dtFormat);
                if (String.Compare(dt_fa200.ToString("yyyy-MM-dd"), MiscAction.GetServerDateString()) < 0 && Envior.cur_userId != AppInfo.ROOTID)
                {
                    MessageBox.Show("只能作废当天的收费记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (MessageBox.Show("确认要作废吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    return;
                }
                string s_rc001 = gridView1.GetRowCellValue(rowHandle, "AC001").ToString();
                if (Convert.ToDecimal(gridView1.GetRowCellValue(rowHandle, "FA004")) < 0)
                {
                    MessageBox.Show("退费业务不能作废!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (gridView1.GetRowCellValue(rowHandle, "FA002").ToString() == "2")                  //寄存业务
                {
                    decimal count = (decimal)SqlAssist.ExecuteScalar("select count(*) from v_rc04 where rc001='" + s_rc001 + "'", null);
                    if (count <= 1)
                    {
                        if (MessageBox.Show("此记录是唯一一次交费记录,作废此记录将删除寄存登记信息,是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                        {
                            return;
                        }
                    }
                }

                string s_fa001   = gridView1.GetRowCellValue(rowHandle, "FA001").ToString();
                string s_fa005   = gridView1.GetRowCellValue(rowHandle, "FA005").ToString();                 //电子发票号
                string s_retCode = string.Empty;

                int re = MiscAction.FinanceRemove(s_fa001, Envior.cur_userId);
                if (re > 0)
                {
                    ////////// 发票作废 ///////////////////////////////////////////////////
                    if (!string.IsNullOrEmpty(s_fa005))
                    {
                        if (!Envior.TAX_READY)
                        {
                            MessageBox.Show("金税卡没有打开!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        else
                        {
                            s_retCode = PrtServAction.InvoiceRemoved(s_fa001, Envior.mform.Handle.ToInt32());
                        }
                    }
                    ///////////////////////////////////////////////////////////////////////

                    if (!string.IsNullOrEmpty(s_fa005) && s_retCode == "6011")
                    {
                        MessageBox.Show("作废成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (!string.IsNullOrEmpty(s_fa005) && s_retCode != "6011")
                    {
                        MessageBox.Show("作废成功但未作废发票!" + s_retCode, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        MessageBox.Show("作废成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }


                    //MessageBox.Show("作废成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dt_finance.Rows.RemoveAt(gridView1.GetDataSourceRowIndex(rowHandle));
                    if (gridView1.RowCount == 0)
                    {
                        dt_detail.Rows.Clear();
                    }
                    else
                    {
                        this.RetrieveDetail(gridView1.FocusedRowHandle);
                    }
                    return;
                }
            }
        }