Exemple #1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            var CustomerInfoCnt = CustomerInfo.ReadSys();
            var ItemInfoCnt     = ItemInfo.ReadSys();

            TaxInfo.ReadTemplate();
            var invalidCIcount = CustomerInfo.list.Count(x => x.TaxCode.Length != 18);

            toolStripStatusLabel1.Text = "读取客户编码:" + CustomerInfoCnt + " 商品编码:" + ItemInfoCnt;
            MessageBox.Show("税号非18位的客户记录数:" + invalidCIcount);
        }
Exemple #2
0
        private void btnCreateSimpleRecipe_Click(object sender, EventArgs e)
        {
            if (txtXMLFolder.Text == "")
            {
                MessageBox.Show("请先选择XML目录");
                return;
            }

            int MissCustomCnt = 0;
            int ZeroAmountCnt = 0;
            int SimpleCnt     = 0;

            foreach (var item in TaxInfo.list.GroupBy(x => x.公司))
            {
                var SumAmount = item.Sum(x => x.金额_不含税);
                if (SumAmount == 0)
                {
                    //冲账用,不开发票
                    ZeroAmountCnt++; continue;
                }
                var IsOK = item.Count() <= TaxInfo.CountLimit && SumAmount < TaxInfo.AmountLimit_不含税;
                if (!IsOK)
                {
                    continue;
                }
                //客户编码是全角的
                var CompanySeekKey = item.Key.Replace("(", "(");
                CompanySeekKey = CompanySeekKey.Replace(")", ")");
                var cInfo = CustomerInfo.list.Where(x => x.Name == CompanySeekKey).FirstOrDefault();
                if (cInfo == null)
                {
                    MissCustomCnt++; continue;
                }
                var strRecipe = TaxInfo.FillTemplate(CompanySeekKey, item.ToList());
                var sw        = new StreamWriter(txtXMLFolder.Text + CompanySeekKey + ".xml", false, Encoding.GetEncoding("GBK"));
                sw.Write(strRecipe);
                sw.Close();
                SimpleCnt++;
                MessageBox.Show("制作发票数:" + SimpleCnt + " 公司信息缺失数:" + MissCustomCnt + " 冲账数:" + ZeroAmountCnt);
            }
        }
Exemple #3
0
        private void btnReadOrg_Click(object sender, EventArgs e)
        {
            var OF = new OpenFileDialog();

            if (OF.ShowDialog() == DialogResult.OK)
            {
                var cnt = TaxInfo.ReadExcel(OF.FileName);
                lstCompany.Clear();
                lstCompany.Columns.Add("公司名", 250);
                lstCompany.Columns.Add("发票件数");
                lstCompany.Columns.Add("金额", 150);
                lstCompany.Columns.Add("符合条件");
                foreach (var item in TaxInfo.list.GroupBy(x => x.公司))
                {
                    var SumAmount = item.Sum(x => x.金额_不含税);
                    var IsOK      = item.Count() <= TaxInfo.CountLimit && SumAmount < TaxInfo.AmountLimit_不含税;
                    lstCompany.Items.Add(new ListViewItem(new string[] { item.Key, item.Count().ToString(), SumAmount.ToString(), IsOK ? "是" : "否" }));
                }
                MessageBox.Show("读取到发票记录数:" + cnt);
            }
        }
Exemple #4
0
        private void btnCreateRecipeXML_Click(object sender, EventArgs e)
        {
            double checkAmount = 0;
            bool   HasPrint    = false;
            bool   HasSplited  = false;
            bool   HasMerged   = false;
            var    checkItems  = new List <ItemDetail>();

            foreach (ListViewItem item in lstRecipeDetails.CheckedItems)
            {
                var r = (item.Tag as ItemDetail);
                if (r.已开票)
                {
                    HasPrint = true;
                    break;
                }
                if (r.被拆分)
                {
                    HasSplited = true;
                    break;
                }
                if (r.被合并)
                {
                    HasMerged = true;
                    break;
                }
                checkAmount += r.金额_不含税;
                checkItems.Add(r);
            }


            if (HasSplited)
            {
                MessageBox.Show("发票里面有被拆分项目");
                return;
            }
            if (HasMerged)
            {
                MessageBox.Show("发票里面有被合并项目");
                return;
            }
            if (HasPrint)
            {
                MessageBox.Show("发票里面有已开票项目");
                return;
            }
            if (lstRecipeDetails.CheckedItems.Count == 0)
            {
                MessageBox.Show("请选择需要开票的项目!");
                return;
            }
            if (lstRecipeDetails.CheckedItems.Count > TaxInfo.CountLimit || checkAmount > TaxInfo.AmountLimit_不含税)
            {
                MessageBox.Show("开票条件不符合!");
                return;
            }
            //客户编码是全角的
            var CompanySeekKey = checkItems[0].公司.Replace("(", "(");

            CompanySeekKey = CompanySeekKey.Replace(")", ")");
            var cInfo = CustomerInfo.list.Where(x => x.Name == CompanySeekKey).FirstOrDefault();

            if (cInfo == null)
            {
                MessageBox.Show("无法找到公司【" + CompanySeekKey + "】的信息!");
                return;
            }
            if (cInfo.TaxCode.Length != 18)
            {
                MessageBox.Show("公司税号不是18位:" + cInfo.TaxCode);
                return;
            }
            if (txtXMLFolder.Text == "")
            {
                MessageBox.Show("请先选择XML目录");
                return;
            }
            var strRecipe = TaxInfo.FillTemplate(CompanySeekKey, checkItems);
            var filename  = txtXMLFolder.Text + txtFilename.Text + (chkFilenameTimeStamp.Checked ? ("_" + System.DateTime.Now.ToString("yyyyMMdd")) : "") + ".xml";

            if (File.Exists(filename))
            {
                if (MessageBox.Show("已经存在文件,是否覆盖?", "覆盖", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }
            var sw = new StreamWriter(filename, false, Encoding.GetEncoding("GBK"));

            sw.Write(strRecipe);
            sw.Close();
            foreach (ListViewItem item in lstRecipeDetails.CheckedItems)
            {
                var r = (item.Tag as ItemDetail);
                r.已开票 = true;
                item.SubItems[6].Text = "已开票";
                item.BackColor        = System.Drawing.Color.Gray;
            }
        }