public void GetOneEmail(Int32 EmailNo, bool IsArchive, out string EmailSubject, out string EmailContent) { if (IsArchive == true) { //instance of the database connection class clsDataConnection DB = new clsDataConnection(); //this adds the parameter ArchiveNo (masked as EmailNo for purposes of the retrieval DB.AddParameter("ArchiveNo", EmailNo); //this executes the stored procedure for the email address DB.Execute("sproc_tblArchive_GetEmail"); //this retrieves one email content and subject from the Table "tblEmailAddress", index only needs to be 0 EmailContent = DB.DataTable.Rows[0]["EmailContent"].ToString(); //this retrieves the email subject. EmailSubject = DB.DataTable.Rows[0]["EmailSubject"].ToString(); } else { //instance of the database connection class clsDataConnection DB = new clsDataConnection(); //this adds the parameter EmailNo DB.AddParameter("EmailNo", EmailNo); //this executes the stored procedure for the email address DB.Execute("sproc_tblEmail_GetEmail"); //this retrieves one email content and subject from the Table "tblEmailAddress", index only needs to be 0 EmailContent = DB.DataTable.Rows[0]["EmailContent"].ToString(); //this retrieves the email subject. EmailSubject = DB.DataTable.Rows[0]["EmailSubject"].ToString(); } }
//public constructor public clsEmailCollection() { //instance of the database connection class clsDataConnection DB = new clsDataConnection(); //exectue the stored procedure DB.Execute("sproc_tblEmail_SelectAll"); //get the count Int32 RecordCount = DB.Count; //set up index for the loop Int32 Index = 0; //while there are records to process while (Index < RecordCount) { //create a new instance of the email class clsEmail AEmail = new clsEmail(); //get the email subject AEmail.EmailSubject = DB.DataTable.Rows[Index]["EmailSubject"].ToString(); //get the primary key AEmail.EmailNo = Convert.ToInt32(DB.DataTable.Rows[Index]["EmailNo"]); //get the email Content AEmail.EmailContent = DB.DataTable.Rows[Index]["EmailContent"].ToString(); //get the email address recieving AEmail.EmailAddressNo = Convert.ToInt32(DB.DataTable.Rows[Index]["EmailAddressNo"]); //passess the EmailAddressNo to get the EmailAddress AEmail.EmailAddress = GetEmailAddress(AEmail.EmailAddressNo); //add the Email to the private data allEmails.Add(AEmail); //add to the index Index++; } }
public clsAppointmentCollection() { //var for the index Int32 Index = 0; //var to store the record count Int32 RecordCount = 0; //object for the data connection clsDataConnection DB = new clsDataConnection(); //execute the stored procedure DB.Execute("sproc_tblAppointment_SelectAll"); //get the count of records RecordCount = DB.Count; //while there are records to proccess while (Index < RecordCount) { //create a blank appointment clsAppointments AnAppointment = new clsAppointments(); // //read in the fields from the current record AnAppointment.AppointmentID = Convert.ToInt32(DB.DataTable.Rows[Index]["AppointmentID"]); AnAppointment.AppointmentLocation = Convert.ToString(DB.DataTable.Rows[Index]["AppointmentLocation"]); AnAppointment.AppointmentDate = Convert.ToDateTime(DB.DataTable.Rows[Index]["AppointmentDate"]); // //add the record to the private data member appointmentList.Add(AnAppointment); // //point at the next record Index++; } }
public clsProductCollection() { //var for the index Int32 Index = 0; //var to store the record count Int32 RecordCount = 0; //object for the data connection clsDataConnection DB = new clsDataConnection(); //execute the stored procedure DB.Execute("sproc_tblProduct_SelectAll"); //get the count of records RecordCount = DB.Count; //while there are records to proccess while (Index < RecordCount) { //create a blank customer clsProduct AProduct = new clsProduct(); // //read in the fields from the current record AProduct.ProductNo = Convert.ToInt32(DB.DataTable.Rows[Index]["ProductNo"]); AProduct.ProductName = Convert.ToString(DB.DataTable.Rows[Index]["ProductName"]); AProduct.ProductType = Convert.ToString(DB.DataTable.Rows[Index]["ProductType"]); AProduct.ProductDescription = Convert.ToString(DB.DataTable.Rows[Index]["ProductDescription"]); AProduct.ProductPrice = Convert.ToDecimal(DB.DataTable.Rows[Index]["ProductPrice"]); AProduct.ProductManufacturer = Convert.ToString(DB.DataTable.Rows[Index]["ProductManufacturer"]); AProduct.ProductsInStock = Convert.ToInt32(DB.DataTable.Rows[Index]["ProductsInStock"]); // //add the record to the private data member productList.Add(AProduct); // //point at the next record Index++; } }
public clsPaymentCollection() { //var for the index Int32 Index = 0; //var to store the record count Int32 RecordCount = 0; //object for the data connection clsDataConnection DB = new clsDataConnection(); //execute the stored procedure DB.Execute("sproc_tblPayment_SelectAll"); //get the count of records RecordCount = DB.Count; //while there are records to proccess while (Index < RecordCount) { //create a blank customer clsPayment APayment = new clsPayment(); // //read in the fields from the current record APayment.PaymentNo = Convert.ToInt32(DB.DataTable.Rows[Index]["PaymentNo"]); APayment.PaymentMethod = Convert.ToString(DB.DataTable.Rows[Index]["PaymentMethod"]); APayment.Amount = Convert.ToDecimal(DB.DataTable.Rows[Index]["Amount"]); APayment.Dateadded = Convert.ToDateTime(DB.DataTable.Rows[Index]["DateAdded"]); // //add the record to the private data member paymentList.Add(APayment); // //point at the next record Index++; } }
public bool Find(Int32 AppointmentID) { //create an instance of the data connection clsDataConnection DB = new clsDataConnection(); //add the parameter for the address no to search for DB.AddParameter("@AppointmentID", AppointmentID); //execute the stored procedure DB.Execute("sproc_tblAppointment_FilterByAppointmentID"); //if one record is found (there should either one or zero!) if (DB.Count == 1) { //copy the data from the database to the private data members appointmentID = Convert.ToInt32(DB.DataTable.Rows[0]["AppointmentID"]); appointmentLocation = Convert.ToString(DB.DataTable.Rows[0]["AppointmentLocation"]); appointmentDate = Convert.ToDateTime(DB.DataTable.Rows[0]["AppointmentDate"]); //return that everything worked OK return true; } //if no record was found else { //return false indicating a probelm return false; } }
public string SavedSearch (Int32 AgeFrom, Int32 AgeTo, string Location) { clsDataConnection DataConnection = new clsDataConnection(); DataConnection.AddParameter("AgeFrom", AgeFrom); DataConnection.AddParameter("AgeTo", AgeTo); DataConnection.AddParameter("Location", Location); DataConnection.Execute("sproc_tblCustomer_GetEmailAddressFromAgeAndLocation"); string EmailAddress = ""; ////get the count Int32 RecordCount = DataConnection.Count; Int32 Index = 0; while (Index < RecordCount) { EmailAddress += DataConnection.DataTable.Rows[Index]["EmailAddress"].ToString(); if (Index == RecordCount - 1) { EmailAddress += ""; } else { EmailAddress += ", "; } Index++; } return EmailAddress; }
public void AddNewSavedSearch(Int32 AgeMin, Int32 AgeMax, string Location) { clsDataConnection NewConn = new clsDataConnection(); NewConn.AddParameter("AgeFrom", AgeMin); NewConn.AddParameter("AgeTo", AgeMax); NewConn.AddParameter("Location", Location); NewConn.Execute("sproc_tblGroupList_AddNewGroupList"); }
public void RemoveItem(Int32 AgeFrom, Int32 AgeTo, string Location) { clsDataConnection DataConn = new clsDataConnection(); DataConn.AddParameter("AgeFrom", AgeFrom); DataConn.AddParameter("AgeTo", AgeTo); DataConn.AddParameter("Location", Location); DataConn.Execute("sproc_tblGroupList_RemoveGroupList"); }
public void Delete(int Staffid) { //deletes the recoed point ti by this staff //connect to the database clsDataConnection NewDBProducts = new clsDataConnection(); //set the paraters for the stored procedure NewDBProducts.AddParameter("@staffid", Staffid); //exectue the store procedure NewDBProducts.Execute("sproc_tblStaff_Delete"); }
public string GetEmailAddress(Int32 EmailAddressNo) { //instance of the database connection class clsDataConnection DB = new clsDataConnection(); //this adds the parameter EmailAddressNo DB.AddParameter("EmailNo", EmailAddressNo); //this executes the stored procedure for the email address DB.Execute("sproc_tblEmailAddress_GetEmailAddress"); //this retrieves one email address from the Table "tblEmailAddress", index only needs to be 0 string EmailAddress = DB.DataTable.Rows[0]["EmailAddress"].ToString(); //this returns the output return EmailAddress; }
//Add Stafff Information public int AddStaff(clsStaff staffModel) { dBConnection = new clsDataConnection(); //execute dBConnection.AddParameter("@Name", staffModel.Staffname); dBConnection.AddParameter("@Age", staffModel.Age); dBConnection.AddParameter("@Brief", staffModel.Brief); dBConnection.AddParameter("@Gender", staffModel.Gender); dBConnection.AddParameter("@Mobilesphone", staffModel.Mobilesphone); dBConnection.AddParameter("@workage", staffModel.Workage); dBConnection.AddParameter("@positiob", staffModel.Position); return dBConnection.Execute("sproc_Staff_Insert"); }
public Int32 AddStaff() { clsDataConnection NewDBProducts = new clsDataConnection(); //add the parameters // NewDBProduct.AddParameter("@ProductNo", ThisProduct.ProductNo); dBConnection.AddParameter("@Name", ThisStaff.Staffname); dBConnection.AddParameter("@Age", ThisStaff.Age); dBConnection.AddParameter("@Brief", ThisStaff.Brief); dBConnection.AddParameter("@Gender", ThisStaff.Gender); dBConnection.AddParameter("@Mobilesphone", ThisStaff.Mobilesphone); dBConnection.AddParameter("@workage", ThisStaff.Workage); dBConnection.AddParameter("@positiob", ThisStaff.Position); return dBConnection.Execute("sproc_Staff_Insert"); }
public void Update() { //update the recoed point ti by this staff //connect to the database clsDataConnection NewDBProducts = new clsDataConnection(); //set the paraters for the stored procedure dBConnection.AddParameter("@staffid", ThisStaff.Staffid); dBConnection.AddParameter("@Name", ThisStaff.Staffname); dBConnection.AddParameter("@Age", ThisStaff.Age); dBConnection.AddParameter("@Brief", ThisStaff.Brief); dBConnection.AddParameter("@Gender", ThisStaff.Gender); dBConnection.AddParameter("@Mobilesphone", ThisStaff.Mobilesphone); dBConnection.AddParameter("@workage", ThisStaff.Workage); dBConnection.AddParameter("@positiob", ThisStaff.Position); //exectue the store procedure NewDBProducts.Execute("sproc_tblStaff_Update"); }
//public void FindAllStockItems() public clsStockCollection() { //re-set the connection clsDataConnection myDB = new clsDataConnection(); //execute the stored procedure myDB.Execute("sproc_tblStockItem_SelectAll"); //get the count of records Int32 recordCount = myDB.Count; //var to store the index Int32 Index = 0; //while there are still records to process while (Index < myDB.Count) ////var to store the user number of the current record //Int32 StockNo; ////var to flag that user was found //Boolean StockFound; { //create an instance of the stock item class clsStockItem AStockItem = new clsStockItem(); //get the stock name AStockItem.StockName = myDB.DataTable.Rows[Index]["StockName"].ToString(); //get the primary key AStockItem.StockNo = Convert.ToInt32(myDB.DataTable.Rows[Index]["StockNo"]); //increment the index Index++; ////get the user number from the database //StockNo = Convert.ToInt32(myDB.DataTable.Rows[Index]["StockNo"]); ////find the user by invoking the find method //StockFound = NewItem.Find(StockNo); //if (StockFound == true) //{ // //add the user to the list allStock.Add(AStockItem); //} } }
//public constructor for the class //this constructor is a function that runs when class is created public clsServiceOrderCollection() { //create instance of data connection class clsDataConnection DB = new clsDataConnection(); //execute stored procedure to get list of data DB.Execute("sproc_tblServiceOrder_SelectAll"); //get count of records Int32 RecordCount = DB.Count; //Set up index for the loop Int32 Index = 0; //while there are records to process while (Index < RecordCount) { //create instance of Service Order class clsServiceOrder AnOrder = new clsServiceOrder(); //get service AnOrder.Service = DB.DataTable.Rows[Index]["Service"].ToString(); //get primary key AnOrder.OrderNo = Convert.ToInt32(DB.DataTable.Rows[Index]["OrderNo"]); //increment the index Index++; /* //create instance of order class to store an order clsServiceOrder AnOrder = new clsServiceOrder(); //set service to 'Antivirus' AnOrder.Service = "Antivirus"; //add the order to the private list of orders allOrders.Add(AnOrder); //re-initialise the AnOrder object to accept a new item AnOrder = new clsServiceOrder(); //set the new service to 'Memory' AnOrder.Service = "Memory"; //add second service to private list of orders allOrders.Add(AnOrder); //the private list now contains two orders*/ } }
public clsCustomerCollection() { //var for the index Int32 Index = 0; //var to store the record count Int32 RecordCount = 0; //object for the data connection clsDataConnection DB = new clsDataConnection(); //execute the stored procedure DB.Execute("sproc_tblCustomer_SelectAll"); //get the count of records RecordCount = DB.Count; //while there are records to proccess while (Index < RecordCount) { //create a blank customer clsCustomer ACustomer = new clsCustomer(); //read in the fields from the current record ACustomer.CustomerNo = Convert.ToInt32(DB.DataTable.Rows[Index]["CustomerNo"]); ACustomer.FirstName = Convert.ToString(DB.DataTable.Rows[Index]["FirstName"]); ACustomer.LastName = Convert.ToString(DB.DataTable.Rows[Index]["LastName"]); ACustomer.AddressLine1 = Convert.ToString(DB.DataTable.Rows[Index]["AddressLine1"]); ACustomer.AddressLine2 = Convert.ToString(DB.DataTable.Rows[Index]["AddressLine2"]); ACustomer.Town = Convert.ToString(DB.DataTable.Rows[Index]["Town/City"]); ACustomer.PostCode = Convert.ToString(DB.DataTable.Rows[Index]["PostCode"]); ACustomer.EmailAddress = Convert.ToString(DB.DataTable.Rows[Index]["EmailAddress"]); ACustomer.UserName = Convert.ToString(DB.DataTable.Rows[Index]["UserName"]); ACustomer.Password = Convert.ToString(DB.DataTable.Rows[Index]["Password"]); ACustomer.PhoneNo = Convert.ToString(DB.DataTable.Rows[Index]["PhoneNo"]); //add the record to the private data member customerList.Add(ACustomer); //point at the next record Index++; } }
public List<clsStaff> clsStaffListCollection() { //var for the index Int32 Index = 0; //var to store the record count Int32 RecordCount = 0; //object for the data connection List<clsStaff> StaffList = new List<clsStaff>(); clsDataConnection DB = new clsDataConnection(); //execute the stored procedure DB.Execute("sproc_tblStaff_SelectAll"); //get the count of records RecordCount = DB.Count; //while there are records to proccess while (Index < RecordCount) { clsStaff StaffOne = new clsStaff(); StaffOne.Staffid = Convert.ToInt32(DB.DataTable.Rows[Index]["staffid"]); StaffOne.Staffname = Convert.ToString(DB.DataTable.Rows[Index]["Name"]); StaffOne.Age = Convert.ToInt32(DB.DataTable.Rows[Index]["age"]); StaffOne.Brief = Convert.ToString(DB.DataTable.Rows[Index]["brief"]); StaffOne.Gender = Convert.ToString(DB.DataTable.Rows[Index]["gender"]); StaffOne.Mobilesphone = Convert.ToString(DB.DataTable.Rows[Index]["mobilesphone"]); StaffOne.Workage = Convert.ToInt32(DB.DataTable.Rows[Index]["workage"]); StaffOne.Position = Convert.ToString(DB.DataTable.Rows[Index]["position"]); StaffList.Add(StaffOne); // //point at the next record Index++; } return StaffList; }
public clsStaff Find(Int32 Staffid) { //initialise the DBConnection clsDataConnection dBConnection = new clsDataConnection(); //add the Product No parameter dBConnection.AddParameter("@Staffid", Staffid); //execute the query dBConnection.Execute("sproc_tblStaff_FilterByStaffid"); //if the record was found clsStaff clstaffs = new clsStaff(); if (dBConnection.Count == 1) { //get the Product No clstaffs.Staffid = Convert.ToInt32(dBConnection.DataTable.Rows[0]["Staffid"]); clstaffs.Staffname = Convert.ToString(dBConnection.DataTable.Rows[0]["Staffname"]); clstaffs.Age = Convert.ToInt32(dBConnection.DataTable.Rows[0]["Age"]); clstaffs.Brief = Convert.ToString(dBConnection.DataTable.Rows[0]["Brief"]); clstaffs.Gender = Convert.ToString(dBConnection.DataTable.Rows[0]["Gender"]); clstaffs.Mobilesphone = Convert.ToString(dBConnection.DataTable.Rows[0]["Mobilesphone"]); clstaffs.Workage = Convert.ToInt32(dBConnection.DataTable.Rows[0]["Workage"]); clstaffs.Position = Convert.ToString(dBConnection.DataTable.Rows[0]["Position"]); } //return success return clstaffs; }
//construtor for the class public clsStockCollection() { { //object for the data connection clsDataConnection DB = new clsDataConnection(); //execute the stored procedure DB.Execute("sproc_tblStock_SelectAll"); PopulateArray(DB); } //{ // //var for the indec // Int32 Index = 0; // //var to store the record count // Int32 RecordCount = 0; // //object for the data connection // clsDataConnection DB = new clsDataConnection(); // //execute the stored procedure // DB.Execute("sproc_tblStock_SelectAll"); // //get the count of records // RecordCount = DB.Count; // //while there are records to process // while (Index < RecordCount) // { // //create a blank address // clsStock AStock = new clsStock(); // //read inthe fiueld of the current record // AStock.ModelNo = Convert.ToInt32(DB.DataTable.Rows[Index]["ModelNo"]); // AStock.CarModel = Convert.ToString(DB.DataTable.Rows[Index]["CarModel"]); // AStock.BHP = Convert.ToString(DB.DataTable.Rows[Index]["BHP"]); // AStock.Price = Convert.ToInt32(DB.DataTable.Rows[Index]["Price"]); // AStock.DateAdded = Convert.ToDateTime(DB.DataTable.Rows[Index]["DateAdded"]); // AStock.Availability = Convert.ToBoolean(DB.DataTable.Rows[Index]["Availability"]); // //add the record to the private data member // mStockList.Add(AStock); // //point at the next record // Index++; // } // //create the item of test data // clsStock TestItem = new clsStock(); // //set its properties // TestItem.Availability = true; // TestItem.ModelNo = 1; // TestItem.CarModel = "Mercedes A Class"; // TestItem.BHP = "120 BHP"; // TestItem.Price = 1; // TestItem.DateAdded = DateTime.Now.Date; // //add the item to the test list // mStockList.Add(TestItem); // //resinitiadkoasdosmad // TestItem = new clsStock(); // //set its properties // TestItem.Availability = true; // TestItem.ModelNo = 2; // TestItem.CarModel = "Mercedes A45 AMG"; // TestItem.BHP = "290 BHP"; // TestItem.Price = 2; // TestItem.DateAdded = DateTime.Now.Date; // //add the item to the test list // mStockList.Add(TestItem); //} }
public bool Find(Int32 CustomerNo) { //create an instance of the data connection clsDataConnection DB = new clsDataConnection(); //add the parameter for the customer no to search for DB.AddParameter("@CustomerNo", CustomerNo); //Execute the stored Procedure DB.Execute("sproc_tblCustomer_FilterByCustomerNo"); //if one record is found (there should be one or zero!) if (DB.Count == 1) { //set the private data member to the test data value customerNo = Convert.ToInt32(DB.DataTable.Rows[0]["CustomerNo"]); firstName = Convert.ToString(DB.DataTable.Rows[0]["FirstName"]); lastName = Convert.ToString(DB.DataTable.Rows[0]["LastName"]); password = Convert.ToString(DB.DataTable.Rows[0]["Password"]); phoneNo = Convert.ToString(DB.DataTable.Rows[0]["PhoneNo"]); emailAddress = Convert.ToString(DB.DataTable.Rows[0]["EmailAddress"]); addressLine1 = Convert.ToString(DB.DataTable.Rows[0]["AddressLine1"]); addressLine2 = Convert.ToString(DB.DataTable.Rows[0]["AddressLine2"]); postCode = Convert.ToString(DB.DataTable.Rows[0]["PostCode"]); town = Convert.ToString(DB.DataTable.Rows[0]["Town/City"]); userName = Convert.ToString(DB.DataTable.Rows[0]["UserName"]); //return that everything worked ok return true; } //if no record was found else { //return false indicating a problem return false; } }
public int Add() { //adds a new record to the database based on the values of thisStockItem //connect to the database clsDataConnection DB = new clsDataConnection(); //set the parameters for the stored procedure //DB.AddParameter("@StockNo", thisStockItem.StockNo); DB.AddParameter("@ItemPrice", thisStockItem.ItemPrice); DB.AddParameter("@StockLevel", thisStockItem.StockLevel); DB.AddParameter("@StockItemDescription", thisStockItem.StockItemDescription); DB.AddParameter("@StockName", thisStockItem.StockName); DB.AddParameter("@SupplierName", thisStockItem.SupplierName); //execute the query returning the primary key value return DB.Execute("sproc_tblStockItem_Insert"); }
public void UpdateEmails() { using (ImapClient client = new ImapClient("imap.gmail.com", 993, "*****@*****.**", "DeMonfortUniversity2015", AuthMethod.Auto, true)) { int EmailAddressNo = 0; var uids = client.Search(SearchCondition.All()); var messages = client.GetMessages(uids); foreach (var mail in messages) { //set up the data connection clsDataConnection DB = new clsDataConnection(); DB.AddParameter("EmailContent", mail.Body); DB.Execute("sproc_tblEmail_CheckIfExists"); DB.Execute("sproc_tblArchive_CheckIfExists"); //Int32 Result = Convert.ToInt32(DB.DataTable.Rows[0]["EmailNo"]); if (DB.DataTable.Rows.Count == 0) { clsDataConnection DB5 = new clsDataConnection(); string from = Convert.ToString(mail.From); //this uses substrings to extract the data we need from the email string output = from.Substring(from.IndexOf("<") + 1, from.IndexOf(">") - from.IndexOf("<") - 1); DB5.AddParameter("EmailAddress", output); DB5.Execute("sproc_tblEmail_CheckEmailAddress"); if (DB.DataTable.Rows.Count == 0) { clsDataConnection DB3 = new clsDataConnection(); DB3.AddParameter("EmailAddress", output); DB3.Execute("sproc_tblEmailAddress_InsertNewEmailAddress"); } clsDataConnection DB4 = new clsDataConnection(); DB4.AddParameter("EmailAddress", output); DB4.Execute("sproc_tblEmail_CheckEmailAddress"); EmailAddressNo = Convert.ToInt32(DB4.DataTable.Rows[0]["EmailAddressNo"]); //new data connection for new parameters clsDataConnection DB2 = new clsDataConnection(); var header = mail.Headers["Subject"]; string body = mail.Body; DB2.AddParameter("EmailSubject", header); DB2.AddParameter("EmailContent", body); DB2.AddParameter("EmailAddressNo", EmailAddressNo); DB2.Execute("sproc_tblEmail_InsertNewEmail"); } } } }
private void btnArchiveEmail_Click(object sender, EventArgs e) { //try //{ clsDataConnection Connection = new clsDataConnection(); Connection.AddParameter("EmailNo", EmailNo); Connection.Execute("sproc_tblEmailAndArchive_PutEmailInArchive"); MessageBox.Show("Successful transfer!"); //} //catch //{ // MessageBox.Show("Sorry there was an error, please try again."); //} }
public int Add() { clsDataConnection DB = new clsDataConnection(); DB.AddParameter("@FirstName", thisCustomer.FirstName); DB.AddParameter("@LastName", thisCustomer.LastName); DB.AddParameter("@AddressLine1", thisCustomer.AddressLine1); DB.AddParameter("@AddressLine2", thisCustomer.AddressLine2); DB.AddParameter("@Town", thisCustomer.Town); DB.AddParameter("@PostCode", thisCustomer.PostCode); DB.AddParameter("@PhoneNo", thisCustomer.PhoneNo); DB.AddParameter("@EmailAddress", thisCustomer.EmailAddress); DB.AddParameter("@UserName", thisCustomer.UserName); DB.AddParameter("@Password", thisCustomer.Password); //execute the query returning the primary key value return DB.Execute("sproc_tblCustomer_Insert"); }
public bool Find(Int32 PaymentNo) { //create an instance of the data connection clsDataConnection DB = new clsDataConnection(); //add the paramter for the payemntno to search for DB.AddParameter("@PaymentNo", PaymentNo); //excute the stored procedure DB.Execute("sproc_tblPayment_FilterByPaymentNo"); //if one record is found( there should be either one or zero!) if (DB.Count == 1) { //copy the data from the databse to the private data members paymentNo = Convert.ToInt32(DB.DataTable.Rows[0]["PaymentNo"]); amount = Convert.ToDecimal(DB.DataTable.Rows[0]["Amount"]); paymentMethod = Convert.ToString(DB.DataTable.Rows[0]["PaymentMethod"]); dateAdded = Convert.ToDateTime(DB.DataTable.Rows[0]["DateAdded"]); //return that everthing worked Ok return true; } //if no record was found else { //return false indicating a problem return false; } }
public bool Find(Int32 ProductNo) { //create an instance of the data connection clsDataConnection DB = new clsDataConnection(); //add the parameter for the address no to search for DB.AddParameter("@ProductNo", ProductNo); //execute the stored procedure DB.Execute("sproc_tblProduct_FilterByProductNo"); //if one record is found (there should either one or zero!) if (DB.Count == 1) { //copy the data from the database to the private data members productNo = Convert.ToInt32(DB.DataTable.Rows[0]["ProductNo"]); productName = Convert.ToString(DB.DataTable.Rows[0]["ProductName"]); productType = Convert.ToString(DB.DataTable.Rows[0]["ProductType"]); productDescription = Convert.ToString(DB.DataTable.Rows[0]["ProductDescription"]); productPrice = Convert.ToDecimal(DB.DataTable.Rows[0]["ProductPrice"]); productManufacturer = Convert.ToString(DB.DataTable.Rows[0]["ProductManufacturer"]); productsInStock = Convert.ToInt32(DB.DataTable.Rows[0]["ProductsInStock"]); //return that everything worked OK return true; } //if no record was found else { //return false indicating a probelm return false; } }
//public bool Active //{ // get //{ // //return the private data // return active; // } // set // { // //set the private data // active = value; // } //} //public int StockNo { get; set; } public bool Find(int StockNo) { //creat an instanc of the data connection clsDataConnection DB = new clsDataConnection(); //add the parameter for the stock code to search for DB.AddParameter("@StockNo", StockNo); //execute the stored procedure DB.Execute("sproc_tblStockItem_FilterByStockNo"); //if one record is found if(DB.Count==1) { //copy the data from the databas to the private data member stockCode = Convert.ToInt32(DB.DataTable.Rows[0]["StockNo"]); itemPrice = Convert.ToDecimal(DB.DataTable.Rows[0]["ItemPrice"]); stockLevel=Convert.ToInt32(DB.DataTable.Rows[0]["StockLevel"]); stockItemDescription=Convert.ToString(DB.DataTable.Rows[0]["StockItemDescription"]); stockName = Convert.ToString(DB.DataTable.Rows[0]["StockName"]); supplierName = Convert.ToString(DB.DataTable.Rows[0]["SupplierName"]); //dateAdded = Convert.ToDateTime(DB.DataTable.Rows[0]["DateAdded"]); //active = Convert.ToBoolean(DB.DataTable.Rows[0]["Active"]); //return that everything worked OK return true; } //if no record was found else { //return false indicating a problem return false; } }
private void btnRestoreEmail_Click(object sender, EventArgs e) { //try //{ clsDataConnection NewConnection = new clsDataConnection(); NewConnection.AddParameter("ArchiveNo", ArchiveNo); NewConnection.Execute("sproc_tblEmailAndArchive_PutArchiveBackInEmail"); MessageBox.Show("Successful Transfer!"); this.Refresh(); //} //catch //{ // MessageBox.Show("Unfortunately there was an error. Please try again."); //} }
private void FrmEmailClient_Load(object sender, EventArgs e) { try { //clear the listbox LstBxSavedSearch.Items.Clear(); //initalise the data connection clsDataConnection DataConn = new clsDataConnection(); //add the sproc DataConn.Execute("sproc_tblGroupList_GetAllGroupList"); //get the count of records Int32 RecordCount = DataConn.Count; //set up the index Int32 Index = 0; //create a new list List<string> NewList = new List<string>(); //this runs whilst index is lower than record count while (Index < RecordCount) { string zz = "Age(s) "; zz += DataConn.DataTable.Rows[Index]["AgeFrom"].ToString(); zz += "-"; zz += DataConn.DataTable.Rows[Index]["AgeTo"].ToString(); zz += " Location "; zz += DataConn.DataTable.Rows[Index]["Location"].ToString(); GroupListNo.Add(Convert.ToInt32(DataConn.DataTable.Rows[Index]["GroupListNo"])); NewList.Add(zz); Index++; } LstBxSavedSearch.DataSource = NewList; } catch { MessageBox.Show("Group List Retreival failed, please try again"); } }