Пример #1
0
        private void b_ok_Click(object sender, EventArgs e)
        {
            decimal dec_fin = new decimal(0);
            decimal dec_tax = new decimal(0);
            string  s_tip   = string.Empty;

            foreach (DataRow dr in dt_source.Rows)
            {
                if (dr["SA020"].ToString() == "F")
                {
                    dec_fin += Convert.ToDecimal(dr["SA007"]);
                }
                else if (dr["SA020"].ToString() == "T")
                {
                    dec_tax += Convert.ToDecimal(dr["SA007"]);
                }
            }

            if (dec_fin > 0 && dec_tax > 0)
            {
                s_tip = "本次结算共需要一张财政发票和一张税务发票,是否继续?";
            }
            else if (dec_fin > 0)
            {
                s_tip = "本次结算共需要一张财政发票,是否继续?";
            }
            else if (dec_tax > 0)
            {
                s_tip = "本次结算共需要一张税务发票,是否继续?";
            }
            else
            {
                return;
            }

            if (XtraMessageBox.Show(s_tip, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            string        s_fa001    = Tools.GetEntityPK("FA01");
            string        s_cuname   = FireAction.GetGuyNameById(AC001);
            List <string> sa001_list = new List <string>();

            foreach (DataRow r in dt_source.Rows)
            {
                sa001_list.Add(r["SA001"].ToString());
            }

            int result = FireAction.FireBusinessSettle(s_fa001,
                                                       AC001,
                                                       s_cuname,
                                                       sa001_list.ToArray(),
                                                       Envior.cur_userId
                                                       );

            if (result > 0)
            {
                b_ok.Enabled = false;

                int fire_row = gridView1.LocateByValue("SA002", "06");
                //如果有火化,打印火化证明
                if (fire_row >= 0)
                {   //打印火化证明
                    if (XtraMessageBox.Show("现在打印火化证明?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        PrtServAction.Print_HHZM(AC001, 0);
                    }
                }

                XtraMessageBox.Show("结算成功!现在开始打印发票!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ////开财政票!
                if (dec_fin > 0)
                {
                    //string s_pjh = string.Empty;
                    //string s_zch = string.Empty;
                    if (FinInvoice.GetCurrentPh() > 0)
                    {
                        if (XtraMessageBox.Show("下一张财政发票号码:" + Envior.FIN_NEXT_BILL_NO + ",是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            FinInvoice.Invoice(s_fa001);
                        }
                    }
                }

                //// 开税票
                if (dec_tax > 0)
                {
                    //获取税务客户信息
                    string            s_ac003       = SqlAssist.ExecuteScalar("select ac003 from ac01 where ac001='" + AC001 + "'").ToString();
                    Frm_TaxClientInfo frm_taxClient = new Frm_TaxClientInfo(s_ac003);
                    if (frm_taxClient.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    TaxClientInfo clientInfo = frm_taxClient.swapdata["taxclientinfo"] as TaxClientInfo;

                    if (TaxInvoice.GetNextInvoiceNo() > 0)
                    {
                        if (XtraMessageBox.Show("下一张税票代码:" + Envior.NEXT_BILL_CODE + "\r\n" + "票号:" + Envior.NEXT_BILL_NUM + ",是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            TaxInvoice.Invoice(s_fa001, clientInfo);
                        }
                    }
                }
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }