コード例 #1
0
ファイル: frmYear.cs プロジェクト: Clark-Chen-Dev/TempRepo
 /// <summary>
 /// 新增年度
 /// </summary>
 private void addYear()
 {
     if (!checkInput())
     {
         MessageBox.Show("请检查输入项", this.funName);
         return;
     }
     using (TAXDBDataContext db = new TAXDBDataContext())
     {
         AGENT_YEAR ay = new AGENT_YEAR
         {
             AY_NAME    = Convert.ToInt32(txtYear.Text.Trim()),
             AY_ADDTIME = DateTime.Now,
             AY_UIID    = SysUtil.CurrentUserID(),
         };
         db.AGENT_YEARs.InsertOnSubmit(ay);
         db.SubmitChanges();
         loadYears();
     }
 }
コード例 #2
0
        /// <summary>
        /// 加载所有列
        /// </summary>
        private void loadCols()
        {
            var data = db.v_COLUMNs.Where(c => c.CI_ISVALID == true).OrderBy(a => a.CI_ID).Select(cl => cl);
            var ds   = new BindingList <ColInfo>();

            foreach (var d in data)
            {
                ColInfo ci = new ColInfo {
                    CI_ID      = d.CI_ID,
                    CI_COLNAME = d.CI_COLNAME,
                    CI_MARK    = d.CI_MARK,
                    CI_ALIAS   = string.Join(",", db.COLUMNS_ALIAs.Where(c => c.CA_CIID == d.CI_ID).Select(a => a.CA_ALIAS).ToList()),
                    CI_TITLE   = d.CI_NAME,
                    CI_NAME    = d.CI_NAME,
                    CT_NAME    = SysUtil.GetTypeName(d.CI_TYPEID),
                };

                ds.Add(ci);
            }

            dgvCols.DataSource = ds;
        }
コード例 #3
0
ファイル: frmYear.cs プロジェクト: Clark-Chen-Dev/TempRepo
 /// <summary>
 /// 增加货币单位
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAddCurr_Click(object sender, EventArgs e)
 {
     if (!checkInputOfCurrency())
     {
         MessageBox.Show("请检查输入项");
         return;
     }
     using (TAXDBDataContext db = new TAXDBDataContext())
     {
         //db.Connection.ConnectionString = Cryptogram.DecryptPassword(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString());
         CURRENCY curr = new CURRENCY
         {
             C_ADDTIME = DateTime.Now,
             C_NAME    = txtCurrency.Text.Trim(),
             C_UIID    = SysUtil.CurrentUserID(),
             C_ISDEL   = false
         };
         db.CURRENCies.InsertOnSubmit(curr);
         db.SubmitChanges();
         loadCurrency();
         MessageBox.Show("添加成功");
     }
 }
コード例 #4
0
        /// <summary>
        /// 查询留抵记录
        /// </summary>
        private void LoadData()
        {
            /* Modified by cyq 20160331 */
            /* ***********  Begin  *********/
            int currYear = SysUtil.GetCurrentYear();

            db.Log = Console.Out;
            if (cbxAgentCs.SelectedItem == null)
            {
                //dgvCredit.DataSource = db.v_TAXCREDITs
                //                            .Where(a => a.AI_NAME == ((AGENT_INFO)cbxAgents.SelectedItem).AI_NAME)
                //                            .Select(a => a).ToList();
                dgvCredit.DataSource = db.v_TAXCREDITs
                                       .Where(a => a.AI_NAME == ((AGENT_INFO)cbxAgents.SelectedItem).AI_NAME &&
                                              (currYear - a.TC_YEAR) <= 5)
                                       .Select(a => a).ToList();
            }
            else
            {
                //dgvCredit.DataSource = db.v_TAXCREDITs
                //                         .Where(a => a.AI_NAME == ((AGENT_INFO)cbxAgents.SelectedItem).AI_NAME &&
                //                            (a.AC_NAME == ((AGENT_COUNTRY)cbxAgentCs.SelectedItem).AC_NAME))
                //                         .Select(a => a).ToList();

                dgvCredit.DataSource = db.v_TAXCREDITs
                                       .Where(a => a.AI_NAME == ((AGENT_INFO)cbxAgents.SelectedItem).AI_NAME &&
                                              (a.AC_NAME == ((AGENT_COUNTRY)cbxAgentCs.SelectedItem).AC_NAME) &&
                                              (currYear - a.TC_YEAR) <= 5)
                                       .Select(a => a).ToList();
            }



            /* ***********  End  *********/

            setRowNumber(dgvCredit);
        }
