private void button1_Click_1(object sender, EventArgs e) { DbHelper.ExportExcel(dataGridView1); }
private void btluu_Click(object sender, EventArgs e) { if (validate()) { if (state == "insert") { //MessageBox.Show("INSERT INTO PhieuNhap(MaPhieuNhap, TenNCC, TenMH, SoLuongNhap,GiaNhap,TienDaThanhToan,NgayThanhToan) VALUES (" + Convert.ToInt32(txtMaPhieuNhap.Text) + ",N'" + txtTenNCC.Text + "',N'" + txtTenMH.Text + "'," + Convert.ToInt32(txtSoLuongNhap.Text) + "," + Convert.ToInt32(txtGiaNhap.Text) + "," + Convert.ToInt32(txtTienDaThanhToan.Text) + ",'"+txtNgayThanhToan.Value.ToShortDateString().ToString() +"')"); string sql = @"INSERT INTO [QLKhoHang].[dbo].[PhieuXuat] ([NgayXuat] ,[NguoiXuat] ,[MaKH] ,[SoLuongXuat] ,[MaHH]) VALUES ('" + fieldNgayXuat.Value.ToString("yyyy/MM/dd") + @"' ,N'" + fieldNguoiXuat.Text + @"' ," + fieldMaKH.SelectedValue + @" ," + Convert.ToInt64(fieldSoLuongXuat.Text) + @" ," + fieldMaHH.SelectedValue + @" )"; if (DbHelper.Query(sql) != -1) { MessageBox.Show("Thêm thành công !"); } else { MessageBox.Show("Có lỗi trong quá trình thêm"); } } //end add else if (state == "update") { string sql = @"UPDATE [QLKhoHang].[dbo].[PhieuXuat] SET [NgayXuat] ='" + fieldNgayXuat.Value.ToString("yyyy/MM/dd") + @"' ,[NguoiXuat] = N'" + fieldNguoiXuat.Text + @"' ,[MaKH] =" + fieldMaKH.SelectedValue + @" ,[SoLuongXuat] =" + Convert.ToInt64(fieldSoLuongXuat.Text) + @" ,[MaHH] = " + fieldMaHH.SelectedValue + @" WHERE MaPXK = " + Convert.ToInt64(fieldMaPXK.Text); if (DbHelper.Query(sql) != -1) { MessageBox.Show("Sửa thành công !"); } else { MessageBox.Show("Có lỗi trong quá trình Sửa"); } } hien(); dongtxt(); mobtn(); }//end validate if (state == "delete" && validate()) { string sql = @"DELETE [QLKhoHang].[dbo].[PhieuXuat] WHERE MaPXK = " + Convert.ToInt64(fieldMaPXK.Text); if (DbHelper.Query(sql) != -1) { MessageBox.Show("Xóa thành công !"); } else { MessageBox.Show("Có lỗi trong quá trình Xóa"); } hien(); dongtxt(); mobtn(); } }