private void SortDataFromExcelForStudent(object[] StudentInfo_ExcelRow) { Parent addedStudent = new Parent(); DAL Data = new DAL(); try { DateTime strSubmittedTime = (DateTime)StudentInfo_ExcelRow[0]; string strName = (string)StudentInfo_ExcelRow[1]; string strSurName = (string)StudentInfo_ExcelRow[2]; string strGuardianNumber = StudentInfo_ExcelRow[3].ToString(); string stringNumTrunks = (string)StudentInfo_ExcelRow[4]; string strStorageOption = (string)StudentInfo_ExcelRow[5]; string strPaymentMethod = (string)StudentInfo_ExcelRow[6]; string strHouse = (string)StudentInfo_ExcelRow[7]; string strNumber = StudentInfo_ExcelRow[8].ToString(); string strEmail = (string)StudentInfo_ExcelRow[9]; // sorted date time if (strSubmittedTime.Month <= 4) { DateTime SubmitedTime = new DateTime(strSubmittedTime.Year, 4, 1); addedStudent.StoragePeriod = SubmitedTime; } else if (strSubmittedTime.Month <= 8) { DateTime SubmitedTime = new DateTime(strSubmittedTime.Year, 8, 1); addedStudent.StoragePeriod = SubmitedTime; } else if (strSubmittedTime.Month <= 12) { DateTime SubmitedTime = new DateTime(strSubmittedTime.Year, 12, 1); addedStudent.StoragePeriod = SubmitedTime; } //Name check for & if (strName.Contains("&")) { strName = strName.Replace(" ", ""); int index = strName.IndexOf("&"); string FirtPerson = strName.Remove(index); string ExtraPerson = strName.Remove(0, index + 1); object[] NewPerson = { strSubmittedTime, ExtraPerson, strSurName, strGuardianNumber, stringNumTrunks, strStorageOption, strPaymentMethod, strHouse, strNumber, strEmail }; SortDataFromExcelForStudent(NewPerson); addedStudent.Name = FirtPerson; } else { addedStudent.Name = strName; } //Number of trunks stringNumTrunks = stringNumTrunks.Remove(1);// removing any excess information int NumTrunks = Convert.ToInt32(stringNumTrunks); //stroage option convertion strStorageOption = strStorageOption.ToLower(); if (strStorageOption.Contains("washing")) { StorageOption StorageOpt = StorageOption.StorageAndWashing; addedStudent.Option = StorageOpt; } else if (strStorageOption.Contains("only")) { StorageOption StorageOpt = StorageOption.Storage; addedStudent.Option = StorageOpt; } //payment Method strPaymentMethod = strPaymentMethod.ToLower(); if (strPaymentMethod.Contains("cash")) { MethodOfPayment PaymentMethod = MethodOfPayment.Cash; addedStudent.MethodOfPayment = PaymentMethod; } else if (strPaymentMethod.Contains("eco")) { MethodOfPayment PaymentMethod = MethodOfPayment.EcoCash; addedStudent.MethodOfPayment = PaymentMethod; } else if (strPaymentMethod.Contains("student")) { MethodOfPayment PaymentMethod = MethodOfPayment.StudentAccount; addedStudent.MethodOfPayment = PaymentMethod; } else if (strPaymentMethod.Contains("bank")) { MethodOfPayment PaymentMethod = MethodOfPayment.BankTransfer; addedStudent.MethodOfPayment = PaymentMethod; } //student house strHouse = strHouse.ToLower(); if (strHouse.Contains("founders")) { FalconCollegeHouse House = FalconCollegeHouse.Founders; addedStudent.House = House; } else if (strHouse.Contains("george")) { FalconCollegeHouse House = FalconCollegeHouse.GeorgeGrey; addedStudent.House = House; } else if (strHouse.Contains("hervey")) { FalconCollegeHouse House = FalconCollegeHouse.Hervey; addedStudent.House = House; } else if (strHouse.Contains("oates")) { FalconCollegeHouse House = FalconCollegeHouse.Oates; addedStudent.House = House; } else if (strHouse.Contains("tredgold")) { FalconCollegeHouse House = FalconCollegeHouse.Tredgold; addedStudent.House = House; } else if (strHouse.Contains("chubb")) { FalconCollegeHouse House = FalconCollegeHouse.Chubb; addedStudent.House = House; } addedStudent.Email = strEmail; addedStudent.Trunks = NumTrunks; addedStudent.Number = strNumber; addedStudent.GaurdianNumber = strGuardianNumber; addedStudent.Surname = strSurName; } catch (Exception ex) { string caption = "Error Adding Student"; MessageBoxButtons Button = MessageBoxButtons.OK; MessageBoxIcon icon = MessageBoxIcon.Error; MessageBox.Show(ex.Message, caption, Button, icon); } Data.QInsertStudent(addedStudent); }
public static Parent SortDataGridVeiwToParentClass(DataRow Row) { Parent ConStudent = new Bulawayo_Storage.Parent(); int strId = (int)Row.ItemArray[0]; string strName = (string)Row.ItemArray[1]; string strSurName = (string)Row.ItemArray[2]; string strHouse = (string)Row.ItemArray[3]; string strEmail = (string)Row.ItemArray[4]; string strNumber = (string)Row.ItemArray[5]; string strGuardianNumber = (string)Row.ItemArray[6]; int stringNumTrunks = (int)Row.ItemArray[7]; string strStorageOption = (string)Row.ItemArray[8]; string strPaymentMethod = (string)Row.ItemArray[9]; DateTime period = (DateTime)Row.ItemArray[10]; ConStudent.Id = strId; ConStudent.Name = strName; ConStudent.Surname = strSurName; strHouse = strHouse.ToLower(); if (strHouse.Contains("founders")) { FalconCollegeHouse House = FalconCollegeHouse.Founders; ConStudent.House = House; } else if (strHouse.Contains("george")) { FalconCollegeHouse House = FalconCollegeHouse.GeorgeGrey; ConStudent.House = House; } else if (strHouse.Contains("hervey")) { FalconCollegeHouse House = FalconCollegeHouse.Hervey; ConStudent.House = House; } else if (strHouse.Contains("oates")) { FalconCollegeHouse House = FalconCollegeHouse.Oates; ConStudent.House = House; } else if (strHouse.Contains("tredgold")) { FalconCollegeHouse House = FalconCollegeHouse.Tredgold; ConStudent.House = House; } else if (strHouse.Contains("chubb")) { FalconCollegeHouse House = FalconCollegeHouse.Chubb; ConStudent.House = House; } ConStudent.Email = strEmail; ConStudent.Number = strNumber; ConStudent.GaurdianNumber = strGuardianNumber; ConStudent.Trunks = stringNumTrunks; strStorageOption = strStorageOption.ToLower(); if (strStorageOption.Contains("washing")) { StorageOption StorageOpt = StorageOption.StorageAndWashing; ConStudent.Option = StorageOpt; } else if (strStorageOption.Contains("only")) { StorageOption StorageOpt = StorageOption.Storage; ConStudent.Option = StorageOpt; } strPaymentMethod = strPaymentMethod.ToLower(); if (strPaymentMethod.Contains("cash")) { MethodOfPayment PaymentMethod = MethodOfPayment.Cash; ConStudent.MethodOfPayment = PaymentMethod; } else if (strPaymentMethod.Contains("eco")) { MethodOfPayment PaymentMethod = MethodOfPayment.EcoCash; ConStudent.MethodOfPayment = PaymentMethod; } else if (strPaymentMethod.Contains("student")) { MethodOfPayment PaymentMethod = MethodOfPayment.StudentAccount; ConStudent.MethodOfPayment = PaymentMethod; } else if (strPaymentMethod.Contains("bank")) { MethodOfPayment PaymentMethod = MethodOfPayment.BankTransfer; ConStudent.MethodOfPayment = PaymentMethod; } ConStudent.StoragePeriod = period; return(ConStudent); }