コード例 #5
0
        /// <summary>
        /// 导入留抵记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnImport_Click(object sender, EventArgs e)
        {
            if (cbxAgentCs.SelectedItem == null)
            {
                MessageBox.Show("请选择国别信息后进行导入");
                return;
            }
            int acid = ((AGENT_COUNTRY)cbxAgentCs.SelectedItem).AC_ID;

            if (checkItemsInFile())
            {
                ExcelHelper excel = new ExcelHelper();
                try
                {
                    excel.OpenFile(txtDir.Text, 1, true);
                    int rows = excel.GetRowsCount();
                    int i    = 2;

                    List <string> sl;
                    for (; i <= rows; i++) //首先检查纳税人和对应年份的留抵记录是否已存在
                    {
                        sl = excel.GetValue(i, 1, i, 5);
                        string tname = sl[0].Replace(" ", string.Empty);
                        int    year  = Convert.ToInt32(sl[1].Replace(" ", string.Empty));
                        if (db.TAX_PLAYERs.SingleOrDefault(a => (a.TP_ACID == acid) && (a.TP_NAME == tname)) == null)
                        {
                            MessageBox.Show(tname + "此纳税人不存在,请检查", this.funName);
                            //excel.Close();
                            return;
                        }
                        if (db.v_TAXCREDITs.SingleOrDefault(a => a.TC_YEAR == year && a.TP_NAME == tname) != null)
                        {
                            MessageBox.Show(tname + "此纳税人" + year + "留抵记录已存在,请检查", this.funName);
                            //excel.Close();
                            return;
                        }
                    }

                    i = 2;
                    for (; i <= rows; i++)
                    {
                        sl = excel.GetValue(i, 1, i, 5);
                        string tname = sl[0].Replace(" ", string.Empty);
                        int    year  = Convert.ToInt32(sl[1].Replace(" ", string.Empty));
                        int    tpid  = SysUtil.GetPlayerID(acid, tname);
                        if (sl[2] == string.Empty)
                        {
                            sl[2] = "0";
                        }
                        if (sl[3] == string.Empty)
                        {
                            sl[3] = "0";
                        }
                        if (sl[4] == string.Empty)
                        {
                            sl[4] = "0";
                        }

                        TAX_CREDIT tc = new TAX_CREDIT
                        {
                            TP_ID            = tpid,
                            TC_YEAR          = year,
                            TC_CREDITALL     = Math.Abs(Convert.ToDecimal(sl[2])),
                            TC_CREDITUSED    = Math.Abs(Convert.ToDecimal(sl[3])),
                            TC_CREDITBALANCE = Math.Abs(Convert.ToDecimal(sl[4]))
                        };
                        db.TAX_CREDITs.InsertOnSubmit(tc);
                    }
                    db.SubmitChanges();



                    MessageBox.Show("导入成功,导入记录" + (rows - 1) + "条", this.funName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    excel.Close();
                }
            }
        }
コード例 #6
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            int count = dgvReportList.SelectedRows.Count;

            if (count == 0)
            {
                MessageBox.Show("请选择记录后进行操作");
                return;
            }

            DialogResult dialogResult = MessageBox.Show("确定将此" + count + "记录删除吗", this.funName, MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                for (int i = 0; i < count; i++)
                {
                    /* Modified by cyq 20160331 */
                    /* ***********  Begin  *********/
                    //int riid = (int)dgvReportList.SelectedRows[i].Cells[0].Value;
                    //db.REPORT1_DETAILs.DeleteAllOnSubmit(db.REPORT1_DETAILs.Where(a => a.R1_RIID == riid));
                    //db.REPORT2_DETAILs.DeleteAllOnSubmit(db.REPORT2_DETAILs.Where(a => a.R2_RIID == riid));
                    //db.REPORT_INFOs.DeleteAllOnSubmit(db.REPORT_INFOs.Where(a => a.RI_ID == riid));
                    //db.TAX_CREDITs.DeleteAllOnSubmit(db.TAX_CREDITs.Where(a => a.TC_RIID == riid));
                    //db.SubmitChanges();

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

                    try
                    {
                        db.Connection.Open();
                        db.Transaction = db.Connection.BeginTransaction();

                        var reportInfo     = db.REPORT_INFOs.Where(a => a.RI_ID == riid);
                        var tpid           = reportInfo.Select(report => report.RI_TPID).Single();
                        var relatedCredits = db.TAX_CREDITs
                                             .Where(a => a.TP_ID == tpid && (SysUtil.GetCurrentYear() - a.TC_YEAR) <= 5 &&
                                                    a.TC_CREDITUSED > 0).ToList();

                        if (relatedCredits.Any())
                        {
                            decimal avail = reportInfo.Single().RI_USEALL.GetValueOrDefault() - reportInfo.Single().RI_USE2.GetValueOrDefault();
                            decimal diff  = 0;

                            foreach (var credit in relatedCredits)
                            {
                                diff = credit.TC_CREDITUSED.GetValueOrDefault() - avail;

                                if (diff >= 0)
                                {
                                    credit.TC_CREDITUSED    -= avail;
                                    credit.TC_CREDITBALANCE += avail;
                                    break;
                                }
                                else
                                {
                                    avail -= credit.TC_CREDITUSED.GetValueOrDefault();
                                    credit.TC_CREDITBALANCE = credit.TC_CREDITALL;
                                    credit.TC_CREDITUSED    = 0;
                                }
                            }
                        }

                        db.REPORT1_DETAILs.DeleteAllOnSubmit(db.REPORT1_DETAILs.Where(a => a.R1_RIID == riid));
                        db.REPORT2_DETAILs.DeleteAllOnSubmit(db.REPORT2_DETAILs.Where(a => a.R2_RIID == riid));
                        db.REPORT_INFOs.DeleteAllOnSubmit(reportInfo);
                        db.TAX_CREDITs.DeleteAllOnSubmit(db.TAX_CREDITs.Where(a => a.TC_RIID == riid));
                        db.SubmitChanges(ConflictMode.FailOnFirstConflict);
                        db.Transaction.Commit();
                    }
                    catch (ChangeConflictException)
                    {
                        db.Transaction.Rollback();
                        MessageBox.Show("报表记录及报表对应的留抵因未知原因无法级联删除。", "错误",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    /* ***********  End  *********/
                }
            }

            LoadData();
        }
コード例 #7
0
        /// <summary>
        /// 报表导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEm_Click(object sender, EventArgs e)
        {
            //*** Modified by CYQ on 2018-07-26 ***//
            // 根据财通嘉鑫要求,增加有关无身份证号的报税申请人处理
            //*** Begin ***//
            TAX_PLAYER currTP = db.TAX_PLAYERs.SingleOrDefault(ai => ai.TP_ID == RW1.Base.RI_TPID);

            #region 用户输入无身份证号的报税申请人的身份证号
            string id = string.Empty;  // 申报人身份证号
            if (string.IsNullOrEmpty(currTP.TP_IDNUMBER))
            {
                string s = "请输入申报人身份证号";
                if (InputDialog.ShowInputDialog(ref s) == DialogResult.OK)
                {
                    id = s.Trim();
                }
            }
            else
            {
                id = currTP.TP_IDNUMBER;
            }

            if (id != string.Empty)
            {
                currTP.TP_IDNUMBER = id;
                db.SubmitChanges();
            }
            else
            {
                MessageBox.Show("未获取到有效的身份证号信息,请重新输入", "消息",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            #endregion
            //*** End ***//

            fbdPath.Description = "将导出文件保存到...";
            DialogResult result = fbdPath.ShowDialog();
            if (result != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            Assembly assembly = Assembly.GetExecutingAssembly();
            Assembly asm      = Assembly.GetExecutingAssembly();
            string   file     = string.Format("{0}.Resources.ReportTemplate.xlsx", asm.GetName().Name);

            Stream fileStream = asm.GetManifestResourceStream(file);

            string filename = fbdPath.SelectedPath + string.Format("\\{0}-{1}_{2}.xlsx", RW1.ACNAME, RW1.TPNAME, DateTime.Now.ToString("yyyyMMddHHmm"));

            SaveStreamToFile(filename, fileStream);

            ExcelHelper excel = new ExcelHelper();

            //报表一
            excel.OpenFile(filename, 1);
            excel.SetValue(1, 2, string.Format("{0}-{1}{2}工资单", RW1.ACNAME, RW1.TPNAME, RW1.Base.RI_YEARTITLE1));
            excel.SetValue(4, 6, RW1.Base.RI_CURRENTNAME);
            var data = RW1.Details.OrderBy(a => a.R1_MONTH).ToList();
            //load data;
            int i = 0;
            foreach (var d in data)
            {
                string[] tmp = new string[] { d.R1_MONTH, d.R1_FORTAX.ToString(), d.R1_REALDOLLOR.ToString(), d.R1_REALRMB.ToString(), d.R1_TAXALREADY.ToString(), d.R1_TAXALREADYRMB.ToString(), d.R1_SALARYRMB.ToString() };
                excel.SetValue(5 + i, 2, tmp);
                i++;
            }
            excel.SetValue(17, 3, RW1.Base.RI_BONUS.ToString());
            excel.SetValue(18, 2, RW1.Base.RI_NOTE1);
            excel.SetValue(19, 2, RW1.Base.RI_NOTE2);

            /* Modified by cyq 20160331 */
            /************  Begin  *********/
            excel.SetFontNameSize(21, 2, "宋体", 11);
            excel.SetFontNameSize(21, 4, "宋体", 11);
            excel.SetFontNameSize(23, 2, "宋体", 11);
            excel.SetFontNameSize(23, 4, "宋体", 11);
            excel.SetValue(21, 2, "编制日期: " + RW1.Base.RI_TABLETIME.ToLongDateString().ToString());
            excel.SetValue(21, 4, "复核日期: " + RW1.Base.RI_TABLETIME.AddDays(2).ToLongDateString().ToString());
            excel.SetValue(23, 2, "编制人: " + txtScheduler.Text.Trim());
            excel.SetValue(23, 4, "复核人: " + txtReviewer.Text.Trim());
            /************  End  *********/

            //报表二
            excel.ChangeSheet(2);
            excel.SetValue(3, 1, string.Format("{0}--工资个税               {1}", RW2.TPNAME, RW2.Base.RI_YEARTITLE2));
            var data2 = RW2.Details.OrderBy(a => a.R2_MONTH).ToList();
            i = 0;
            foreach (var d in data2)
            {
                string[] tmp = new string[] { d.R2_MONTH, d.R2_SALARY.ToString(), d.R2_MINUS.ToString(), d.R2_TAXSALARY.ToString(), string.Format("{0}%", d.R2_TAXRATE), d.R2_QUICK.ToString(), d.R2_NEED.ToString() };
                excel.SetValue(7 + i, 1, tmp);
                i++;
            }
            excel.SetValue(19, 2, RW2.Base.RI_BONUS.ToString());
            excel.SetValue(19, 4, RW2.Base.RI_BONUS.ToString());
            TAX_RATE tr = SysUtil.GetTaxRate((int)RW2.Base.RI_BONUSTAXRATEID);
            excel.SetValue(19, 5, string.Format("{0}%", tr.TR_RATE));
            excel.SetValue(19, 6, tr.TR_QUICH.ToString());
            excel.SetValue(19, 7, RW2.Base.RI_BONUSTAX.ToString());
            excel.SetValue(20, 2, RW2.Base.RI_SUMS.ToString());
            excel.SetValue(20, 4, RW2.Base.RI_SUMTAXSALARY.ToString());
            excel.SetValue(20, 7, RW2.Base.RI_SUMTAXRMB.ToString());
            excel.SetValue(20, 8, RW2.Base.RI_SUMTAXALREADYRMB.ToString());

            // Modified by CYQ on 2018-09-10
            // 根据财通嘉鑫要求,将“本年已缴/以前留抵”拆分为“境内已纳税额”和“以前留抵税额”
            // Begin
            //excel.SetValue(20, 9, RW2.Base.RI_USEALL.ToString());
            excel.SetValue(20, 9, (RW2.Base.RI_USE2).ToString());                       // 境内已纳税额
            excel.SetValue(20, 10, (RW2.Base.RI_USEALL - RW2.Base.RI_USE2).ToString()); // 以前留抵税额


            //*** Modified by CYQ on 2018-07-13 ***//
            //
            //*** Begin ***//
            //excel.SetValue(20, 10, RW2.Base.RI_NEEDPACKREAL.ToString());

            //if (RW2.Base.RI_NEEDPACKREAL.HasValue &&
            //    RW2.Base.RI_NEEDPACKREAL.Value > 0)
            //{
            //    excel.SetValue(20, 10, RW2.Base.RI_NEEDPACKREAL.ToString());
            //} // end if

            //if (RW2.Base.RI_NEEDPACKREAL.HasValue)
            //{
            //    if (RW2.Base.RI_NEEDPACKREAL.Value > 0)
            //    {
            //        excel.SetValue(20, 10, RW2.Base.RI_NEEDPACKREAL.ToString());
            //    } // end if
            //    else
            //    {
            //        excel.SetValue(20, 10, "0.00");
            //    } // end else
            //}

            if (RW2.Base.RI_NEEDPACKREAL.HasValue)
            {
                if (RW2.Base.RI_NEEDPACKREAL.Value > 0)
                {
                    excel.SetValue(20, 11, RW2.Base.RI_NEEDPACKREAL.ToString());
                } // end if
                else
                {
                    excel.SetValue(20, 11, "0.00");
                } // end else
            }
            // End
            //*** End ***//

            excel.SetValue(22, 1, RW2.Base.RI_NOTE1);
            excel.SetValue(23, 1, string.Format("   {0}", RW2.Base.RI_NOTE2));

            /* Modified by cyq 20160331 */
            /************  Begin  *********/
            excel.SetFontNameSize(25, 2, "宋体", 11);
            excel.SetFontNameSize(25, 4, "宋体", 11);
            excel.SetFontNameSize(27, 2, "宋体", 11);
            excel.SetFontNameSize(27, 4, "宋体", 11);
            excel.SetValue(25, 2, "编制日期: " + RW1.Base.RI_TABLETIME.ToLongDateString().ToString());
            excel.SetValue(25, 4, "复核日期: " + RW1.Base.RI_TABLETIME.AddDays(2).ToLongDateString().ToString());
            excel.SetValue(27, 2, "编制人: " + txtScheduler.Text.Trim());
            excel.SetValue(27, 4, "复核人: " + txtReviewer.Text.Trim());
            /************  End  *********/

            excel.Close();

            //生成报表三
            if (RW2.Base.RI_MOUNTHCOUNT == 12)
            {
                filename = fbdPath.SelectedPath + string.Format("\\{0}-{1}_{2}.doc", RW1.ACNAME, RW1.TPNAME, DateTime.Now.ToString("yyyyMMddHHmm"));
                File.WriteAllBytes(filename, TaxDemo.Properties.Resources.Template3);

                AGENT_INFO ai   = SysUtil.GetAgentInfo(RW1.Base.RI_ACID);
                TAX_PLAYER tp   = SysUtil.GetTaxPlayer(RW1.Base.RI_TPID);
                WordUtil   word = new WordUtil();
                {
                    word.Open(filename);

                    /* Modified by cyq 20160331 */
                    /************  Begin  *********/
                    word.WriteData(RW1.Base, ai, tp, InternalTotal, ExternalTotal);
                    /************  End  *********/
                    word.Close();
                }
            }

            MessageBox.Show("导出成功", this.funName);
            if (cbxOpen.Checked)
            {
                Process.Start(fbdPath.SelectedPath);
            }
        }
コード例 #8
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            btnImport.Enabled = false; //防止误操作

            dgvSals.Rows.Clear();      //清空原数据

            //检查数据是否填写
            if (checkInput() == false)
            {
                MessageBox.Show("请检查输入项", this.funName, MessageBoxButtons.OK);
                btnImport.Enabled = true;
                return;
            }

            if (cbxAgentCs.SelectedItem == null)
            {
                MessageBox.Show("请选择国别", this.funName, MessageBoxButtons.OK);
                btnImport.Enabled = true;
                return;
            }

            //参数缓存保存至文件
            TmpData td = new TmpData
            {
                Title1 = txtYearTitle1.Text.Trim(),
                Title2 = txtYearTitle2.Text.Trim(),
                Annu   = txtYearAnnu.Text.Trim(),
                Rate1  = txtERate1.Text.Trim(),
                Rate2  = txtERate2.Text.Trim(),
                Date1  = dtDeclare.Value,
                Date2  = dtTableOn.Value
            };

            SaveToFile(td);

            //获取模板
            int           tmpID = (int)db.AGENT_COUNTRies.SingleOrDefault(a => a.AC_ID == ((AGENT_COUNTRY)cbxAgentCs.SelectedItem).AC_ID).AC_TIID;
            TEMPLATE_INFO ti    = db.TEMPLATE_INFOs.SingleOrDefault(a => a.TI_ID == tmpID);

            //获取年金限额
            decimal YearAnnuLimit = Convert.ToDecimal(txtYearAnnu.Text.Trim());

            ExcelHelper excel = new ExcelHelper();

            try
            {
                excel.OpenFile(txtDir.Text, 1, true);
                int rowCount = excel.GetDataRowsCount((int)ti.TI_DATAROW);

                //检查列数是否一致
                if (excel.GetColumnsCount() != ti.TI_COLSCOUNT)
                {
                    MessageBox.Show("文件输入项与模板列数不一致,请检查后再导入");
                    btnImport.Enabled = true;
                    return;
                }

                //检查表头是否一致
                if (!cbxNeedCheck.Checked)
                {
                    if (TemplateUtil.CheckTitle(tmpID, excel.GetHeader((int)ti.TI_HEARDERROW)) == false)
                    {
                        MessageBox.Show("导入文件表头与模板不一致,请检查", this.funName, MessageBoxButtons.OK);
                        btnImport.Enabled = true;
                        return;
                    }
                }

                //获取EXCEL薪资数据,姓名为KEY,各月数据LIST
                Dictionary <string, List <List <string> > > lists = excel.GetRows((int)ti.TI_DATAROW, rowCount, SysUtil.GetExcelColumnIntValue(ti.TI_NAMECOL));

                //检查纳税人是否存在
                List <string> namenotexsist = new List <string>();
                foreach (var name in lists.Keys)
                {
                    if (namenotexsist.Contains(name) == false)
                    {
                        if (db.TAX_PLAYERs.SingleOrDefault(a => a.TP_NAME == name && a.TP_ACID == this.ACID) == null)
                        {
                            namenotexsist.Add(name);
                        }
                    }
                }

                if (namenotexsist.Count > 0)
                {
                    MessageBox.Show("以下员工信息尚不存在:" + string.Join <string>(";", namenotexsist), this.funName);
                    btnImport.Enabled = true;
                    return;
                }


                Names      = lists.Keys.ToList();                  //需要导入的已纳税人姓名,下述按姓名
                TaxAlready = new Dictionary <string, decimal>();   //已纳税数据缓存
                decimal rate2 = Convert.ToDecimal(txtERate2.Text); //美元人民币汇率

                foreach (var item in lists)                        //每个纳税人
                {
                    string name = item.Key;

                    var value = item.Value;

                    foreach (var v in value)                                                                      //每个纳税人,每月记录
                    {
                        var     newv   = v.ToList();                                                              //每个纳税人,每月每项数据
                        string  sBonus = v[SysUtil.GetExcelColumnIntValue(ti.TI_BONUSCOL) - 1];                   //年度奖金
                        decimal annu   = Convert.ToDecimal(v[SysUtil.GetExcelColumnIntValue(ti.TI_ANNUCOL) - 1]); //企业年金
                        decimal fortax = FormulaC.GetCal(ti.TI_SALF, v);                                          //计算税前
                        if (Math.Abs(annu) > Math.Abs(YearAnnuLimit))                                             //企业年金与年金限额比较
                        {
                            fortax += (Math.Abs(annu) - Math.Abs(YearAnnuLimit));
                        }

                        newv.Insert(0, name);                                                  //姓名
                        newv.Insert(1, v[SysUtil.GetExcelColumnIntValue(ti.TI_MONTHCOL) - 1]); //月份
                        newv.Insert(2, fortax.ToString());                                     //税前
                        newv.Insert(3, v[SysUtil.GetExcelColumnIntValue(ti.TI_REALCOL) - 1]);  //实发美元
                        newv.Insert(4, (Convert.ToDecimal(newv[3]) * rate2).ToString(""));     //实发RMB
                        newv.Insert(5, "");                                                    //已纳税美元
                        newv.Insert(6, "");                                                    //已纳税RMB
                        newv.Insert(7, v[SysUtil.GetExcelColumnIntValue(ti.TI_BONUSCOL) - 1]); //奖金
                        object[] oA = new object[] { false };                                  //首项为是否选中
                        object[] oB = oA.Concat(newv.ToArray()).ToArray();
                        dgvSals.Rows.Add(oB.ToArray());                                        //加入数据表显示
                    }
                }

                //显示数据统计信息
                UpdateInfo();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                excel.Close();
                btnImport.Enabled = true;
            }
        }
コード例 #9
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;
            }
        }
コード例 #10
0
ファイル: frmMain.cs プロジェクト: Clark-Chen-Dev/TempRepo
 private void loadYear()
 {
     toolStripStatusLabel2.Text = "当前年度:" + SysUtil.GetCurrentYear();
 }
コード例 #11
0
ファイル: frmMain.cs プロジェクト: Clark-Chen-Dev/TempRepo
        private void frmMain_Shown(object sender, EventArgs e)
        {
            frmLogin     loginScreen = new frmLogin();
            DialogResult result      = loginScreen.ShowDialog();


            if (result == DialogResult.OK)
            {
                UserName = loginScreen.UserName;
                toolStripStatusLabel1.Text = "当前用户:" + loginScreen.UserName + "   当前年度:" + SysUtil.GetCurrentYear();

                loadMenu();
            }
            else
            {
                Application.Exit();
            }
        }
コード例 #12
0
        /// <summary>
        /// 报表2数据加载
        /// </summary>
        public void LoadData()
        {
            if (RW2 != null)
            {
                //REPORT2
                lblTitle2.Text    = string.Format("{0}--工资个税", RW2.TPNAME);
                lblYearTitle.Text = RW2.Base.RI_YEARTITLE2;
                lblNote1.Text     = RW2.Base.RI_NOTE1;
                lblNote2.Text     = RW2.Base.RI_NOTE2;


                //如果应纳税所得额<0,后续列直接填空,如果年终奖在此月发放,计算年终奖税时还需将此数据扣除
                var data = RW2.Details.OrderBy(a => a.R2_MONTH).ToList();
                foreach (var d2 in data)
                {
                    c1FlexGrid2.AddItem(new string[] { d2.R2_MONTH.ToString(), d2.R2_SALARY.ToString("F2"), d2.R2_MINUS.ToString("F2"), d2.R2_TAXSALARY.ToString("F2"), string.Format("{0}%", d2.R2_TAXRATE), d2.R2_QUICK.ToString(), d2.R2_NEED.ToString() });
                }

                //年终奖按12个月除,若存在月应纳税所得额为负,应先扣除后再计算税率

                c1FlexGrid2.Rows.Add();
                int index = c1FlexGrid2.Rows.Count - 1;
                c1FlexGrid2[index, 0] = "年终奖";
                TAX_RATE trbonus = SysUtil.GetTaxRate((int)RW2.Base.RI_BONUSTAXRATEID);
                c1FlexGrid2[index, 1] = RW2.Base.RI_BONUS;
                c1FlexGrid2[index, 3] = RW2.Base.RI_BONUS;
                c1FlexGrid2[index, 4] = string.Format("{0}%", trbonus.TR_RATE);
                c1FlexGrid2[index, 5] = trbonus.TR_QUICH;
                c1FlexGrid2[index, 6] = RW2.Base.RI_BONUSTAX;

                //总计
                c1FlexGrid2.Rows.Add();
                index = c1FlexGrid2.Rows.Count - 1;
                c1FlexGrid2[index, 0] = "总计";

                c1FlexGrid2[index, 1] = RW2.Base.RI_SUMS.ToString("F2");
                c1FlexGrid2[index, 3] = RW2.Base.RI_SUMTAXSALARY.ToString("F2");

                c1FlexGrid2[index, 6] = RW2.Base.RI_SUMTAXRMB;        // 应缴税额(总计) Added by CYQ 2018-07-13
                c1FlexGrid2[index, 7] = RW2.Base.RI_SUMTAXALREADYRMB; // 境外已纳税额(总计) Added by CYQ 2018-07-13

                // Modified by CYQ on 2018-09-10
                // 根据财通嘉鑫要求,将“本年已缴/以前留抵”拆分为“境内已纳税额”和“以前留抵税额”
                // Begin
                //c1FlexGrid2[index, 8] = RW2.Base.RI_USEALL; // 本年已缴/以前留抵(总计) Added by CYQ 2018-07-13
                // End

                // Modify by CYQ 2018-07-13
                // 修复境内应补税额显示错误。
                // Begin
                //c1FlexGrid2[index, 9] = RW2.Base.RI_NEEDPACK; // 境内应补税额(总计) Added by CYQ 2018-07-13

                // Modified by CYQ on 2018-09-10
                // 根据财通嘉鑫要求,将“本年已缴/以前留抵”拆分为“境内已纳税额”和“以前留抵税额”
                // Begin
                //c1FlexGrid2[index, 9] = RW2.Base.RI_SUMTAXRMB - RW2.Base.RI_SUMTAXALREADYRMB - RW2.Base.RI_USEALL; // 境内应补税额(总计)
                c1FlexGrid2[index, 8] = RW2.Base.RI_USE2 != null ? RW2.Base.RI_USE2.Value : 0; // 境内已纳税额

                // 以前留抵税额 = 使用可抵税总额 - 境内已纳税额
                if (RW2.Base.RI_USEALL == null)
                {
                    c1FlexGrid2[index, 9] = 0;
                }
                else
                {
                    if (RW2.Base.RI_USE2 == null)
                    {
                        c1FlexGrid2[index, 9] = RW2.Base.RI_USEALL.Value;
                    }
                    else
                    {
                        c1FlexGrid2[index, 9] = RW2.Base.RI_USEALL.Value - RW2.Base.RI_USE2.Value;
                    }
                }

                c1FlexGrid2[index, 10] = RW2.Base.RI_SUMTAXRMB - RW2.Base.RI_SUMTAXALREADYRMB - RW2.Base.RI_USEALL; // 境内应补税额(总计)
                // End
                // End
            }
            RefreshStyle2();
        }