Example #1
0
        private void btnMore_Click(object sender, EventArgs e)
        {
            if (dgvReportList.SelectedRows.Count != 1)
            {
                MessageBox.Show("请选择一行记录后进行操作", this.funName, MessageBoxButtons.OK);
                return;
            }

            int riid = (int)dgvReportList.SelectedRows[0].Cells[0].Value;

            using (frmReportNew fa = new frmReportNew())
            {
                Report1Wrapper rw1 = new Report1Wrapper();
                Report2Wrapper rw2 = new Report2Wrapper();

                REPORT_INFO ri = db.REPORT_INFOs.SingleOrDefault(a => a.RI_ID == riid);
                rw1.Base = rw2.Base = ri;

                rw1.ACNAME  = dgvReportList.SelectedRows[0].Cells[3].Value.ToString();
                rw2.TPNAME  = rw1.TPNAME = dgvReportList.SelectedRows[0].Cells[4].Value.ToString();
                rw1.Details = db.REPORT1_DETAILs.Where(a => a.R1_RIID == riid).ToList();
                rw2.Details = db.REPORT2_DETAILs.Where(a => a.R2_RIID == riid).ToList();

                fa.RW1 = rw1;
                fa.RW2 = rw2;
                if (fa.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                }
            }
        }
Example #2
0
        /// <summary>
        /// 查看报表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            decimal internalTotal = 0; // 境内合计 Added by CYQ 2018-07-12
            decimal externalTotal = 0; // 境外合计 Added by CYQ 2018-07-12

            try
            {
                if (dgvSals.SelectedRows.Count == 0)
                {
                    MessageBox.Show("请选择一行记录后进行操作", this.funName, MessageBoxButtons.OK);
                    return;
                }

                List <string> months = new List <string>();
                for (int i = 0; i < dgvSals.SelectedRows.Count; i++)
                {
                    months.Add(dgvSals.SelectedRows[i].Cells[2].Value.ToString());
                }
                List <string> mons = months.OrderBy(a => a).ToList();

                //修改每月建费用额
                string   x   = string.Empty;
                frmInput frm = new frmInput();
                frm.monthList = mons;

                if (frm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                try
                {
                    Dictionary <string, decimal> minusList = frm.minusList; //每月减费用额,计算税级时使用

                    TEMPLATE_INFO ti         = db.TEMPLATE_INFOs.SingleOrDefault(a => a.TI_ID == this.TIID);
                    string        playerName = (string)dgvSals.SelectedRows[0].Cells[1].Value; // 个税申报人

                    using (frmReportNew fa = new frmReportNew())
                    {
                        Report1Wrapper rw1 = new Report1Wrapper();                     //报表1数据
                        Report2Wrapper rw2 = new Report2Wrapper();                     //报表2数据
                        REPORT_INFO    ri  = new REPORT_INFO();                        //报表数据

                        rw1.ACNAME = ((AGENT_COUNTRY)cbxAgentCs.SelectedItem).AC_NAME; // 国别名称 Added by CYQ 2018-07-12
                        rw1.TPNAME = rw2.TPNAME = playerName;                          // 个税申报人姓名 Added by CYQ 2018-07-12
                        rw1.MINUS  = 4800;

                        ri.RI_ACID = this.ACID; // 国别ID Added by CYQ 2018-07-12

                        decimal bonus = getBonus();
                        if (bonus == -1)
                        {
                            string s = "年终奖多于1行,请输入年终奖最终值";
                            if (InputDialog.ShowInputDialog(ref s) == DialogResult.OK)
                            {
                                bonus = Convert.ToDecimal(s);
                            }
                            else
                            {
                                return;
                            }
                        }

                        //报表基础信息
                        ri.RI_BONUS       = bonus;                                                    // 年终奖金
                        ri.RI_DECLARETIME = dtDeclare.Value;                                          // 报税时间
                        ri.RI_TABLETIME   = dtTableOn.Value;                                          // 填表时间
                        ri.RI_ERATE1      = Convert.ToDecimal(txtERate1.Text);                        // 汇率 1
                        ri.RI_ERATE2      = Convert.ToDecimal(txtERate2.Text);                        // 汇率 2
                        ri.RI_MOUNTHCOUNT = dgvSals.SelectedRows.Count;                               // 纳税月数

                        ri.RI_MONTH       = mons[0] + "-" + mons[months.Count - 1];                   // 月数说明
                        ri.RI_CREATETIME  = dtTableOn.Value;                                          // 生成时间
                        ri.RI_UIID        = SysUtil.CurrentUserID();                                  // 操作用户
                        ri.RI_YEARTITLE1  = txtYearTitle1.Text;                                       // 报表1年度说明
                        ri.RI_YEARTITLE2  = txtYearTitle2.Text;                                       // 报表2年度说明
                        ri.RI_AYNAME      = AYNAME;                                                   // 纳税年度
                        ri.RI_YEARANNU    = Convert.ToDecimal(txtYearAnnu.Text.Trim());               // 年金限额
                        ri.RI_CURRENTNAME = lblCurrent.Text.Substring(1, lblCurrent.Text.Length - 2); // 币种名称
                        int tpid = 0;
                        if (SysUtil.GetPlayerID(ACID, playerName, ref tpid))
                        {
                            ri.RI_TPID = tpid;
                        }

                        for (int i = 0; i < dgvSals.SelectedRows.Count; i++)
                        {
                            //报表1数据
                            var td = new REPORT1_DETAIL
                            {
                                R1_MONTH         = dgvSals.SelectedRows[i].Cells[2].Value.ToString(),                    // 月份
                                R1_FORTAX        = Convert.ToDecimal(dgvSals.SelectedRows[i].Cells[3].Value.ToString()), // 应纳税工资
                                R1_REALDOLLOR    = Convert.ToDecimal(dgvSals.SelectedRows[i].Cells[4].Value.ToString()), // 实发工资(美元)
                                R1_REALRMB       = Convert.ToDecimal(dgvSals.SelectedRows[i].Cells[5].Value.ToString()), // 实发工资(RMB)
                                R1_TAXALREADY    = Convert.ToDecimal(dgvSals.SelectedRows[i].Cells[6].Value.ToString()), // 已纳税额
                                R1_TAXALREADYRMB = Convert.ToDecimal(dgvSals.SelectedRows[i].Cells[7].Value.ToString()), // 已纳税额(RMB)
                            };
                            td.R1_SALARYRMB = td.R1_FORTAX + td.R1_REALRMB + td.R1_TAXALREADYRMB;                        // 应纳税工资合计

                            /* Modified by cyq 20160331 */
                            /************  Begin  *********/
                            if (minusList[td.R1_MONTH] == 3500)
                            {
                                internalTotal += td.R1_SALARYRMB;
                            }
                            else
                            {
                                externalTotal += td.R1_SALARYRMB;
                            }
                            /************  End  *********/

                            //报表2数据
                            var td2 = new REPORT2_DETAIL();
                            td2.R2_MONTH     = dgvSals.SelectedRows[i].Cells[2].Value.ToString();
                            td2.R2_SALARY    = td.R1_SALARYRMB;                                                                          // 应纳税工资(报表2)
                            td2.R2_MINUS     = minusList[td2.R2_MONTH];                                                                  // 减费用额(报表2)
                            td2.R2_TAXSALARY = td2.R2_SALARY - td2.R2_MINUS;                                                             // 应纳税所得额(报表2)
                            TAX_RATE ta = SysUtil.GetTaxRate(td2.R2_SALARY, minusList[td2.R2_MONTH]);
                            td2.R2_TAXRATE = ta.TR_RATE;                                                                                 // 税率(报表2)
                            td2.R2_QUICK   = ta.TR_QUICH;                                                                                // 速算扣除数(报表2)
                            td2.R2_NEED    = Convert.ToDecimal((td2.R2_TAXSALARY * td2.R2_TAXRATE / 100 - td2.R2_QUICK).ToString("F2")); // 应纳税额(报表2)

                            rw1.Details.Add(td);
                            rw2.Details.Add(td2);
                        }

                        /* Modified by cyq 20160331 */
                        /************  Begin  *********/
                        fa.InternalTotal = internalTotal;
                        fa.ExternalTotal = externalTotal;
                        /************  End  *********/

                        decimal min = rw2.Details.Min(a => a.R2_TAXSALARY);
                        if (min > 0)
                        {
                            min = 0;
                        }

                        //*** Modified by CYQ on 2018-07-26 ***//
                        // 根据财通佳鑫要求:
                        // 1.当应纳税工资<=0时 年终奖调整额根据min所在行减费用额,调减3500或4800。
                        // 2.如果“应纳税所得额”值min不唯一,且“减费用额”列对应数值不唯一,则取值4800对年终奖进行调整。
                        //*** Begin ***//
                        else
                        {
                            if (min < -3500)
                            {
                                int minTSCnt = rw2.Details.Where(r => r.R2_TAXSALARY == min).Count(); // 应纳税所得额唯一值统计

                                decimal[] r2_Minus = rw2.Details.Where(r => r.R2_TAXSALARY == min).Select(r => r.R2_MINUS).ToArray();
                                if (minTSCnt > 1) // 存在重复的应纳税所得额
                                {
                                    if (r2_Minus.Distinct().Count() > 1)
                                    {
                                        min = -4800;
                                    }
                                    else
                                    {
                                        min = (-1) * r2_Minus[0];
                                    } // end else
                                }
                                else  // 无重复的应纳税所得额
                                {
                                    min = (-1) * r2_Minus[0];
                                }
                            }
                        } // end else
                          //*** End ***//

                        TAX_RATE trbonus = SysUtil.GetTaxRate((ri.RI_BONUS + min) / 12, 4800, true);
                        ri.RI_BONUSTAXRATEID   = trbonus.TR_ID;                                                                                // 年终奖金税率
                        ri.RI_BONUSTAX         = Convert.ToDecimal(((ri.RI_BONUS * trbonus.TR_RATE / 100) - trbonus.TR_QUICH).ToString("F2")); // 应纳税额(年终奖)
                        ri.RI_SUMS             = rw2.Details.Sum(a => a.R2_SALARY) + ri.RI_BONUS;                                              // 收入额(合计)
                        ri.RI_SUMTAXSALARY     = rw2.Details.Sum(a => a.R2_TAXSALARY) + ri.RI_BONUS;                                           // 应纳税所得额(合计)
                        ri.RI_SUMTAXRMB        = rw2.Details.Sum(a => a.R2_NEED) + (decimal)ri.RI_BONUSTAX;                                    // 应纳税额(合计)
                        ri.RI_SUMTAXALREADY    = TaxAlready[playerName];
                        ri.RI_SUMTAXALREADYRMB = Convert.ToDecimal((TaxAlready[playerName] * ri.RI_ERATE1 * ri.RI_ERATE2).ToString("F2"));     // rw1.Details.Sum(a => a.R1_TAXALREADYRMB); // 境外已纳税额
                        ri.RI_NEEDPACK         = (decimal)ri.RI_SUMTAXRMB - (decimal)ri.RI_SUMTAXALREADYRMB;                                   // 境内应补税额【计算公式:应纳税额(合计) - 境外已纳税额】
                        ri.RI_USEALL           = 0;
                        ri.RI_USE2             = 0;

                        /* Modified by cyq 20160331 */
                        /* ***********  Begin  *********/
                        if (ri.RI_NEEDPACK < 0)
                        {
                            TAX_CREDIT tc = new TAX_CREDIT
                            {
                                TP_ID            = tpid,
                                TC_YEAR          = AYNAME,
                                TC_CREDITALL     = Math.Abs(ri.RI_NEEDPACK),
                                TC_CREDITUSED    = 0,
                                TC_CREDITBALANCE = Math.Abs(ri.RI_NEEDPACK)
                            };

                            fa.AddedTC = tc;
                        }
                        else
                        {
                            TAX_CREDIT tc = new TAX_CREDIT
                            {
                                TP_ID            = tpid,
                                TC_YEAR          = AYNAME,
                                TC_CREDITALL     = 0,
                                TC_CREDITUSED    = 0,
                                TC_CREDITBALANCE = 0
                            };

                            fa.AddedTC = tc;
                        }
                        /* ***********  End  *********/

                        if (ri.RI_NEEDPACK < 0)
                        {
                            ri.RI_NEEDPACKREAL = 0;
                        }
                        else
                        {
                            ri.RI_NEEDPACKREAL = ri.RI_NEEDPACK;                                                                                                                                                                                                 // 境内实需补税额
                        }
                        ri.RI_NOTE1 = string.Format("注:1. {0}{1}{2}元人民币", dtDeclare.Value.ToString("yyyy年MM月dd日"), lblCurrent.Text, (ri.RI_ERATE1 * ri.RI_ERATE2).ToString("f6"));                                                                               // 备注1
                        ri.RI_NOTE2 = string.Format("2. {0}年{1}已纳税额 {2} {3},折合人民币 {4} 元", txtYear.Text, rw1.ACNAME, ri.RI_SUMTAXALREADY.ToString("N2"), ((AGENT_COUNTRY)cbxAgentCs.SelectedItem).AC_CURRENCY, ((decimal)ri.RI_SUMTAXALREADYRMB).ToString("N2")); // 备注2

                        ri.RI_USEALL = 0;                                                                                                                                                                                                                        // 使用可抵税总额

                        rw1.Base = rw2.Base = ri;
                        fa.RW1   = rw1;
                        fa.RW2   = rw2;
                        fa.Owner = this;
                        //展示报表
                        if (fa.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("错误类型:" + ex.GetType().ToString() + "\n" +
                                    "错误消息:" + ex.Message + "\n" +
                                    "对象名称:" + ex.Source + "\n" +
                                    "引发异常的方法:" + ex.TargetSite + "\n" +
                                    "调用堆栈:" + ex.StackTrace + "\n");
                    throw;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ";是否已纳税额尚未输入");
                return;
            }
        }