/// <summary> /// Select Bảng /// </summary> /// <returns></returns> public Entities.BCDTTheoNhanVien[] Select(Entities.BCDTTheoNhanVien bcdtt) { Sql = new Constants.Sql(); dttnv = new Constants.BCDTTheoNhanVien(); string sql = Sql.BCDTTheoNhanVienTheoMa; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("@ID", SqlDbType.VarChar, 20).Value = bcdtt.MaNhanVien; cmd.Parameters.Add("@Truoc", SqlDbType.DateTime).Value = bcdtt.Truoc; cmd.Parameters.Add("@Sau", SqlDbType.DateTime).Value = bcdtt.Sau; SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); //Insert Category into ArrayList ArrayList arr = new ArrayList(); while (dr.Read()) { Entities.BCDTTheoNhanVien bcdtnv1 = new Entities.BCDTTheoNhanVien(); bcdtnv1.MaNhanVien = dr[dttnv.MaNhanVien].ToString(); bcdtnv1.TenNhanVien = dr[dttnv.TenNhanVien].ToString(); bcdtnv1.MaHDBanHang = dr[dttnv.MaHDBanHang].ToString(); bcdtnv1.NgayBan = Convert.ToDateTime(dr[dttnv.NgayBan].ToString()); bcdtnv1.ThanhToanNgay = double.Parse(dr[dttnv.ThanhToanNgay].ToString()); bcdtnv1.ThanhToanKhiLapPhieu = double.Parse(dr[dttnv.ThanhToanKhiLapPhieu].ToString()); bcdtnv1.TongTienThanhToan = double.Parse(dr["TongTienThanhToan"].ToString()); bcdtnv1.GiaTriThe = double.Parse(dr["GiaTriThe"].ToString()); bcdtnv1.GiaTriTheGiaTri = double.Parse(dr["GiaTriTheGiaTri"].ToString()); arr.Add(bcdtnv1); } int n = arr.Count; if (n == 0) { return(null); } Entities.BCDTTheoNhanVien[] arrC = new Entities.BCDTTheoNhanVien[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.BCDTTheoNhanVien)arr[i]; } //Giai phong bo nho arr = null; cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return(arrC); }
/// <summary> /// Select Bảng /// </summary> /// <returns></returns> public Entities.BCDTTheoNhanVien[] Select(Entities.BCDTTheoNhanVien bcdtt) { Sql = new Constants.Sql(); dttnv = new Constants.BCDTTheoNhanVien(); string sql = Sql.BCDTTheoNhanVienTheoMa; Connection conn = new Connection(); SqlConnection cn = conn.openConnection(); SqlCommand cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("@ID", SqlDbType.VarChar,20).Value = bcdtt.MaNhanVien; cmd.Parameters.Add("@Truoc", SqlDbType.DateTime).Value = bcdtt.Truoc; cmd.Parameters.Add("@Sau", SqlDbType.DateTime).Value = bcdtt.Sau; SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); //Insert Category into ArrayList ArrayList arr = new ArrayList(); while (dr.Read()) { Entities.BCDTTheoNhanVien bcdtnv1 = new Entities.BCDTTheoNhanVien(); bcdtnv1.MaNhanVien = dr[dttnv.MaNhanVien].ToString(); bcdtnv1.TenNhanVien = dr[dttnv.TenNhanVien].ToString(); bcdtnv1.MaHDBanHang = dr[dttnv.MaHDBanHang].ToString(); bcdtnv1.NgayBan = Convert.ToDateTime(dr[dttnv.NgayBan].ToString()); bcdtnv1.ThanhToanNgay = double.Parse(dr[dttnv.ThanhToanNgay].ToString()); bcdtnv1.ThanhToanKhiLapPhieu = double.Parse(dr[dttnv.ThanhToanKhiLapPhieu].ToString()); bcdtnv1.TongTienThanhToan = double.Parse(dr["TongTienThanhToan"].ToString()); bcdtnv1.GiaTriThe = double.Parse(dr["GiaTriThe"].ToString()); bcdtnv1.GiaTriTheGiaTri = double.Parse(dr["GiaTriTheGiaTri"].ToString()); arr.Add(bcdtnv1); } int n = arr.Count; if (n == 0) return null; Entities.BCDTTheoNhanVien[] arrC = new Entities.BCDTTheoNhanVien[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.BCDTTheoNhanVien)arr[i]; } //Giai phong bo nho arr = null; cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); cn = null; conn = null; return arrC; }
public frmBaoCaorpt(string hanhDong, string ma, DateTime truoc, DateTime sau) { try { InitializeComponent(); switch (hanhDong) { case "NhanVien": { CongTy(); cl = new Server_Client.Client(); this.client1 = cl.Connect(Luu.IP, Luu.Ports); Entities.BCDTTheoNhanVien ctxh = new Entities.BCDTTheoNhanVien("SelectTheoMa", ma, truoc, sau); Entities.BCDTTheoNhanVien[] pt1 = new Entities.BCDTTheoNhanVien[1]; clientstrem = cl.SerializeObj(this.client1, "BCDTTheoNhanVien", ctxh); pt1 = (Entities.BCDTTheoNhanVien[])cl.DeserializeHepper1(clientstrem, pt1); if (pt1 == null) { MessageBox.Show("Không có dữ liệu", "Hệ thống cảnh báo"); return; } //Tổng tiền thực thu foreach (Entities.BCDTTheoNhanVien item in pt1) { List<double> bientam = TienIch.TinhDoanhThu(item.TongTienThanhToan, item.GiaTriThe, item.GiaTriTheGiaTri); item.TongTienThanhToan = bientam[0]; item.GiaTriThe = bientam[1]; item.GiaTriTheGiaTri = bientam[2]; item.TongTienThucThu = bientam[3]; } GUI.Report.rptBCDoanhThuTheoMaNhanVien report = new GUI.Report.rptBCDoanhThuTheoMaNhanVien(); report.SetDataSource(pt1); crvReport.ReportSource = report; report.SetParameterValue("TenCongTy", CT.TenCongTy); report.SetParameterValue("DiaChiCongTy", CT.DiaChi); report.SetParameterValue("DienThoai", CT.SoDienThoai); report.SetParameterValue("FaxCongTy", CT.Fax); report.SetParameterValue("Web", CT.Website); report.SetParameterValue("TenBaoCao", "Báo Cáo Doanh Thu Theo Nhân Viên"); report.SetParameterValue("NgayTao", new Common.Utilities().XuLy(2, DateServer.Date().ToShortDateString())); report.SetParameterValue("MaNhanVien", Common.Utilities.User.TenNhanVien); report.SetParameterValue("Email", CT.Email); report.SetParameterValue("tuNgay", new Common.Utilities().XuLy(2, truoc.ToShortDateString())); report.SetParameterValue("DenNgay", new Common.Utilities().XuLy(2, sau.ToShortDateString())); crvReport.Show(); break; } default: break; } } catch { } }