public void SelectDTNhanVien() { try { cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.BCDTTheoNhanVien ctxh = new Entities.BCDTTheoNhanVien("Select"); clientstrem = cl.SerializeObj(this.client1, "BCDTTheoNhanVien", ctxh); bcnv = (Entities.BCDTTheoNhanVien[])cl.DeserializeHepper1(clientstrem, bcnv); if (bcnv == null) { bcnv = new Entities.BCDTTheoNhanVien[0]; return; } } catch { } }
private void txttimkiem_TextChanged(object sender, EventArgs e) { try { if (rdbtimkiem3.Checked == true) { return; } if (txttimkiem.Text.Length == 0) { dtgvhienthi.DataSource = new Entities.BCDTTheoNhanVien[0]; return; } int soluong = 0; if (hienthi != null) { if (rdbtimkiem1.Checked == true) { for (int i = 0; i < hienthi.Length; i++) { int kiemtra = hienthi[i].MaNhanVien.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper()); if (kiemtra >= 0) { soluong++; } } if (soluong == 0) { dtgvhienthi.DataSource = new Entities.BCDTTheoNhanVien[0]; return; } Entities.BCDTTheoNhanVien[] hienthitheoid = new Entities.BCDTTheoNhanVien[soluong]; soluong = 0; for (int i = 0; i < hienthi.Length; i++) { int kiemtra = hienthi[i].MaNhanVien.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper()); if (kiemtra >= 0) { hienthitheoid[soluong] = hienthi[i]; soluong++; } } dtgvhienthi.DataSource = hienthitheoid; } if (rdbtimkiem2.Checked == true) { for (int i = 0; i < hienthi.Length; i++) { int kiemtra = hienthi[i].TenNhanVien.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper()); if (kiemtra >= 0) { soluong++; } } if (soluong == 0) { dtgvhienthi.DataSource = new Entities.BCDTTheoNhanVien[0]; return; } Entities.BCDTTheoNhanVien[] hienthitheoma = new Entities.BCDTTheoNhanVien[soluong]; soluong = 0; for (int i = 0; i < hienthi.Length; i++) { int kiemtra = hienthi[i].TenNhanVien.ToString().ToUpper().IndexOf(txttimkiem.Text.ToUpper()); if (kiemtra >= 0) { hienthitheoma[soluong] = hienthi[i]; soluong++; } } dtgvhienthi.DataSource = hienthitheoma; } if (dtgvhienthi.RowCount > 0) { tsslexcel.Enabled = tsslPdf.Enabled = tsslWord.Enabled = tsslchitiet.Enabled = true; } else { tsslexcel.Enabled = tsslPdf.Enabled = tsslWord.Enabled = tsslchitiet.Enabled = false; } } } finally { fix(); } }
public void TongTienNhanVien(DateTime batdau, DateTime ketthuc) { try { int sotang = 0; for (int i = 0; i < nv.Length; i++) { for (int j = 0; j < bcnv.Length; j++) { DateTime hientai = bcnv[j].NgayBan; if (hientai.Date >= batdau.Date && hientai.Date <= ketthuc.Date && bcnv[j].MaNhanVien == nv[i].MaNhanVien) { sotang++; } } } Entities.BCDTTheoNhanVien[] bcdt = new Entities.BCDTTheoNhanVien[sotang]; sotang = 0; double tongtien; for (int i = 0; i < nv.Length; i++) { tongtien = 0; for (int j = 0; j < bcnv.Length; j++) { DateTime hientai = bcnv[j].NgayBan; if (hientai.Date >= batdau.Date && hientai.Date <= ketthuc.Date && bcnv[j].MaNhanVien == nv[i].MaNhanVien) { List<double> bientam = TienIch.TinhDoanhThu(bcnv[j].TongTienThanhToan, bcnv[j].GiaTriThe, bcnv[j].GiaTriTheGiaTri); tongtien += bientam[3]; //bcnv[j].ThanhToanNgay } } if (tongtien != 0) { bcdt[sotang] = new Entities.BCDTTheoNhanVien("", nv[i].MaNhanVien, nv[i].TenNhanVien, new Common.Utilities().FormatMoney(tongtien)); sotang++; } } hienthi = new Entities.BCDTTheoNhanVien[sotang]; for (int i = 0; i < hienthi.Length; i++) { hienthi[i] = bcdt[i]; } //////////////////////////////////////////////Mrk FIX List<Entities.BCDTTheoNhanVien> tem0 = new List<Entities.BCDTTheoNhanVien>(); double tong0 = 0; for (int i = 0; i < bcdt.Length; i++) { if (bcdt[i] == null) { break; } tong0 += double.Parse(bcdt[i].TongTien.Replace(",", "")); tem0.Add(bcdt[i]); } Entities.BCDTTheoNhanVien tem1 = new Entities.BCDTTheoNhanVien(); tem1.TongTien = new Common.Utilities().FormatMoney(tong0); tem1.TenNhanVien = "Tổng Cộng: "; tem0.Add(tem1); //foreach (Entities.BCDTTheoNhanVien item in tem0) //{ // hienthi[i] = item; //} ////////////////////////////////////////////////////// //dtgvhienthi.DataSource = hienthi; if (tem0.Count == 1 && tem0[0].TenNhanVien.Equals("Tổng Cộng: ")) { //tem0.Remove(tem0[0]); tem0 = new List<Entities.BCDTTheoNhanVien>(); } else if (tem0.Count > 1) { foreach (Entities.BCDTTheoNhanVien item in tem0) { if (item.TenNhanVien.Equals("Tổng Cộng: ")) { item.GiaTriThe = 0; } } } dtgvhienthi.DataSource = tem0.ToArray(); if (bcdt.Length > 0) { tsslexcel.Enabled = tsslPdf.Enabled = tsslWord.Enabled = tsslchitiet.Enabled = true; } else { tsslexcel.Enabled = tsslPdf.Enabled = tsslWord.Enabled = tsslchitiet.Enabled = false; } fix(); } catch { } }
public void TongTienNhanVien(DateTime batdau, DateTime ketthuc) { try { int sotang = 0; for (int i = 0; i < nv.Length; i++) { for (int j = 0; j < bcnv.Length; j++) { DateTime hientai = bcnv[j].NgayBan; if (hientai.Date >= batdau.Date && hientai.Date <= ketthuc.Date && bcnv[j].MaNhanVien == nv[i].MaNhanVien) { sotang++; } } } Entities.BCDTTheoNhanVien[] bcdt = new Entities.BCDTTheoNhanVien[sotang]; sotang = 0; double tongtien; for (int i = 0; i < nv.Length; i++) { tongtien = 0; for (int j = 0; j < bcnv.Length; j++) { DateTime hientai = bcnv[j].NgayBan; if (hientai.Date >= batdau.Date && hientai.Date <= ketthuc.Date && bcnv[j].MaNhanVien == nv[i].MaNhanVien) { List <double> bientam = TienIch.TinhDoanhThu(bcnv[j].TongTienThanhToan, bcnv[j].GiaTriThe, bcnv[j].GiaTriTheGiaTri); tongtien += bientam[3]; //bcnv[j].ThanhToanNgay } } if (tongtien != 0) { bcdt[sotang] = new Entities.BCDTTheoNhanVien("", nv[i].MaNhanVien, nv[i].TenNhanVien, new Common.Utilities().FormatMoney(tongtien)); sotang++; } } hienthi = new Entities.BCDTTheoNhanVien[sotang]; for (int i = 0; i < hienthi.Length; i++) { hienthi[i] = bcdt[i]; } //////////////////////////////////////////////Mrk FIX List <Entities.BCDTTheoNhanVien> tem0 = new List <Entities.BCDTTheoNhanVien>(); double tong0 = 0; for (int i = 0; i < bcdt.Length; i++) { if (bcdt[i] == null) { break; } tong0 += double.Parse(bcdt[i].TongTien.Replace(",", "")); tem0.Add(bcdt[i]); } Entities.BCDTTheoNhanVien tem1 = new Entities.BCDTTheoNhanVien(); tem1.TongTien = new Common.Utilities().FormatMoney(tong0); tem1.TenNhanVien = "Tổng Cộng: "; tem0.Add(tem1); //foreach (Entities.BCDTTheoNhanVien item in tem0) //{ // hienthi[i] = item; //} ////////////////////////////////////////////////////// //dtgvhienthi.DataSource = hienthi; if (tem0.Count == 1 && tem0[0].TenNhanVien.Equals("Tổng Cộng: ")) { //tem0.Remove(tem0[0]); tem0 = new List <Entities.BCDTTheoNhanVien>(); } else if (tem0.Count > 1) { foreach (Entities.BCDTTheoNhanVien item in tem0) { if (item.TenNhanVien.Equals("Tổng Cộng: ")) { item.GiaTriThe = 0; } } } dtgvhienthi.DataSource = tem0.ToArray(); if (bcdt.Length > 0) { tsslexcel.Enabled = tsslPdf.Enabled = tsslWord.Enabled = tsslchitiet.Enabled = true; } else { tsslexcel.Enabled = tsslPdf.Enabled = tsslWord.Enabled = tsslchitiet.Enabled = false; } fix(); } catch { } }