private void frmImportSalary_Load(object sender, EventArgs e) { loadAgents(); // 加载公司信息 Added by CYQ 2018-07-12 AGENT_YEAR ay = db.AGENT_YEARs.SingleOrDefault(a => a.AY_ISCURRENT == true); txtYear.Text = ay.AY_NAME.ToString(); // 申报年度设置为当前年度 Added by CYQ 2018-07-12 this.AYNAME = ay.AY_NAME; // 获取当前年度 Added by CYQ 2018-07-12 cbxOthers.SelectedIndex = 0; // 设置其它数据导入为已纳税额(总额) Added by CYQ 2018-07-12 LoadXML(); //加载上次使用的参数数据 }
/// <summary> /// 获取当前年度 /// </summary> /// <returns></returns> public static int GetCurrentYear() { int result = 0; using (TAXDBDataContext db = new TAXDBDataContext()) { AGENT_YEAR ay = db.AGENT_YEARs.SingleOrDefault(v => v.AY_ISCURRENT == true); if (ay != null) { result = ay.AY_NAME; } return(result); } }
/// <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(); } }
/// <summary> /// 设置为当前年度 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SetcurrentYear(object sender, EventArgs e) { if (dgvYear.SelectedRows.Count != 1) { MessageBox.Show("请选择一行后进行操作", this.funName); return; } using (TAXDBDataContext db = new TAXDBDataContext()) { AGENT_YEAR old = db.AGENT_YEARs.SingleOrDefault(a => a.AY_ISCURRENT == true); if (old != null) { old.AY_ISCURRENT = false; } db.SubmitChanges(); AGENT_YEAR ay = db.AGENT_YEARs.SingleOrDefault(a => a.AY_ID == (int)dgvYear.SelectedRows[0].Cells[0].Value); ay.AY_ISCURRENT = true; db.SubmitChanges(); loadYears(); MessageBox.Show("修改成功", this.funName); } }