private void btnIn_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); DateTime ngayBD = DateTime.ParseExact(dtpTuNgay.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); DateTime ngayKT = DateTime.ParseExact(dtpDenngay.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); //Xử lý dữ liệu vào KT_SoDu_TK _KTXuLySoDuRepo.DeleteSoDuTk(ngayBD, ngayKT); _KTXuLySoDuRepo.InsertSoDuTk(ngayBD, ngayKT); dt.Columns.AddRange(new DataColumn[] { new DataColumn("MA_TK"), new DataColumn("TEN_TK") , new DataColumn("VND_DU_NO", System.Type.GetType("System.Double")), new DataColumn("VND_DU_CO", System.Type.GetType("System.Double")) , new DataColumn("VND_PS_NO", System.Type.GetType("System.Double")), new DataColumn("VND_PS_CO", System.Type.GetType("System.Double")) , new DataColumn("VND_CK_NO", System.Type.GetType("System.Double")), new DataColumn("VND_CK_CO", System.Type.GetType("System.Double"))}); _db = new dbVstoreAppDataContext(Const.builder.ConnectionString); var list = _KTXuLySoDuRepo.GetSoDuTk(ngayBD, ngayKT); foreach (var item in list) { DataRow dr = dt.NewRow(); dr["MA_TK"] = item.MA_TK; dr["TEN_TK"] = item.TEN_TK; dr["VND_DU_NO"] = Utils.CDblDef(item.VND_DU_NO, 0); dr["VND_DU_CO"] = Utils.CDblDef(item.VND_DU_CO, 0); dr["VND_PS_NO"] = Utils.CDblDef(item.VND_PS_NO, 0); dr["VND_PS_CO"] = Utils.CDblDef(item.USD_PS_CO, 0); dr["VND_CK_NO"] = Utils.CDblDef(item.VND_CK_NO, 0); dr["VND_CK_CO"] = Utils.CDblDef(item.VND_CK_CO, 0); dt.Rows.Add(dr); } ExcelUtlity Utlity = new ExcelUtlity(); if (rdMau1.Checked) Utlity.WriteDataTableToExcel_InCanDoiPhatSinhTaiKhoan_Mau1(dt, dtpTuNgay.Value, dtpDenngay.Value, dtNgayin.Value); else Utlity.WriteDataTableToExcel_InCanDoiPhatSinhTaiKhoan_Mau1(dt, dtpTuNgay.Value, dtpDenngay.Value, dtNgayin.Value); }
private void btnLuu_Click(object sender, EventArgs e) { try { _KT_CTuGocRepo = new KT_CTuGocRepo(); int id = Utils.CIntDef(gridView2.GetRowCellValue(gridView2.FocusedRowHandle, "ID"), 0); KT_CTuGoc obj = _KT_CTuGocRepo.GetById(id); if (obj != null) { obj.MA_CTU = txtLoai.Text; obj.SO_CTU = txtSo.Text; obj.NGAY_CTU = null; if(txtNgay.Text.Length >0) obj.NGAY_CTU = DateTime.ParseExact(txtNgay.Text, "d/M/yyyy", CultureInfo.InvariantCulture); obj.DIEN_GIAI = txtDiengiai.Text; obj.TEN_KH = txtTenKH.Text; obj.HD_SO = txtSoHD.Text; obj.HD_NGAY = null; if (txtNgayHD.Text.Length > 0) obj.HD_NGAY = DateTime.ParseExact(txtNgayHD.Text, "d/M/yyyy", CultureInfo.InvariantCulture); obj.HD_SR = txtSeriHD.Text; //txtUsdTienHang.Text = string.Format("", o obj.CHIET_KHAU_USD = Utils.CDblDef(txtUsdChietkhau.Text.Replace(",", "").Replace(".", ""), 0); obj.TIEN_THUE_USD = Utils.CDblDef(txtUsdTienthue.Text.Replace(",", "").Replace(".", ""), 0); obj.TONG_TIEN_USD = Utils.CDblDef(txtUsdTongtien.Text.Replace(",", "").Replace(".", ""), 0); obj.TIEN_HANG = Utils.CDblDef(txtVndTienhang.Text.Replace(",", "").Replace(".", ""), 0); //txtVndChietkhau1.Text = string.Format("{0:#,###}", obj.CHIET_KHAU_VND); obj.CHIET_KHAU_VND = Utils.CDblDef(txtVndChietkhau2.Text.Replace(",", "").Replace(".", ""), 0); //txtVndTienthue1.Text = string.Format("{0:#,###}", obj.TIEN_THUE_VND); obj.TIEN_THUE_VND = Utils.CDblDef(txtVndTienthue2.Text.Replace(",", "").Replace(".", ""), 0); obj.TONG_TIEN_VND = Utils.CDblDef(txtVndTongtien.Text.Replace(",", "").Replace(".", ""), 0); _KT_CTuGocRepo.Update(obj); MessageBox.Show("Cập nhật thành công!", "Thông báo"); int row = gridView2.FocusedRowHandle; _db = new dbVstoreAppDataContext(Const.builder.ConnectionString); var list = this._db.KT_CTuGocs.Where(u => u.NGAY_CTU.Value != null && u.NGAY_CTU.Value.Month == Utils.CIntDef(fTerm._month, 0) && u.NGAY_CTU.Value.Year == Utils.CIntDef(fTerm._year, 0) && (u.NGAY_CTU.Value.Day >= Utils.CIntDef(txtTungay.Text, 0) || Utils.CIntDef(txtTungay.Text, 0) == 0) && (u.NGAY_CTU.Value.Day <= Utils.CIntDef(txtDenngay.Text, 0) || Utils.CIntDef(txtDenngay.Text, 0) == 0) && (u.MA_CTU == Utils.CStrDef(cboLoaichungtu.SelectedValue, "") || Utils.CStrDef(cboLoaichungtu.SelectedValue, "") == "") && (u.SO_CTU == Utils.CStrDef(cboSochungtu.SelectedValue, "") || Utils.CStrDef(cboSochungtu.SelectedValue, "") == "")); gridData2.DataSource = list; gridView2.FocusedRowHandle = row; getInfo(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnXemchitiet_Click(object sender, EventArgs e) { _db = new dbVstoreAppDataContext(Const.builder.ConnectionString); var list = this._db.KT_CTuGocs.Where(u => u.NGAY_CTU.Value != null && u.NGAY_CTU.Value.Month == Utils.CIntDef(fTerm._month, 0) && u.NGAY_CTU.Value.Year == Utils.CIntDef(fTerm._year, 0) && (u.NGAY_CTU.Value.Day >= Utils.CIntDef(txtTungay.Text, 0) || Utils.CIntDef(txtTungay.Text, 0) == 0) && (u.NGAY_CTU.Value.Day <= Utils.CIntDef(txtDenngay.Text, 0) || Utils.CIntDef(txtDenngay.Text, 0) == 0) && (u.MA_CTU == Utils.CStrDef(cboLoaichungtu.SelectedValue, "") || Utils.CStrDef(cboLoaichungtu.SelectedValue, "") == "") && (u.SO_CTU == Utils.CStrDef(cboSochungtu.SelectedValue, "") || Utils.CStrDef(cboSochungtu.SelectedValue, "") == "")); gridData2.DataSource = list; tabControl1.SelectedTab = tabItem2; getInfo(); }