private static VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCollection ConvertDataTableToCollection(DataTable dt) { try { VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCollection vehicleClasses = new VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCollection(); for (int i = 0; i < dt.Rows.Count; i++) { VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCBE vehicleClass = new VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCBE(); if (dt.Rows[i]["TMS_ID"] != DBNull.Value) { vehicleClass.TMSId = Convert.ToInt32(dt.Rows[i]["TMS_ID"]); } if (dt.Rows[i]["VEHICLE_CLASS_ID"] != DBNull.Value) { vehicleClass.Id = Convert.ToInt32(dt.Rows[i]["VEHICLE_CLASS_ID"]); } if (dt.Rows[i]["VEHICLE_CLASS_NAME"] != DBNull.Value) { vehicleClass.Name = Convert.ToString(dt.Rows[i]["VEHICLE_CLASS_NAME"]); } if (dt.Rows[i]["MODIFIED_BY"] != DBNull.Value) { vehicleClass.ModifierId = Convert.ToInt32(dt.Rows[i]["MODIFIED_BY"]); } if (dt.Rows[i]["CREATION_DATE"] != DBNull.Value) { vehicleClass.CreationDate = Convert.ToDateTime(dt.Rows[i]["CREATION_DATE"]); } if (dt.Rows[i]["MODIFICATION_DATE"] != DBNull.Value) { vehicleClass.ModificationDate = Convert.ToDateTime(dt.Rows[i]["MODIFICATION_DATE"]); } if (dt.Rows[i]["TRANSFER_STATUS"] != DBNull.Value) { vehicleClass.TransferStatus = Convert.ToInt32(dt.Rows[i]["TRANSFER_STATUS"]); } vehicleClasses.Add(vehicleClass); } return(vehicleClasses); } catch (Exception ex) { throw ex; } }
private static List <VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCBE> ConvertDataTableToList(DataTable dt) { VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCollection vehicleClasses = ConvertDataTableToCollection(dt); List <VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCBE> vehicleClassList = new List <VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCBE>(); foreach (VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCBE vc in vehicleClasses) { vehicleClassList.Add(vc); } return(vehicleClassList); }
private static string GetVehicleClassByName(Int32 vehicleClassId, VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCollection vehicleClasses) { string VehicleClassName = string.Empty; foreach (VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCBE vc in vehicleClasses) { if (vc.Id == vehicleClassId) { VehicleClassName = vc.Name; break; } } return(VehicleClassName); }
public static VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCBE GetVehicleClassId(CBE.VehicleClassCBE vehicleClass) { try { VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCollection vehicleClasses = new VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCollection(); string spName = VaaaN.MLFF.Libraries.CommonLibrary.Constants.oraclePackagePrefix + "VEHICLE_CLASS_GETBYID"; DbCommand command = VaaaN.MLFF.Libraries.CommonLibrary.DBA.DBAccessor.GetStoredProcCommand(spName); command.Parameters.Add(VaaaN.MLFF.Libraries.CommonLibrary.DBA.DBAccessor.CreateDbParameter(ref command, "P_VEHICLE_CLASS_ID", DbType.Int32, vehicleClass.Id, ParameterDirection.Input)); DataSet ds = VaaaN.MLFF.Libraries.CommonLibrary.DBA.DBAccessor.LoadDataSet(command, tableName); DataTable dt = ds.Tables[tableName]; vehicleClasses = ConvertDataTableToCollection(dt); return(vehicleClasses[0]); } catch (Exception ex) { throw ex; } }
public static VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCollection GetAllAsCollection() { VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCollection vehicleClasses = new VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCollection(); try { //Stored procedure must have cur_out parameter. //There is no need to add ref cursor for oracle in code. string spName = VaaaN.MLFF.Libraries.CommonLibrary.Constants.oraclePackagePrefix + "VEHICLE_CLASS_GETALL"; DbCommand command = VaaaN.MLFF.Libraries.CommonLibrary.DBA.DBAccessor.GetStoredProcCommand(spName); DataSet ds = VaaaN.MLFF.Libraries.CommonLibrary.DBA.DBAccessor.LoadDataSet(command, tableName); DataTable dt = ds.Tables[tableName]; vehicleClasses = ConvertDataTableToCollection(dt); } catch (Exception ex) { throw ex; } return(vehicleClasses); }
public static Int16 CreateCsvWithTitleFilter(string fpath, DataTable dt, string Title, object obj) { Int16 RetVal = 0; if (dt.Rows.Count > 0) { StreamWriter sw = new StreamWriter(fpath, false); int iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write(Title); } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); if (Title == "Customer") { CustomerVehicleModel objCustomerVehicleModel = new CustomerVehicleModel(); objCustomerVehicleModel = (CustomerVehicleModel)obj; #region Customer Id Filter iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Customer ID"); } else if (i == 1) { if (objCustomerVehicleModel.AccountId > 0) { sw.Write(objCustomerVehicleModel.AccountId); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Resident Id Filter iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Resident ID"); } else if (i == 1) { if (!string.IsNullOrEmpty(objCustomerVehicleModel.ResidentId)) { sw.Write(objCustomerVehicleModel.ResidentId); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Name Filter iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Name"); } else if (i == 1) { if (!string.IsNullOrEmpty(objCustomerVehicleModel.FirstName)) { sw.Write(objCustomerVehicleModel.FirstName); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Mobile Phone Filter iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Mobile Phone"); } else if (i == 1) { if (!string.IsNullOrEmpty(objCustomerVehicleModel.MobileNo)) { sw.Write(objCustomerVehicleModel.MobileNo); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Email iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Email"); } else if (i == 1) { if (!string.IsNullOrEmpty(objCustomerVehicleModel.EmailId)) { sw.Write(objCustomerVehicleModel.EmailId); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Registration Num (VRN) iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Registration Num (VRN)"); } else if (i == 1) { if (!string.IsNullOrEmpty(objCustomerVehicleModel.VehRegNo)) { sw.Write(objCustomerVehicleModel.VehRegNo); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion } else if (Title == "Vehicle") { CustomerVehicleModel objCustomerVehicleModel = new CustomerVehicleModel(); objCustomerVehicleModel = (CustomerVehicleModel)obj; #region Customer Id Filter iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Customer ID"); } else if (i == 1) { if (objCustomerVehicleModel.AccountId > 0) { sw.Write(objCustomerVehicleModel.AccountId); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Resident Id Filter iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Resident ID"); } else if (i == 1) { if (!string.IsNullOrEmpty(objCustomerVehicleModel.ResidentId)) { sw.Write(objCustomerVehicleModel.ResidentId); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Name Filter iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Name"); } else if (i == 1) { if (!string.IsNullOrEmpty(objCustomerVehicleModel.FirstName)) { sw.Write(objCustomerVehicleModel.FirstName); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Mobile Phone Filter iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Mobile Phone"); } else if (i == 1) { if (!string.IsNullOrEmpty(objCustomerVehicleModel.MobileNo)) { sw.Write(objCustomerVehicleModel.MobileNo); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Email iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Email"); } else if (i == 1) { if (!string.IsNullOrEmpty(objCustomerVehicleModel.EmailId)) { sw.Write(objCustomerVehicleModel.EmailId); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Certificate Num (VRCN) iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Certificate Num (VRCN)"); } else if (i == 1) { if (!string.IsNullOrEmpty(objCustomerVehicleModel.VehicleRCNumber)) { sw.Write(objCustomerVehicleModel.VehicleRCNumber); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Registration Num (VRN) iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Registration Num (VRN)"); } else if (i == 1) { if (!string.IsNullOrEmpty(objCustomerVehicleModel.VehRegNo)) { sw.Write(objCustomerVehicleModel.VehRegNo); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Class iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Class"); } else if (i == 1) { if (objCustomerVehicleModel.VehicleClassId > 0) { VaaaN.MLFF.Libraries.CommonLibrary.CBE.VehicleClassCollection vehicleClasses = VaaaN.MLFF.Libraries.CommonLibrary.BLL.VehicleClassBLL.GetAllAsCollection(); sw.Write(GetVehicleClassByName(objCustomerVehicleModel.VehicleClassId, vehicleClasses)); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Status iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Status"); } else if (i == 1) { if (objCustomerVehicleModel.QueueStatus > 0) { sw.Write(Constants.CustomerQueueStatusName[(objCustomerVehicleModel.QueueStatus) - 1]); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion #region Exception iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { if (i == 0) { sw.Write("Exception"); } else if (i == 1) { if (objCustomerVehicleModel.ExceptionFlag > 0) { sw.Write(Constants.ExceptionFlagName[(objCustomerVehicleModel.ExceptionFlag) - 1]); } else { sw.Write("All"); } } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); #endregion } sw.Write(sw.NewLine); sw.Write(sw.NewLine); iColCount = dt.Columns.Count; for (int i = 0; i < iColCount; i++) { sw.Write(dt.Columns[i].ToString()); if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); foreach (DataRow dr in dt.Rows) { for (int i = 0; i < iColCount; i++) { if (!Convert.IsDBNull(dr[i])) { sw.Write(dr[i].ToString().Replace("\r\n", " ").Replace(",", " ")); } if (i < iColCount) { sw.Write(","); } } sw.Write(sw.NewLine); } sw.Close(); RetVal = 1; } dt.Rows.Clear(); return(RetVal); }