public BaoCaoTon GetBaoCaoFromThangNam(int thang, int nam) { try { var obj = new BaoCaoTon(); if (_connection.State != ConnectionState.Open) { _connection.Open(); } SqlCommand command = new SqlCommand("SELECT * FROM BaoCaoTon WHERE Thang = @thang and Nam=@nam", _connection); command.Parameters.Add("@thang", SqlDbType.Int).Value = thang; command.Parameters.Add("@nam", SqlDbType.Int).Value = nam; SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { obj.MaBaoCaoTon = reader["MaBaoCaoTon"].ToString(); obj.Thang = int.Parse(reader["Thang"].ToString()); obj.Nam = int.Parse(reader["Nam"].ToString()); reader.Close(); } _connection.Close(); return(obj); } catch (Exception ex) { _connection.Close(); } return(null); }
public bool UpdateBaoCao(BaoCaoTon bccn) { try { if (_connection.State != ConnectionState.Open) { _connection.Open(); } string query = "update BaoCaoTon" + "set Thang=@Thang," + "Nam=@Nam" + "where MaBaoCaoTon=@MaBaoCaoTon"; SqlCommand cmd = new SqlCommand(query, _connection); cmd.Parameters.Add("@MaBaoCaoTon", SqlDbType.Char).Value = bccn.MaBaoCaoTon; cmd.Parameters.Add("@Thang", SqlDbType.Int).Value = bccn.Thang; cmd.Parameters.Add("@Nam", SqlDbType.Int).Value = bccn.Nam; cmd.ExecuteNonQuery(); _connection.Close(); return(true); } catch (Exception ex) { _connection.Close(); } return(false); }
private void lậpBáoCáoThángToolStripMenuItem_Click(object sender, EventArgs e) { BaoCaoTon f = new BaoCaoTon(); f.MdiParent = this; f.Show(); }
private void LoadData() { BaoCaoTon bct = new BaoCaoTon(); bct.ThangBaoCao = curr; dgv_DSachSach.DataSource = BaoCaoTon_CT.LoadData(bct); FormatGrid(); }
private void Button_Click_6(object sender, RoutedEventArgs e) { BaoCaoTon baoCaoTon = new BaoCaoTon(); baoCaoTon.myEvent += new EventHandler(OnClosedBaoCaoTonWindow); BtBaoCaoTon.IsEnabled = false; baoCaoTon.Show(); }
public void BaoCaoTon_Update(BaoCaoTon Data) { using (var cmd = new SqlCommand("sp_BaoCaoTon_update", GetConnection())) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@MaVatTuPhuTung", Data.MaVatTuPhuTung)); cmd.Parameters.Add(new SqlParameter("@Thang", Data.Thang)); cmd.Parameters.Add(new SqlParameter("@Nam", Data.Nam)); cmd.Parameters.Add(new SqlParameter("@TonDau", Data.TonDau)); cmd.Parameters.Add(new SqlParameter("@TonCuoi", Data.TonCuoi)); cmd.Parameters.Add(new SqlParameter("@PhatSinh", Data.PhatSinh)); cmd.ExecuteNonQuery(); connection.Close(); } }
public static void ThemBaoCao(BaoCaoTon baoCao) { DataAccessHelper db = new DataAccessHelper(); SqlCommand cmd = db.Command("THEMBAOCAOTON"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@MABCT", baoCao.MaBCT); cmd.Parameters.AddWithValue("@THANG", baoCao.Thang); cmd.Parameters.AddWithValue("@NAM", baoCao.Nam); SqlDataAdapter da = new SqlDataAdapter(cmd); db.dt = new DataTable(); da.Fill(db.dt); }
private void uc_InventoryReport_Load(object sender, EventArgs e) { cbo_Year.DataSource = BaoCaoTon.LoadYear(); cbo_Year.DisplayMember = "Nam"; cbo_Year.ValueMember = "Nam"; cbo_Year.Text = DateTime.Today.ToString("yyyy"); pn_T10.Appearance.BackColor = Color.Salmon; pn_T10.Appearance.Options.UseBackColor = true; pn_T10.LookAndFeel.UseDefaultLookAndFeel = false; pn_T10.LookAndFeel.Style = LookAndFeelStyle.Flat; curr = new DateTime(2016, 10, 01); LoadData(); }
public static void ThemPhieuSuaChua(PhieuSuaChua psc) { PhieuSuaChuaDAL.ThemPhieuSuaChua(psc); string hieuXe = XeDAL.GetHieuXe(psc.BienSo); string maBCDT = BaoCaoDoanhThuBLL.GetMaBC(psc.NgaySuaChua.Month, psc.NgaySuaChua.Year); if (maBCDT == "") { maBCDT = BaoCaoDoanhThuBLL.AutoMABC(); BaoCaoDoanhThu baoCao = new BaoCaoDoanhThu(); baoCao.MaBaoCaoDoanhThu = maBCDT; baoCao.Thang = psc.NgaySuaChua.Month; baoCao.Nam = psc.NgaySuaChua.Year; BaoCaoDoanhThuBLL.ThemBC(baoCao); } ChiTietBaoCaoDoanhThu chiTiet = new ChiTietBaoCaoDoanhThu(); chiTiet.MaBC = maBCDT; chiTiet.MaCTBC = ChiTietBaoCaoDoanhThuBLL.GetMaCTBC(maBCDT, hieuXe); if (chiTiet.MaCTBC == "") { chiTiet.MaCTBC = ChiTietBaoCaoDoanhThuBLL.AutoMACTBC(); chiTiet.HieuXe = hieuXe; ChiTietBaoCaoDoanhThuBLL.ThemCTBC(chiTiet); } ChiTietBaoCaoDoanhThuBLL.CapNhatSoLuotSua(chiTiet); string maBCT = BaoCaoTonBLL.GetMaBCT(psc.NgaySuaChua.Month, psc.NgaySuaChua.Year); if (maBCT == "") { maBCT = BaoCaoTonBLL.AutoMABCT(); BaoCaoTon BCT = new BaoCaoTon(); BCT.MaBCT = maBCT; BCT.Thang = psc.NgaySuaChua.Month; BCT.Nam = psc.NgaySuaChua.Year; BaoCaoTonBLL.ThemBC(BCT); } }
// Chuyển giá trị trong Textbox thành BaoCaoTon public BaoCaoTon Textbox_To_BaoCaoTon() { try { BaoCaoTon result = new BaoCaoTon(); result.id = (int)this.numbid.Value; result.id_tblSach = (int)this.numbid_tblSach.Value; result.chiPhi = (int)this.numbchiPhi.Value; result.ngay = this.datengay.Value; result.moTa = (this.txtmoTa.Text == null ? null : (string)(this.txtmoTa.Text)); return(result); } catch (Exception ex) { ShowMessage(ex.Message, false); } // Không load được hoặc xảy ra lỗi return(null); }
public static void ThemBC(BaoCaoTon baoCao) { BaoCaoTonDAL.ThemBaoCao(baoCao); DataTable dt = PhuTungBLL.ListPhuTung(); foreach (DataRow row in dt.Rows) { ChiTietBaoCaoTon chiTiet = new ChiTietBaoCaoTon(); chiTiet.MaCTBCT = ChiTietBaoCaoTonBLL.AutoMaCTBCT(); chiTiet.MaBCT = baoCao.MaBCT; chiTiet.TenPT = row.ItemArray[1].ToString(); chiTiet.TonDau = int.Parse(PhuTungBLL.LaySoLuongPhuTung(chiTiet.TenPT)); chiTiet.TonCuoi = chiTiet.TonDau; chiTiet.PhatSinh = 0; ChiTietBaoCaoTonBLL.themChiTietBaoCao(chiTiet); } }
private void btnThemSL_Click(object sender, EventArgs e) { int soluong = int.Parse(txtSoLuong.Text); frmMuaPhuTung form = new frmMuaPhuTung(txtSoLuong); form.ShowDialog(); if (btnThayDoi.Enabled) { PhuTung phuTung = new PhuTung(); phuTung.MaPhuTung = txtMaVTPT.Text; phuTung.TenPhuTung = txtTenPT.Text; phuTung.SoLuong = int.Parse(txtSoLuong.Text); //cap nhat phat sinh DateTime today = DateTime.Now; string maBCT = BaoCaoTonBLL.GetMaBCT(today.Month, today.Year); if (maBCT == "") { BaoCaoTon baocao = new BaoCaoTon(); baocao.MaBCT = BaoCaoTonBLL.AutoMABCT(); maBCT = baocao.MaBCT; baocao.Thang = today.Month; baocao.Nam = today.Year; BaoCaoTonBLL.ThemBC(baocao); } string maCTBCT = ChiTietBaoCaoTonBLL.getMaCTBCT(maBCT, phuTung.TenPhuTung); ChiTietBaoCaoTon chitiet = new ChiTietBaoCaoTon(); chitiet.MaBCT = maBCT; chitiet.MaCTBCT = maCTBCT; chitiet.TenPT = phuTung.TenPhuTung; chitiet.TonCuoi = 0; chitiet.PhatSinh = int.Parse(txtSoLuong.Text) - soluong; chitiet.TonDau = 0; ChiTietBaoCaoTonBLL.capNhatPhatSinh(chitiet); PhuTungBLL.ThayDoiSoLuongPhuTung(phuTung); GetDataGridView(); } }
// Chuyển giá trị trong DataGridView thành BaoCaoTon public BaoCaoTon DataGridView_To_BaoCaoTon(int index) { try { BaoCaoTon result = new BaoCaoTon(); var id = this.dgvData.Rows[index].Cells["id"].Value; if (id != null) { result.id = int.Parse(id.ToString()); } var id_tblSach = this.dgvData.Rows[index].Cells["id_tblSach"].Value; if (id_tblSach != null) { result.id_tblSach = (id_tblSach == null ? null : (int?)int.Parse(id_tblSach.ToString())); } var chiPhi = this.dgvData.Rows[index].Cells["chiPhi"].Value; if (chiPhi != null) { result.chiPhi = (chiPhi == null ? null : (int?)int.Parse(chiPhi.ToString())); } var ngay = this.dgvData.Rows[index].Cells["ngay"].Value; if (ngay != null) { result.ngay = (ngay == null ? null : (DateTime?)DateTime.Parse(ngay.ToString())); } var moTa = this.dgvData.Rows[index].Cells["moTa"].Value; if (moTa != null) { result.moTa = (moTa == null ? null : (string)(moTa)); } return(result); } catch (Exception ex) { ShowMessage(ex.Message, false); } // Không load được hoặc xảy ra lỗi return(null); }
public bool ThemBaoCao(BaoCaoTon baocaoton) { if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); } try { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandType = CommandType.Text; cmd.CommandText = System.String.Concat("insert into baocaoton(thang,nam,masach,tensach,soluongnhap,soluongban,soluongton) values('" + baocaoton.Thang.ToString() + "','" + baocaoton.Nam.ToString() + "','" + baocaoton.MaSach + "',N'" + baocaoton.TenSach + "'," + baocaoton.SoLuongNhap.ToString() + "," + baocaoton.SoLuongBan.ToString() + "," + baocaoton.SoLuongTon.ToString() + ")"); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); conn.Close(); return(true); } catch { conn.Close(); return(false); } }
public bool AddBaoCaoTon(BaoCaoTon bct) { try { if (_connection.State != ConnectionState.Open) { _connection.Open(); } string sql = "insert into BaoCaoTon values(@MaBaoCao,@Thang,@Nam)"; SqlCommand cmd = new SqlCommand(sql, _connection); cmd.Parameters.Add("@MaBaoCao", SqlDbType.Char).Value = bct.MaBaoCaoTon; cmd.Parameters.Add("@Thang", SqlDbType.Int).Value = bct.Thang; cmd.Parameters.Add("@Nam", SqlDbType.Int).Value = bct.Nam; cmd.ExecuteNonQuery(); _connection.Close(); return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); _connection.Close(); } return(false); }
public bool ThemBaoCao(BaoCaoTon baocao) { return(objBaoCao.ThemBaoCao(baocao)); }
public bool AddBaoCao(BaoCaoTon bct) { return(objBCCT.AddBaoCaoTon(bct)); }
public bool UpdateBaoCao(BaoCaoTon bct) { return(objBCCT.UpdateBaoCao(bct)); }
public static void BaoCaoTon_Update(BaoCaoTon Data) { db.BaoCaoTon_Update(Data); }
public static void BaoCaoTon_Insert(BaoCaoTon Data) { db.BaoCaoTon_Insert(Data); }