Beispiel #1
0
        public string CheckDZRed(Djfp dj)
        {
            Fpxx   fpxx     = dj.Fpxx;
            string blueFpdm = fpxx.blueFpdm;
            string blueFphm = fpxx.blueFphm;
            string str3     = "";
            int    result   = 0;

            if (int.TryParse(blueFphm, out result))
            {
                blueFpxx = new FpManager().GetXxfp(this.fplx, blueFpdm, result);
            }
            else
            {
                str3 = string.Format("本张发票不能开红字发票!原因:YFP_HM有误", new object[0]);
            }
            if (blueFpxx != null)
            {
                string str4 = this.CanRedFp(fpxx.je);
                if (str4 != "")
                {
                    str3 = string.Format("本张发票不能开红字发票!原因:{0}", str4);
                }
                return(str3);
            }
            string str5 = this.CanEmptyRedFp(blueFpdm, blueFphm, fpxx.je);

            if (str5 != "")
            {
                str3 = string.Format("本张发票不能开红字发票!原因:{0}", str5);
            }
            return(str3);
        }
Beispiel #2
0
 private void TKfpxx(Djfp dj)
 {
     if ((((int)this.fplx == 0) || ((int)this.fplx == 2)) && (this.invoiceForm != null))
     {
         this.invoiceForm.FillDjxx(dj);
         this.backgroundWorker1.ReportProgress(2, dj);
         this.invoiceForm.AutoImportZpfp(this, dj);
         for (int i = 0; i < 5; i++)
         {
             this.backgroundWorker1.ReportProgress(7, null);
         }
     }
     else if (((int)this.fplx == 0x33) && (this.dzinvoiceForm != null))
     {
         if (dj.Fpxx.isRed)
         {
             this.dzinvoiceForm.FillDjxx(dj, true);
         }
         else
         {
             this.dzinvoiceForm.FillDjxx(dj, false);
         }
         this.backgroundWorker1.ReportProgress(2, dj);
         this.dzinvoiceForm.AutoImportDzfp(this, dj);
         for (int j = 0; j < 5; j++)
         {
             this.backgroundWorker1.ReportProgress(7, null);
         }
     }
     else if (((int)this.fplx == 11) && (this.hyInvoiceForm != null))
     {
         this.hyInvoiceForm.FillDjxx(dj);
         this.backgroundWorker1.ReportProgress(2, dj);
         this.hyInvoiceForm.AutoImporthyfp(this, dj);
         for (int k = 0; k < 5; k++)
         {
             this.backgroundWorker1.ReportProgress(7, null);
         }
     }
     else if (((int)this.fplx == 12) && (this.jdcInvoiceForm != null))
     {
         this.jdcInvoiceForm.FillDjxx(dj);
         this.backgroundWorker1.ReportProgress(2, dj);
         this.jdcInvoiceForm.AutoImportjdcfp(this, dj);
         for (int m = 0; m < 5; m++)
         {
             this.backgroundWorker1.ReportProgress(7, null);
         }
     }
     Thread.Sleep(0x3e8);
 }
Beispiel #3
0
        private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            int progressPercentage = e.ProgressPercentage;

            if (progressPercentage == 0)
            {
                this.SetProgressTip();
                this.ResetProgressValue();
            }
            else if (progressPercentage < 5)
            {
                this.SetProgress(progressPercentage);
                Djfp userState = e.UserState as Djfp;
                if (userState != null)
                {
                    if (this.invoiceForm != null)
                    {
                        this.invoiceForm.ShowImprotFp(userState);
                    }
                    else if (this.dzinvoiceForm != null)
                    {
                        this.dzinvoiceForm.ShowImprotFp(userState);
                    }
                    else if (this.hyInvoiceForm != null)
                    {
                        this.hyInvoiceForm.ShowImprotFp(userState);
                    }
                    else if (this.jdcInvoiceForm != null)
                    {
                        this.jdcInvoiceForm.ShowImprotFp(userState);
                    }
                }
            }
            else
            {
                this.SetProgress(progressPercentage - 5);
            }
        }
