public void Delete(int id) { if (Convert.ToInt32(id) <= 0) { throw new Exception("ID is required."); } try { SQLConnector.OpenConnection(); SQLConnector.BeginTransaction(); string sql = string.Format("DELETE FROM Vendor WHERE ID ={0}", id); SqlCommand command = new SqlCommand(); command.Connection = SQLConnector.Connection; command.Transaction = SQLConnector.Transaction; command.CommandText = sql; command.CommandType = System.Data.CommandType.Text; command.ExecuteNonQuery(); SQLConnector.CommitTransaction(); SQLConnector.CloseConnection(); } catch (Exception exp) { SQLConnector.RollbackTransaction(); throw exp; } }
public void Save() { if (this.Code.Length == 0) { throw new Exception("Code is required"); } if (Global.IsExists("Vendor", "ID", "Code", this.ID, this.Code)) { throw new Exception("Your entered Code is already exists here. Please enter your valid Code."); } if (_email.Length == 0) { throw new Exception("Email is required"); } if (_userName.Length == 0) { throw new Exception("UserName is required"); } try { SQLConnector.OpenConnection(); SQLConnector.BeginTransaction(); string sql = string.Empty; if (_isNew) { _id = Global.GenerateMaxNumber("Vendor", "ID"); sql = string.Format("INSERT INTO Vendor(ID,UserName,Code,Address,Email,ContactNo,BankName,AccountNo,PaymentTerm,EntryUserId,UpdateUserId,UpdateDate,isActive) VALUES({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}',{8},'{9}','{10}','{11}',{12})", _id, _userName, _code, _address, _email, _contactNo, _bankName, _accountNo, _paymentTerm, _entryuserId, _updateuserId, _updateDate, Convert.ToInt32(_isActive)); } else { sql = string.Format("UPDATE Vendor SET UserName = '******', Code='{1}',Address = '{2}', Email= '{3}', ContactNo= '{4}',BankName = '{5}',AccountNo = '{6}',PaymentTerm = {7},EntryUserId = '{8}',UpdateUserId = '{9}',UpdateDate = '{10}',IsActive = {11} WHERE ID = {12} ", _userName, _code, _address, _email, _contactNo, _bankName, _accountNo, _paymentTerm, _entryuserId, _updateuserId, _updateDate, Convert.ToInt32(_isActive), _id); } SqlCommand command = new SqlCommand(); command.Connection = SQLConnector.Connection; command.Transaction = SQLConnector.Transaction; command.CommandText = sql; command.CommandType = System.Data.CommandType.Text; command.ExecuteNonQuery(); SQLConnector.CommitTransaction(); SQLConnector.CloseConnection(); } catch (Exception exp) { SQLConnector.RollbackTransaction(); throw exp; } }
public void Save() { if (this.UserName.Length == 0) { throw new Exception("UserName is required"); } if (Global.IsExists("Report", "ID", "UserName", this.ID, this.UserName)) { throw new Exception("Your entered UserName is already exists here. Please enter your valid UserName."); } if (_invoiceReference.Length == 0) { throw new Exception("Invoice Reference is required"); } if (_omniflowReference.Length == 0) { throw new Exception("Omniflow Reference is required"); } try { SQLConnector.OpenConnection(); SQLConnector.BeginTransaction(); string sql = string.Empty; if (_isNew) { _id = Global.GenerateMaxNumber("Report", "ID"); sql = string.Format("INSERT INTO Report(ID,Code,UserName,InvoiceReference,InvoiceDate,POReference,InvoiceValue,OmniflowReference,ReceiveDate,PaymentTerm,PaymentdueDate,PaymentDate,PaidAmount,TaxDeduction,VatDeduction,Status) VALUES({0},'{1}','{2}',{3},'{4}','{5}',{6},{7},'{8}',{9},'{10}','{11}','{12}','{13}','{14}','{15}')", _id, _code, _userName, _invoiceReference, _invoiceDate, _poReference, _invoiceValue, _omniflowReference, _receiveDate, _paymentTerm, _paymentdueDate, _paymentDate, _paidAmount, _taxDeduction, _vatDeduction, _status); } else { sql = string.Format("UPDATE Report SET Code ='{0}',UserName='******',InvoiceReference = '{2}',InvoiceDate = '{3}',POReference = '{4}',InvoiceValue = {5},OmniflowReference = '{6}',ReceiveDate = '{7}',PaymentTerm = {8},PaymentdueDate = '{9}',PaymentDate = '{10}',PaidAmount = '{11}',TaxDeduction = '{12}',VatDeduction = '{13}' ,Status = '{14}' WHERE ID = {15} ", _code, _userName, _invoiceReference, _invoiceDate, _poReference, _invoiceValue, _omniflowReference, _receiveDate, _paymentTerm, _paymentdueDate, _paymentDate, _paidAmount, _taxDeduction, _vatDeduction, _status, _id); } SqlCommand command = new SqlCommand(); command.Connection = SQLConnector.Connection; command.Transaction = SQLConnector.Transaction; command.CommandText = sql; command.CommandType = System.Data.CommandType.Text; command.ExecuteNonQuery(); SQLConnector.CommitTransaction(); SQLConnector.CloseConnection(); } catch (Exception exp) { SQLConnector.RollbackTransaction(); throw exp; } }
public void Save() { if (this.UserName.Length == 0) { throw new Exception("User Name is required"); } if (Global.IsExists("[User]", "ID", "UserName", this.ID, this.UserName)) { throw new Exception("Your entered User ID or Password is wrong. Please enter your valid User ID or Password."); } if (_password.Length == 0) { throw new Exception("Password is required"); } try { SQLConnector.OpenConnection(); SQLConnector.BeginTransaction(); string sql = string.Empty; if (_isNew) { _id = Global.GenerateMaxNumber("[User]", "ID"); sql = string.Format("INSERT INTO [User](ID,UserName,UserID,Password,IsAdmin,IsOperator) VALUES({0},'{1}','{2}','{3}',{4},{5})", _id, _userName, _userID, _password, Convert.ToInt32(_isAdmin), Convert.ToInt32(_isOperator)); } else { sql = string.Format("UPDATE [User] SET UserName = '******', UserID = '{1}', Password = '******', IsAdmin = {3}, IsOperator = {4} WHERE ID = {5} ", _userName, _userID, _password, Convert.ToInt32(_isAdmin), Convert.ToInt32(_isOperator), _id); } SqlCommand command = new SqlCommand(); command.Connection = SQLConnector.Connection; command.Transaction = SQLConnector.Transaction; command.CommandText = sql; command.CommandType = System.Data.CommandType.Text; command.ExecuteNonQuery(); SQLConnector.CommitTransaction(); SQLConnector.CloseConnection(); } catch (Exception exp) { SQLConnector.RollbackTransaction(); throw exp; } }
public void Save() { if (this.Code.Length == 0) { throw new Exception("Code is required"); } if (Global.IsExists("Holiday", "ID", "Code", this.ID, this.Code)) { throw new Exception("Your entered Code is already exists here. Please enter your valid Code."); } if (_description.Length == 0) { throw new Exception("Description is required"); } try { SQLConnector.OpenConnection(); SQLConnector.BeginTransaction(); string sql = string.Empty; if (_isNew) { _id = Global.GenerateMaxNumber("Holiday", "ID"); sql = string.Format("INSERT INTO Holiday(ID,Code,Description,FromDate,ToDate) VALUES({0},'{1}','{2}','{3}','{4}')", _id, _code, _description, _FromDate, _ToDate); } else { sql = string.Format("UPDATE Holiday SET Code = '{0}', Description = '{1}', FromDate = '{2}', ToDate = '{3}' WHERE ID = {4} ", _code, _description, _FromDate, _ToDate, _id); } SqlCommand command = new SqlCommand(); command.Connection = SQLConnector.Connection; command.Transaction = SQLConnector.Transaction; command.CommandText = sql; command.CommandType = System.Data.CommandType.Text; command.ExecuteNonQuery(); SQLConnector.CommitTransaction(); SQLConnector.CloseConnection(); } catch (Exception exp) { SQLConnector.RollbackTransaction(); throw exp; } }
public void Save() { if (this.Description.Length == 0) { throw new Exception("Description is required"); } if (Global.IsExists("Document", "ID", "Description", this.ID, this.Description)) { throw new Exception("Your entered Description is already exists here. Please enter your valid Description."); } try { SQLConnector.OpenConnection(); SQLConnector.BeginTransaction(); string sql = string.Empty; if (_isNew) { _id = Global.GenerateMaxNumber("Document", "ID"); sql = string.Format("INSERT INTO Document(ID,Description,isMendatory) VALUES({0},'{1}',{2})", _id, _description, Convert.ToInt32(_isMendatory)); } else { sql = string.Format("UPDATE Document SET Description = '{0}', IsMendatory = {1} WHERE ID = {2} ", _description, Convert.ToInt32(_isMendatory), _id); } SqlCommand command = new SqlCommand(); command.Connection = SQLConnector.Connection; command.Transaction = SQLConnector.Transaction; command.CommandText = sql; command.CommandType = System.Data.CommandType.Text; command.ExecuteNonQuery(); SQLConnector.CommitTransaction(); SQLConnector.CloseConnection(); } catch (Exception exp) { SQLConnector.RollbackTransaction(); throw exp; } }