void TatCaThe() { try { DataTable dt = TheDAL.TatCaThe(dtpTuNgay.Text, dtpDenNgay.Text); FillData(dt); } catch { ErrorMessageDAL.DataAccessError(); } }
void DSTheTheoCMND() { try { DataTable dt = TheDAL.TheTheoCMND(txtThongTin.Text); FillData(dt); } catch { ErrorMessageDAL.DataAccessError(); } }
void DSTheDaGiao() { try { DataTable dt = TheDAL.TheDaGiao(dtpTuNgay.Text, dtpDenNgay.Text); FillData(dt); } catch { ErrorMessageDAL.DataAccessError(); } }
/// <summary> This method returns every record for this table/surface. /// Do not use it on too big tables. /// <para>St4mpede guid:{4A910A99-9A50-4977-B2A2-404240CDDC73}</para> /// </summary> public IList<TheDAL.Poco.Project> GetAll( TheDAL.CommitScope context ) { const string Sql = @" Select * From Project "; var res = context.Connection.Query<TheDAL.Poco.Project>( Sql, null, context.Transaction, false, null, null); return res.ToList(); }
private void btnDeleteThe_Click(object sender, EventArgs e) { string soThe = dgvThongTinThe.SelectedRows[0].Cells[3].Value.ToString(); string soTK = dgvThongTinThe.SelectedRows[0].Cells[2].Value.ToString(); string loaiThe = dgvThongTinThe.SelectedRows[0].Cells[4].Value.ToString(); try { The the = new The(ThongTinTheDAL.LayThongTinThe(soTK, loaiThe)); if (Thong_tin_dang_nhap.ma_pb != the.maPB) { MessageBox.Show("Không có quyền xóa thẻ này!\nLiên hệ chi nhánh phát hành thẻ để được hỗ trợ!", "Thông báo", MessageBoxButtons.OK); return; } } catch { ErrorMessageDAL.DataAccessError(); return; } DialogResult result = MessageBox.Show("Có chắc chắn xóa thẻ này?", "Thông báo", MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { try { if (string.IsNullOrEmpty(soThe)) { TheDAL.XoaThe_TheoSoTK_LoaiThe(soTK, loaiThe); } else { TheDAL.XoaThe_TheoSoThe(soThe); } MessageBox.Show("Xóa thẻ " + soThe + " thành công!", "Thông báo", MessageBoxButtons.OK); if (tcrlQuanLyThe.SelectedIndex == 1) { TimKiem_TheoThongTin(); } else { TimKiem_TheoNgay(); } } catch { ErrorMessageDAL.DataAccessError(); } } }
/// <summary> This method is used for deleting a record by its primary key. /// <para>St4mpede guid:{F0137E62-1D45-4B92-A48E-05954850FFE8}</para> /// </summary> public void DeleteById( TheDAL.CommitScope context, System.Int32 customerId ) { const string Sql = @" Delete From Customer Where CustomerId = @customerId "; context.Connection.Execute( Sql, new { customerId = customerId }, context.Transaction, null, null); }
/// <summary> This method is used for deleting a record by its primary key. /// <para>St4mpede guid:{F0137E62-1D45-4B92-A48E-05954850FFE8}</para> /// </summary> public void DeleteById( TheDAL.CommitScope context, System.Int32 projectId ) { const string Sql = @" Delete From Project Where ProjectId = @projectId "; context.Connection.Execute( Sql, new { projectId = projectId }, context.Transaction, null, null); }
/// <summary> This method is used for getting a record but its Id/primary key. /// If nothing is found an exception is thrown. If you want to get null back use LoadById <see cref="LoadById"/> instead. /// <para>St4mpede guid:{71CF185E-0DD1-4FAE-9721-920B5C3C12D9}</para> /// </summary> public TheDAL.Poco.Project GetById( TheDAL.CommitScope context, System.Int32 projectId ) { const string Sql = @" Select * From Project Where ProjectId = @projectId "; var res = context.Connection.Query<TheDAL.Poco.Project>( Sql, new { projectId = projectId }, context.Transaction, false, null, null); return res.Single(); }
/// <summary> This method is used for getting a record but its Id/primary key. /// If nothing is found an exception is thrown. If you want to get null back use LoadById <see cref="LoadById"/> instead. /// <para>St4mpede guid:{71CF185E-0DD1-4FAE-9721-920B5C3C12D9}</para> /// </summary> public TheDAL.Poco.Customer GetById( TheDAL.CommitScope context, System.Int32 customerId ) { const string Sql = @" Select * From Customer Where CustomerId = @customerId "; var res = context.Connection.Query<TheDAL.Poco.Customer>( Sql, new { customerId = customerId }, context.Transaction, false, null, null); return res.Single(); }
/// <summary> This method is used for adding a new record in the database. /// <para>St4mpede guid:{759FBA46-A462-4E4A-BA2B-9B5AFDA572DE}</para> /// </summary> private TheDAL.Poco.Project Add( TheDAL.CommitScope context, TheDAL.Poco.Project project ) { const string Sql = @" Insert Into Project ( Name ) Values ( @Name ) Select * From Project Where ProjectId = Scope_Identity()"; var ret = context.Connection.Query<TheDAL.Poco.Project>( Sql, new { projectId = project.ProjectId }, context.Transaction, false, null, null); return ret.Single(); }
/// <summary> This method is used for adding a new record in the database. /// <para>St4mpede guid:{BC89740A-CBA5-4EDE-BFF4-9B0D8BA4058F}</para> /// </summary> private TheDAL.Poco.Project Add( TheDAL.CommitScope context, System.String name ) { return Add( context, new TheDAL.Poco.Project( 0, name )); }
/// <summary> This method is used for creating a new or updating an existing record in the database. /// If the primary key is default value (typically null or zero) we know it is a new record and try to add it. Otherwise we try to update the record. /// <para>St4mpede guid:{97D67E96-7C3E-4D8B-8984-104896646077}</para> /// </summary> public TheDAL.Poco.Project Upsert( TheDAL.CommitScope context, TheDAL.Poco.Project project ) { if(project.ProjectId == default(System.Int32)){ return Add(context, project); }else{ return Update(context, project); } }
/// <summary> This method is used for creating a new or updating an existing record in the database. /// If the primary key is 0 (zero) we know it is a new record and try to add it. Otherwise we try to update the record. /// <para>St4mpede guid:{A821E709-7333-4ABA-9F38-E85617C906FE}</para> /// </summary> public TheDAL.Poco.Project Upsert( TheDAL.CommitScope context, System.Int32 projectId, System.String name ) { return Upsert( context, new TheDAL.Poco.Project( projectId, name )); }
/// <summary> This method is used for updating an existing record in the database. /// <para>St4mpede guid:{5A4CE926-447C-4F3F-ADFC-8CA9229C60BF}</para> /// </summary> private TheDAL.Poco.User Update( TheDAL.CommitScope context, System.Int32 userId, System.String userName, System.String hashedPassword, System.DateTime lastLoggedOnDatetime ) { return Update( context, new TheDAL.Poco.User( userId, userName, hashedPassword, lastLoggedOnDatetime )); }
/// <summary> This method is used for adding a new record in the database. /// <para>St4mpede guid:{BC89740A-CBA5-4EDE-BFF4-9B0D8BA4058F}</para> /// </summary> private TheDAL.Poco.Customer Add( TheDAL.CommitScope context, System.String name ) { return Add( context, new TheDAL.Poco.Customer( 0, name )); }
/// <summary> This method is used for deleting a record. /// <para>St4mpede guid:{F74246AE-0295-4094-AA7F-1D118C11229D}</para> /// </summary> public void Delete( TheDAL.CommitScope context, TheDAL.Poco.Project project ) { DeleteById( context, project.ProjectId); }
/// <summary> This method is used for deleting a record. /// <para>St4mpede guid:{F74246AE-0295-4094-AA7F-1D118C11229D}</para> /// </summary> public void Delete( TheDAL.CommitScope context, TheDAL.Poco.Customer customer ) { DeleteById( context, customer.CustomerId); }
/// <summary> This method is used for adding a new record in the database. /// <para>St4mpede guid:{BC89740A-CBA5-4EDE-BFF4-9B0D8BA4058F}</para> /// </summary> private TheDAL.Poco.User Add( TheDAL.CommitScope context, System.String userName, System.String hashedPassword, System.DateTime lastLoggedOnDatetime ) { return Add( context, new TheDAL.Poco.User( 0, userName, hashedPassword, lastLoggedOnDatetime )); }
/// <summary> This method is used for updating an existing record in the database. /// <para>St4mpede guid:{B2B1B845-5F93-4A5C-9F90-FBA570228542}</para> /// </summary> private TheDAL.Poco.Customer Update( TheDAL.CommitScope context, TheDAL.Poco.Customer customer ) { const string Sql = @" Update Customer Set Name = @name Where CustomerId = @CustomerId Select * From Customer Where CustomerId = $customerId "; var ret = context.Connection.Query<TheDAL.Poco.Customer>( Sql, new { customerId = customer.CustomerId, name = customer.Name }, context.Transaction, false, null, null); return ret.Single(); }
/// <summary> This method is used for updating an existing record in the database. /// <para>St4mpede guid:{5A4CE926-447C-4F3F-ADFC-8CA9229C60BF}</para> /// </summary> private TheDAL.Poco.Customer Update( TheDAL.CommitScope context, System.Int32 customerId, System.String name ) { return Update( context, new TheDAL.Poco.Customer( customerId, name )); }
/// <summary> This method is used for adding a new record in the database. /// <para>St4mpede guid:{759FBA46-A462-4E4A-BA2B-9B5AFDA572DE}</para> /// </summary> private TheDAL.Poco.Customer Add( TheDAL.CommitScope context, TheDAL.Poco.Customer customer ) { const string Sql = @" Insert Into Customer ( Name ) Values ( @Name ) Select * From Customer Where CustomerId = Scope_Identity()"; var ret = context.Connection.Query<TheDAL.Poco.Customer>( Sql, new { customerId = customer.CustomerId }, context.Transaction, false, null, null); return ret.Single(); }
/// <summary> This method is used for updating an existing record in the database. /// <para>St4mpede guid:{5A4CE926-447C-4F3F-ADFC-8CA9229C60BF}</para> /// </summary> private TheDAL.Poco.Project Update( TheDAL.CommitScope context, System.Int32 projectId, System.String name ) { return Update( context, new TheDAL.Poco.Project( projectId, name )); }
/// <summary> This method is used for adding a new record in the database. /// <para>St4mpede guid:{759FBA46-A462-4E4A-BA2B-9B5AFDA572DE}</para> /// </summary> private TheDAL.Poco.User Add( TheDAL.CommitScope context, TheDAL.Poco.User user ) { const string Sql = @" Insert Into User ( UserName, HashedPassword, LastLoggedOnDatetime ) Values ( @UserName, @HashedPassword, @LastLoggedOnDatetime ) Select * From User Where UserId = Scope_Identity()"; var ret = context.Connection.Query<TheDAL.Poco.User>( Sql, new { userId = user.UserId }, context.Transaction, false, null, null); return ret.Single(); }
/// <summary> This method is used for updating an existing record in the database. /// <para>St4mpede guid:{B2B1B845-5F93-4A5C-9F90-FBA570228542}</para> /// </summary> private TheDAL.Poco.Project Update( TheDAL.CommitScope context, TheDAL.Poco.Project project ) { const string Sql = @" Update Project Set Name = @name Where ProjectId = @ProjectId Select * From Project Where ProjectId = $projectId "; var ret = context.Connection.Query<TheDAL.Poco.Project>( Sql, new { projectId = project.ProjectId, name = project.Name }, context.Transaction, false, null, null); return ret.Single(); }
/// <summary> This method is used for creating a new or updating an existing record in the database. /// If the primary key is 0 (zero) we know it is a new record and try to add it. Otherwise we try to update the record. /// <para>St4mpede guid:{A821E709-7333-4ABA-9F38-E85617C906FE}</para> /// </summary> public TheDAL.Poco.Customer Upsert( TheDAL.CommitScope context, System.Int32 customerId, System.String name ) { return Upsert( context, new TheDAL.Poco.Customer( customerId, name )); }
/// <summary> This method is used for deleting a record. /// <para>St4mpede guid:{F74246AE-0295-4094-AA7F-1D118C11229D}</para> /// </summary> public void Delete( TheDAL.CommitScope context, TheDAL.Poco.User user ) { DeleteById( context, user.UserId); }
/// <summary> This method is used for creating a new or updating an existing record in the database. /// If the primary key is default value (typically null or zero) we know it is a new record and try to add it. Otherwise we try to update the record. /// <para>St4mpede guid:{97D67E96-7C3E-4D8B-8984-104896646077}</para> /// </summary> public TheDAL.Poco.Customer Upsert( TheDAL.CommitScope context, TheDAL.Poco.Customer customer ) { if(customer.CustomerId == default(System.Int32)){ return Add(context, customer); }else{ return Update(context, customer); } }
/// <summary> This method is used for updating an existing record in the database. /// <para>St4mpede guid:{B2B1B845-5F93-4A5C-9F90-FBA570228542}</para> /// </summary> private TheDAL.Poco.User Update( TheDAL.CommitScope context, TheDAL.Poco.User user ) { const string Sql = @" Update User Set UserName = @userName, HashedPassword = @hashedPassword, LastLoggedOnDatetime = @lastLoggedOnDatetime Where UserId = @UserId Select * From User Where UserId = $userId "; var ret = context.Connection.Query<TheDAL.Poco.User>( Sql, new { userId = user.UserId, userName = user.UserName, hashedPassword = user.HashedPassword, lastLoggedOnDatetime = user.LastLoggedOnDatetime }, context.Transaction, false, null, null); return ret.Single(); }
/// <summary> This method is used for getting a record but its Id/primary key. /// If nothing is found an null is returned. If you want to throw an exception use GetById <see cref="GetById"> instead. /// <para>St4mpede guid:{BC171F29-81F2-41ED-AC5C-AD6884EC9718}</para> /// </summary> public TheDAL.Poco.User LoadById( TheDAL.CommitScope context, System.Int32 userId ) { const string Sql = @" Select * From User Where UserId = @userId "; var res = context.Connection.Query<TheDAL.Poco.User>( Sql, new { userId = userId }, context.Transaction, false, null, null); return res.SingleOrDefault(); }