Beispiel #4
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     foreach (string str in this.djFiles)
     {
         this.mFileName = str.Substring(str.LastIndexOf('\\') + 1);
         string bfFile = Path.Combine(this.bfPath, this.mFileName);
         int    length = this.mFileName.Length;
         string str3   = this.mFileName.Substring(0, length - 4) + "_开票结果.TXT";
         this.hxFileNamexml = this.mFileName.Substring(0, length - 4) + "_开票结果.xml";
         List <string> list = this.djHelper.QueryYkdj(this.mFileName);
         if ((int)(int)this.fplx == 0x33)
         {
             doc = new XmlDocument();
             XmlDeclaration newChild = doc.CreateXmlDeclaration("1.0", "GBK", null);
             doc.AppendChild(newChild);
             bus = doc.CreateElement("business");
             doc.AppendChild(bus);
         }
         else
         {
             writer = new StreamWriter(new FileStream(Path.Combine(this.hxPath, str3), FileMode.Append, FileAccess.Write, FileShare.ReadWrite), ToolUtil.GetEncoding());
         }
         List <Djfp> list2 = this.ParseDjFile(str);
         success = true;
         for (int i = 0; (i < list2.Count) && success; i++)
         {
             jqbh       = "";
             fp_dm      = "";
             fp_hm      = "";
             kprq       = "";
             fp_mw      = "";
             jym        = "";
             ewm        = "";
             bz         = "";
             returncode = "0000";
             returnmsg  = "";
             Djfp dj = list2[i];
             this.mDjh = dj.Djh;
             this.backgroundWorker1.ReportProgress(0, null);
             bool flag = false;
             if (list.Contains(this.mDjh))
             {
                 flag = false;
                 object[] args = new object[] { base.TaxCardInstance.TaxClock.ToString("yyyy-MM-dd HH:mm:ss"), this.mDjh, 0, "该单据已成功填开过发票,不可重复开具!" };
                 KpResult   = string.Format("[{0}] 单据号:{1},开具结果:{2},开具失败原因:{3}", args);
                 returncode = "0001";
                 returnmsg  = "该单据已成功填开过发票,不可重复开具!";
                 this.backgroundWorker1.ReportProgress(15, null);
             }
             else if (((int)(int)this.fplx == 0x33) && dj.Fpxx.isRed)
             {
                 string str4 = this.CheckDZRed(dj);
                 if (str4 != "")
                 {
                     flag = false;
                     object[] objArray2 = new object[] { base.TaxCardInstance.TaxClock.ToString("yyyy-MM-dd HH:mm:ss"), this.mDjh, 0, str4 };
                     KpResult   = string.Format("[{0}] 单据号:{1},开具结果:{2},开具失败原因:{3}", objArray2);
                     returncode = "0001";
                     returnmsg  = str4;
                     this.backgroundWorker1.ReportProgress(15, null);
                 }
                 else
                 {
                     this.TKfpxx(dj);
                     if (this.SuccessKp())
                     {
                         list.Add(this.mDjh);
                     }
                     flag = true;
                 }
             }
             else
             {
                 this.TKfpxx(dj);
                 if (this.SuccessKp())
                 {
                     list.Add(this.mDjh);
                 }
                 flag = true;
             }
             if ((int)this.fplx == 0x33)
             {
                 XmlNode node = doc.CreateElement("RESPONSE_COMMON_FPKJ");
                 bus.AppendChild(node);
                 XmlElement element = doc.CreateElement("FPQQLSH");
                 if ((this.mDjh != null) && (this.mDjh != ""))
                 {
                     element.InnerText = this.mDjh;
                 }
                 node.AppendChild(element);
                 XmlElement element2 = doc.CreateElement("JQBH");
                 if ((jqbh != null) && (jqbh != ""))
                 {
                     element2.InnerText = jqbh;
                 }
                 node.AppendChild(element2);
                 XmlElement element3 = doc.CreateElement("FP_DM");
                 if ((fp_dm != null) && (fp_dm != ""))
                 {
                     element3.InnerText = fp_dm;
                 }
                 node.AppendChild(element3);
                 XmlElement element4 = doc.CreateElement("FP_HM");
                 if ((fp_hm != null) && (fp_hm != ""))
                 {
                     element4.InnerText = fp_hm;
                 }
                 node.AppendChild(element4);
                 XmlElement element5 = doc.CreateElement("KPRQ");
                 if ((kprq != "") && (kprq != null))
                 {
                     DateTime time2 = Convert.ToDateTime(kprq);
                     kprq = string.Format("{0:yyyyMMddHHmmss}", time2);
                     element5.InnerText = kprq;
                 }
                 node.AppendChild(element5);
                 XmlElement element6 = doc.CreateElement("FP_MW");
                 if ((fp_mw != null) && (fp_mw != ""))
                 {
                     element6.InnerText = fp_mw;
                 }
                 node.AppendChild(element6);
                 XmlElement element7 = doc.CreateElement("JYM");
                 if ((jym != null) && (jym != ""))
                 {
                     element7.InnerText = jym;
                 }
                 node.AppendChild(element7);
                 XmlElement element8 = doc.CreateElement("EWM");
                 if ((ewm != null) && (ewm != ""))
                 {
                     element8.InnerText = ewm;
                 }
                 node.AppendChild(element8);
                 XmlElement element9 = doc.CreateElement("BZ");
                 if ((bz != null) && (bz != ""))
                 {
                     element9.InnerText = bz;
                 }
                 node.AppendChild(element9);
                 XmlElement element10 = doc.CreateElement("RETURNCODE");
                 element10.InnerText = returncode;
                 node.AppendChild(element10);
                 XmlElement element11 = doc.CreateElement("RETURNMSG");
                 element11.InnerText = KpResult;
                 node.AppendChild(element11);
             }
             else
             {
                 writer.WriteLine(KpResult);
             }
             Thread.Sleep(500);
             if (ErrorExist)
             {
                 this.CloseFile(str, bfFile);
                 break;
             }
             if (this.backgroundWorker1.CancellationPending)
             {
                 this.CloseFile(str, bfFile);
                 this.interrupted = true;
                 e.Cancel         = true;
                 break;
             }
             if (flag && (i != (list2.Count - 1)))
             {
                 Thread.Sleep(0x2710);
             }
             Thread.Sleep(500);
         }
         if ((int)this.fplx == 0x33)
         {
             doc.Save(this.hxPath + @"\" + this.hxFileNamexml);
         }
         else
         {
             writer.Close();
             writer.Dispose();
         }
         File.Copy(str, bfFile, true);
         File.Delete(str);
         Thread.Sleep(200);
     }
 }