public int Delete(SQLDAL DAL) { return 0; // DAL.BeginTransaction(); // m_dbConnection = DAL.m_conn; // if (m_dbConnection.State == ConnectionState.Closed) // m_dbConnection.Open(); // string sql = "Delete from Ton_dau_ky WHERE ma_phieu_nhap=@ma_phieu_nhap"; // SqlCommand command = new SqlCommand(sql, m_dbConnection, DAL.m_trans); // command.CommandType = CommandType.Text; //// command.Parameters.Add(new SqlParameter("@ma_phieu_nhap", Ma_phieu_nhap)); // int result = command.ExecuteNonQuery(); // DAL.CommitTransaction(); // return result; }
public int removebyKey(SQLDAL DAL, string ma_Phieunhap, string ma_vat_tu) { DatabaseHelper help = new DatabaseHelper(); help.ConnectDatabase(); using (var dbcxtransaction = help.ent.Database.BeginTransaction()) { Chi_Tiet_Phieu_Nhap_Vat_Tu deptBook = new Chi_Tiet_Phieu_Nhap_Vat_Tu { Ma_vat_tu = ma_vat_tu, Ma_phieu_nhap = ma_Phieunhap }; help.ent.Entry(deptBook).State = EntityState.Deleted; help.ent.SaveChanges(); dbcxtransaction.Commit(); return 1; } return 0; }
//public DataTable GetAll() //{ // DatabaseHelper help = new DatabaseHelper(); // help.ConnectDatabase(); // using (var dbcxtransaction = help.ent.Database.BeginTransaction()) // { // var entryPoint = (from ep in help.ent.Chi_Tiet_Phieu_Xuat_Tam // select ep // ).ToList(); // return Utilities.clsThamSoUtilities.ToDataTable(entryPoint); // } // //m_dbConnection.Open(); // //DataTable dt = new DataTable(); // //string sql = "SELECT * FROM Chi_Tiet_Phieu_xuat_tam "; // //SqlCommand command = new SqlCommand(sql, m_dbConnection); // //SqlDataAdapter da = new SqlDataAdapter(command); // //da.Fill(dt); // //m_dbConnection.Close(); // //return dt; //} public int Insert(SQLDAL dal) { //DatabaseHelper help = new DatabaseHelper(); //help.ConnectDatabase(); // insert //try //{ // using (var dbcxtransaction = help.ent.Database.BeginTransaction()) // { // var t = new Chi_Tiet_Phieu_Xuat_Tam //Make sure you have a table called test in DB // { // Ma_phieu_xuat_tam = this.Ma_phieu_xuat_tam, // Ma_vat_tu = this.Ma_vat_tu, // ID = Guid.NewGuid(), // So_luong_hoan_nhap = this.So_luong_hoan_nhap, // So_luong_giu_lai = this.So_luong_giu_lai, // So_luong_thuc_lanh = this.so_luong_thuc_lanh, // So_luong_de_nghi = this.So_luong_de_nghi, // }; // help.ent.Chi_Tiet_Phieu_Xuat_Tam.Add(t); // help.ent.SaveChanges(); // dbcxtransaction.Commit(); // return 1; // } //} //catch (Exception ex) //{ return 0; //} //m_dbConnection = dal.m_conn; //if (m_dbConnection.State == ConnectionState.Closed) // m_dbConnection.Open(); //string sql = ""; //sql += "INSERT INTO Chi_Tiet_Phieu_xuat_tam (ma_phieu_xuat_tam,Ma_vat_tu,So_luong_hoan_nhap,So_luong_giu_lai,so_luong_thuc_lanh) "; //sql += "VALUES(@ma_phieu_xuat_tam,@Ma_vat_tu,@So_luong_hoan_nhap,@So_luong_giu_lai,@so_luong_thuc_lanh)"; //SqlCommand command = new SqlCommand(sql, m_dbConnection, dal.m_trans); //command.CommandType = CommandType.Text; ////command.Parameters.Add(new SQLiteParameter("@BangKe_Id", BangKe_Id)); //command.Parameters.Add(new SqlParameter("@ma_phieu_xuat_tam", Ma_phieu_xuat_tam)); //command.Parameters.Add(new SqlParameter("@Ma_vat_tu", Ma_vat_tu)); ////command.Parameters.Add(new SqlParameter("@So_luong_de_nghi", So_luong_de_nghi)); //command.Parameters.Add(new SqlParameter("@So_luong_hoan_nhap", So_luong_hoan_nhap)); //command.Parameters.Add(new SqlParameter("@So_luong_giu_lai", So_luong_giu_lai)); //command.Parameters.Add(new SqlParameter("@so_luong_thuc_lanh", so_luong_thuc_lanh)); //int result = command.ExecuteNonQuery(); //return result; }
public int Update(SQLDAL DAL) { return 0; //{ // DAL.BeginTransaction(); // m_dbConnection = DAL.m_conn; // if (m_dbConnection.State == ConnectionState.Closed) // m_dbConnection.Open(); // string sql = ""; // sql += "UPDATE Ton_dau_ky "; // sql += "Set Ma_vat_tu=@Ma_vat_tu, id_kho =@id_kho ,so_luong=@so_luong "; // sql += "WHERE Ma_vat_tu=@Ma_vat_tu"; // SqlCommand command = new SqlCommand(sql, m_dbConnection, DAL.m_trans); // command.CommandType = CommandType.Text; // command.Parameters.Add(new SqlParameter("@ID_kho", ID_kho)); // command.Parameters.Add(new SqlParameter("@Ma_vat_tu", Ma_vat_tu)); // command.Parameters.Add(new SqlParameter("@so_luong", So_luong)); // int result = command.ExecuteNonQuery(); // DAL.CommitTransaction(); // return result; }
public int Insert(SQLDAL DAL) { return 0; //DAL.BeginTransaction(); //m_dbConnection = DAL.m_conn; //if (m_dbConnection.State == ConnectionState.Closed) //m_dbConnection.Open(); //string sql = ""; //sql += "INSERT INTO Ton_dau_ky (Ma_vat_tu,id_kho,so_luong) "; //sql += "VALUES(@Ma_vat_tu,@id_kho,@so_luong)"; //SqlCommand command = new SqlCommand(sql, m_dbConnection, DAL.m_trans); //command.CommandType = CommandType.Text; ////command.Parameters.Add(new SQLiteParameter("@BangKe_Id", BangKe_Id)); //command.Parameters.Add(new SqlParameter("@Ma_vat_tu", Ma_vat_tu)); //command.Parameters.Add(new SqlParameter("@id_kho", ID_kho)); //command.Parameters.Add(new SqlParameter("@so_luong", So_luong)); //int result = command.ExecuteNonQuery(); //DAL.CommitTransaction(); //return result; }
public int Insert(SQLDAL dal) { DatabaseHelper help = new DatabaseHelper(); help.ConnectDatabase(); // insert using (var dbcxtransaction = help.ent.Database.BeginTransaction()) { try { var t = new Phieu_Nhap_Kho //Make sure you have a table called test in DB { Ma_phieu_nhap = this.Ma_phieu_nhap, Kho_nhan = this.Kho_nhan, Ngay_lap = this.Ngay_lap, Ly_do = this.Ly_do, So_hoa_don = this.So_hoa_don, Cong_trinh = this.Cong_trinh, Dia_Chi = this.Dia_chi, ID_Loai_Phieu_Nhap = this.ID_Loai_Phieu_Nhap, Kho_xuat_ra = this.Kho_xuat_ra, Da_phan_kho = this.Da_phan_kho, // ID_phieu_nhap = this.ID_phieu_nhap, ID_kho = this.ID_khoNhan, isGoiDau = this.isGoiDau, }; help.ent.Phieu_Nhap_Kho.Add(t); help.ent.SaveChanges(); dbcxtransaction.Commit(); return 1; } catch (Exception ex) { dbcxtransaction.Rollback(); return 0; } } }
public int Insert(SQLDAL dal) { DatabaseHelper help = new DatabaseHelper(); help.ConnectDatabase(); // insert try { using (var dbcxtransaction = help.ent.Database.BeginTransaction()) { var t = new Phieu_Xuat_Tam_Vat_Tu //Make sure you have a table called test in DB { Ma_phieu_xuat_tam = this.Ma_phieu_xuat_tam, ID_kho = this.ID_kho, // ID = Guid.NewGuid(), ID_nhan_vien = this.ID_Nhan_vien, Ngay_xuat = this.Ngay_xuat, Ly_do = this.Ly_do, Cong_trinh = this.Cong_trinh, Dia_chi = this.Dia_chi, }; help.ent.Phieu_Xuat_Tam_Vat_Tu.Add(t); help.ent.SaveChanges(); dbcxtransaction.Commit(); return 1; } } catch (Exception ex) { return 0; } // dal.BeginTransaction(); // m_dbConnection = dal.m_conn; // if(m_dbConnection.State == ConnectionState.Closed) // m_dbConnection.Open(); // string sql = ""; // sql += "INSERT INTO Phieu_xuat_tam_vat_tu (ma_phieu_xuat_tam,ID_kho,ID_nhan_vien,ngay_xuat,Ly_do,Cong_trinh,Dia_chi) "; // sql += "VALUES(@ma_phieu_xuat_tam,@ID_kho,@ID_nhan_vien,@ngay_xuat,@Ly_do,@Cong_trinh,@Dia_chi)"; // SqlCommand command = new SqlCommand(sql, m_dbConnection,dal.m_trans); // command.CommandType = CommandType.Text; // //command.Parameters.Add(new SQLiteParameter("@BangKe_Id", BangKe_Id)); // command.Parameters.Add(new SqlParameter("@Ma_phieu_xuat_tam", Ma_phieu_xuat_tam)); // command.Parameters.Add(new SqlParameter("@ID_kho", ID_kho)); // command.Parameters.Add(new SqlParameter("@ngay_xuat", Ngay_xuat.ToString("yyyy-MM-dd"))); // command.Parameters.Add(new SqlParameter("@ID_nhan_vien", ID_Nhan_vien)); // command.Parameters.Add(new SqlParameter("@Ly_do", Ly_do)); // command.Parameters.Add(new SqlParameter("@Cong_trinh", Cong_trinh)); // command.Parameters.Add(new SqlParameter("@Dia_chi", Dia_chi)); //// command.Parameters.Add(new SqlParameter("@Ly_do", Ly_do)); // //command.Parameters.Add(new SqlParameter("@ma_phieu_nhap", Ma_phieu_nhap)); // int result = command.ExecuteNonQuery(); // dal.CommitTransaction(); // return result; }