public int ValidateUser(UserDTO oUserData) { DatabaseManager oDB; int iLoginId = 0; oDB = new DatabaseManager(); try { string sProcName = "up_ValidateUser"; oDB.DbCmd = oDB.GetStoredProcCommand(sProcName); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sUserId", DbType.String, oUserData.UserId); // oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sPwd", DbType.String, oUserData.Password); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sPwd", DbType.String, DataSecurityManager.Encrypt(oUserData.Password)); DataSet ds = oDB.ExecuteDataSet(oDB.DbCmd); if (ds != null) { if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { iLoginId = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString()); } } if (iLoginId != 0) { SaveUserInfoToSession(oUserData.UserId); } } catch (Exception exp) { throw exp; } return(iLoginId); }
protected void Page_Load(object sender, EventArgs e) { string st = DataSecurityManager.Encrypt("*****@*****.**"); if (Session["CustomerMailId"] == null || Session["AgentMailId"] == null) { LinkButton1.Visible = false; } if (Session["CustName"] != null) { lblUsername.Text = "Hello " + Session["CustName"].ToString(); //lnkCustomerRegis.Visible = false; navlogin.Visible = false; LinkButton1.Visible = true; } else if (Session["UserName"] != null) { lblUsername.Text = "Hello " + Session["UserName"].ToString(); //lnkCustomerRegis.Visible = false; navlogin.Visible = false; LinkButton1.Visible = true; } else { //lnkCustomerRegis.Visible = false; navlogin.Visible = true; LinkButton1.Visible = false; } }
public int Insert(AgentDTO oAgentData) { DatabaseManager oDB; int agentId = -1; try { oDB = new DatabaseManager(); string sProcName = "up_Ins_AgentMaster"; oDB.DbCmd = oDB.GetStoredProcCommand(sProcName); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sAgentCode", DbType.String, oAgentData.AgentCode); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sAgentName", DbType.String, oAgentData.AgentName); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@AgentEmailId", DbType.String, DataSecurityManager.Encrypt(oAgentData.EmailId)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@Password", DbType.String, DataSecurityManager.Encrypt(oAgentData.Password)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@Category", DbType.String, DataSecurityManager.Encrypt(oAgentData.category)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@Country", DbType.String, DataSecurityManager.Encrypt(oAgentData.country)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@localAgent", DbType.Byte, oAgentData.localagent); << << << < HEAD oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@CssPath", DbType.String, oAgentData.CssPath); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@RedirectURL", DbType.String, oAgentData.RedirectURL); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@IsPaymentBypass", DbType.Boolean, (oAgentData.IsPaymentBypass)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@AgentURL", DbType.String, (oAgentData.AgentURL));
public bool Insert(UserDTO oUserData) { string sProcName; DatabaseManager oDB; try { oDB = new DatabaseManager(); sProcName = "up_Ins_UserMaster"; oDB.DbCmd = oDB.GetStoredProcCommand(sProcName); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@UserId", DbType.String, oUserData.UserId); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sUserName", DbType.String, DataSecurityManager.Encrypt(oUserData.UserName)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@Password", DbType.String, DataSecurityManager.Encrypt(oUserData.Password)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@Active", DbType.Boolean, oUserData.Active); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@Administrator", DbType.Boolean, oUserData.Administrator); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@UserRoleId", DbType.Int32, oUserData.UserRoleData.UserRoleId); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@UserEmailId", DbType.String, DataSecurityManager.Encrypt(oUserData.EmailId)); oDB.ExecuteNonQuery(oDB.DbCmd); } catch (Exception exp) { oDB = null; oUserData = null; GF.LogError("clsUserMaster.Insert", exp.Message); return(false); } finally { oDB = null; oUserData = null; } return(true); }
private void btnEncrypt_Click(object sender, EventArgs e) { List <UserMaster> userMasterEncryptedList = new List <UserMaster>(); foreach (DataGridViewRow row in dgDB.Rows) { UserMaster um = row.DataBoundItem as UserMaster; um.UserName = DataSecurityManager.Encrypt(um.UserName); um.Password = DataSecurityManager.Encrypt(um.Password); userMasterEncryptedList.Add(um); } dgEncrypted.DataSource = userMasterEncryptedList; }
private void btnEncryptText_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtPlainText.Text)) { MessageBox.Show("Please enter the plain text to encrypt"); return; } List <string> txtList = txtPlainText.Lines.ToList(); StringBuilder sb = new StringBuilder(); foreach (string plainText in txtList) { if (!string.IsNullOrWhiteSpace(plainText)) { sb.AppendLine(DataSecurityManager.Encrypt(plainText)); } } txtResult.Text = sb.ToString(); lblTotalLength.Text = txtResult.Text.Length.ToString(); }
public int AddCustomers(BALCustomers obj) { try { SqlConnection cn = new SqlConnection(strCon); SqlDataAdapter da = new SqlDataAdapter(); da.InsertCommand = new SqlCommand("[dbo].[sp_customers]", cn); da.InsertCommand.Parameters.AddWithValue("@action", obj.action); da.InsertCommand.Parameters.AddWithValue("@Address1", DataSecurityManager.Encrypt(obj.Address1)); da.InsertCommand.Parameters.AddWithValue("@Address2", DataSecurityManager.Encrypt(obj.Address2)); da.InsertCommand.Parameters.AddWithValue("@City", DataSecurityManager.Encrypt(obj.City)); da.InsertCommand.Parameters.AddWithValue("@CountryId", obj.CountryId); da.InsertCommand.Parameters.AddWithValue("@Password", DataSecurityManager.Encrypt(obj.Password)); da.InsertCommand.Parameters.AddWithValue("@Email", DataSecurityManager.Encrypt(obj.Email)); da.InsertCommand.Parameters.AddWithValue("@FirstName", DataSecurityManager.Encrypt(obj.FirstName)); da.InsertCommand.Parameters.AddWithValue("@LastName", DataSecurityManager.Encrypt(obj.LastName)); da.InsertCommand.Parameters.AddWithValue("@PostalCode", DataSecurityManager.Encrypt(obj.PostalCode)); da.InsertCommand.Parameters.AddWithValue("@State", DataSecurityManager.Encrypt(obj.State)); da.InsertCommand.Parameters.AddWithValue("@Telephone", DataSecurityManager.Encrypt(obj.Telephone)); da.InsertCommand.Parameters.AddWithValue("@Title", DataSecurityManager.Encrypt(obj.Title)); da.InsertCommand.Parameters.AddWithValue("@PaymentMethod", DataSecurityManager.Encrypt(obj.PaymentMethod)); da.InsertCommand.Parameters.AddWithValue("@Term", obj.term); << << << < HEAD da.InsertCommand.Parameters.AddWithValue("@AgentId", obj.AgentId); da.InsertCommand.CommandType = CommandType.StoredProcedure; cn.Open(); int Status = da.InsertCommand.ExecuteNonQuery(); cn.Close(); if (Status > 0) { return(Status); } else { return(0); } }
private void prepareQuery(int BookingId, List <Row> rowList, XMLMapper xmlMapper) { StringBuilder insertQuery1 = new StringBuilder(); StringBuilder insertQuery2 = new StringBuilder(); StringBuilder updateQuery = new StringBuilder(); StringBuilder existQuery = new StringBuilder(); StringBuilder fetchTouristNoQuery = new StringBuilder(); bool gotSomeCells = false; string tablename = xmlMapper.TableName; try { foreach (Row row in rowList) { #region Intializing Queries insertQuery1.Remove(0, insertQuery1.Length); insertQuery2.Remove(0, insertQuery2.Length); updateQuery.Remove(0, updateQuery.Length); existQuery.Remove(0, existQuery.Length); fetchTouristNoQuery.Remove(0, fetchTouristNoQuery.Length); insertQuery1 = new StringBuilder(); insertQuery2 = new StringBuilder(); updateQuery = new StringBuilder(); existQuery = new StringBuilder(); fetchTouristNoQuery = new StringBuilder(); insertQuery1.Append("insert into " + tablename + "("); insertQuery2.Append(" values ("); updateQuery.Append("update " + tablename + " set "); existQuery.Append("select * from " + tablename + " where 1=1"); #endregion foreach (ReadPattern readPattern in xmlMapper.ReadPatternList) { #region ColumnWise if (readPattern.ReadPatternValue == "columnwise") { foreach (XMLFieldMapper xmlFieldMapper in readPattern.XmlFieldMapperList) { Cells cell = row.CellList.Find(delegate(Cells c) { return(c.ColNum == xmlFieldMapper.ExcelColumn); }); if (cell != null) { #region Formatting to Date if it date field if (xmlFieldMapper.IsDateField) { DateTime dt; DateTime.TryParse(cell.CellValue, out dt); if (dt != DateTime.MinValue) { cell.CellValue = dt.Year.ToString("0000") + "-" + dt.Month.ToString("00") + "-" + dt.Day.ToString("00"); } else { cell.CellValue = "null"; } } #endregion #region Get Master Id Field if (xmlFieldMapper.MasterLookUpTable.Trim() != string.Empty) { cell.CellValue = getValueFromMaster(xmlFieldMapper.MasterLookUpTable, xmlFieldMapper.MasterIdField, xmlFieldMapper.MasterLookUpField, cell.CellValue); } #endregion #region Preparing the Exist Query if (xmlFieldMapper.IsIdField) { if (cell.CellValue == "null") { existQuery.Append(" and " + xmlFieldMapper.DbField + " = " + cell.CellValue); } else if (xmlFieldMapper.IsAlpha) { if (xmlFieldMapper.IsDateField) { string newVal = "cast('" + cell.CellValue + "' as DateTime)"; existQuery.Append(" and " + xmlFieldMapper.DbField + " = " + newVal); } else { existQuery.Append(" and " + xmlFieldMapper.DbField + " = '" + cell.CellValue + "'"); } } else { existQuery.Append(" and " + xmlFieldMapper.DbField + " = " + cell.CellValue); } } #endregion #region Preparing the Fetch Tourist No. Query if (xmlFieldMapper.FetchTouristNo) { if (cell.CellValue == "null") { fetchTouristNoQuery.Append(" and " + xmlFieldMapper.DbField + " = " + cell.CellValue); } else if (xmlFieldMapper.IsAlpha) { fetchTouristNoQuery.Append(" and " + xmlFieldMapper.DbField + " = '" + cell.CellValue + "'"); } else { fetchTouristNoQuery.Append(" and " + xmlFieldMapper.DbField + " = " + cell.CellValue); } } #endregion insertQuery1.Append(xmlFieldMapper.DbField + ", "); #region Adding '', if field is Alpha if (xmlFieldMapper.IsAlpha) { if (cell.CellValue == "null") { insertQuery2.Append(cell.CellValue + ", "); updateQuery.Append(xmlFieldMapper.DbField + " = " + cell.CellValue + ", "); } else { string val = xmlFieldMapper.Encrypt ? DataSecurityManager.Encrypt(cell.CellValue) : cell.CellValue; insertQuery2.Append("'" + val + "', "); updateQuery.Append(xmlFieldMapper.DbField + " = '" + val + "', "); } } else { insertQuery2.Append(cell.CellValue + ", "); updateQuery.Append(xmlFieldMapper.DbField + " = " + cell.CellValue + ", "); } #endregion gotSomeCells = true; } } } #endregion #region RowWise if (readPattern.ReadPatternValue == "rowwise") { string prevValue = string.Empty; foreach (Row columnarRow in rowList) { XMLFieldMapper xmlFieldMapper = readPattern.XmlFieldMapperList.Find(delegate(XMLFieldMapper fm) { return(fm.ExcelRow == columnarRow.RowNum); }); if (xmlFieldMapper != null) { Cells cell = columnarRow.CellList.Find(delegate(Cells c) { return(c.ColNum == xmlFieldMapper.ExcelColumn); }); if (cell != null) { #region Formatting to Date if it is date field if (xmlFieldMapper.IsDateField) { DateTime dt; DateTime.TryParse(cell.CellValue, out dt); if (dt != DateTime.MinValue) { cell.CellValue = dt.Year.ToString("0000") + "-" + dt.Month.ToString("00") + "-" + dt.Day.ToString("00"); } else { cell.CellValue = "null"; } } #endregion #region Formatting to Date if it is Time field if (xmlFieldMapper.TimeField) { cell.CellValue = cell.CellValue.Replace("HRS", "").Trim(); DateTime dt; DateTime.TryParse(cell.CellValue, out dt); cell.CellValue = dt.ToShortTimeString(); //if (cell.CellValue.Length == 4 && cell.CellValue != "null") //{ // string hh = cell.CellValue.Substring(0, 2); // string mm = cell.CellValue.Substring(2); // cell.CellValue = hh + ":" + mm; //} //else // cell.CellValue = "null"; } #endregion #region Formatting to Bool if it is Boolean field if (xmlFieldMapper.IsBool) { if (cell.CellValue.StartsWith("Y")) { cell.CellValue = "1"; } else if (cell.CellValue.StartsWith("N")) { cell.CellValue = "0"; } } #endregion #region Get Master Id Field if (xmlFieldMapper.MasterLookUpTable.Trim() != string.Empty) { cell.CellValue = getValueFromMaster(xmlFieldMapper.MasterLookUpTable, xmlFieldMapper.MasterIdField, xmlFieldMapper.MasterLookUpField, cell.CellValue); } #endregion #region Preparing the Exist Query if (xmlFieldMapper.IsIdField) { if (cell.CellValue == "null") { existQuery.Append(" and " + xmlFieldMapper.DbField + " = " + cell.CellValue); } else if (xmlFieldMapper.IsAlpha) { existQuery.Append(" and " + xmlFieldMapper.DbField + " = '" + cell.CellValue + "'"); } else { existQuery.Append(" and " + xmlFieldMapper.DbField + " = " + cell.CellValue); } } #endregion if (!xmlFieldMapper.JoinToPrev) { insertQuery1.Append(xmlFieldMapper.DbField + ", "); #region Adding '', if field is Alpha if (xmlFieldMapper.IsAlpha) { if (cell.CellValue == "null") { insertQuery2.Append(cell.CellValue + ", "); updateQuery.Append(xmlFieldMapper.DbField + " = " + cell.CellValue + ", "); } else { insertQuery2.Append("'" + cell.CellValue + "', "); updateQuery.Append(xmlFieldMapper.DbField + " = '" + cell.CellValue + "', "); } } else { insertQuery2.Append(cell.CellValue + ", "); updateQuery.Append(xmlFieldMapper.DbField + " = " + cell.CellValue + ", "); } #endregion } else { if (prevValue != "null" && cell.CellValue != "null") { int lastindex = insertQuery2.ToString().LastIndexOf("'"); insertQuery2.Insert(lastindex, " " + cell.CellValue); lastindex = updateQuery.ToString().LastIndexOf("'"); updateQuery.Insert(lastindex, " " + cell.CellValue); } } prevValue = cell.CellValue; gotSomeCells = true; } } } } #endregion } #region DB OPerations if (gotSomeCells) { #region Get Tourist No. fetchTouristNoQuery.Append(" and bookingId = " + BookingId.ToString()); int TouristNo = getTouristNo(fetchTouristNoQuery.ToString()); existQuery.Append(" and bookingId = " + BookingId.ToString()); insertQuery1.Append("TouristNo, "); insertQuery2.Append(TouristNo.ToString() + ","); updateQuery.Append("TouristNo = " + TouristNo.ToString()); #endregion #region Adding Booking Id insertQuery1.Append("BookingId) "); insertQuery2.Append(BookingId.ToString() + ")"); if (updateQuery.ToString().EndsWith(",")) { updateQuery = updateQuery.Remove(updateQuery.ToString().Trim().LastIndexOf(','), 1); } //updateQuery = updateQuery.Remove(updateQuery.Length - 1, 1); updateQuery.Append(" where BookingId = " + BookingId.ToString()); updateQuery.Append(" and TouristNo = " + TouristNo.ToString()); #endregion insertQuery1.Append(insertQuery2); if (IsExists(existQuery.ToString())) { UpdateRecord(updateQuery.ToString()); } else { InsertRecord(insertQuery1.ToString()); } } #endregion } RemoveExtraInsertedRecords(BookingId); } catch (Exception exp) { throw exp; } }
public AgentDTO AgentLoginForTouristEntry(BALLogin obj) { try { SqlConnection cn = new SqlConnection(strCon); string query = "select a.AgentId, AgentCode, AgentName, AgentEmailId, Password from tblAgentMaster a inner join tblBooking b on b.AgentId=a.AgentId where BookingID=" + obj.BookingId + " and AgentEmailId='" + DataSecurityManager.Encrypt(obj.EmailId) + "' and [password]='" + DataSecurityManager.Encrypt(obj.Password) + "'"; SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = query; cmd.Connection = cn; cn.Open(); AgentDTO agent = null; SqlDataReader reader = cmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(reader); if (dt != null && dt.Rows.Count > 0) { agent = new AgentDTO(); agent.AgentId = dt.Rows[0]["AgentId"] != null?Convert.ToInt32(dt.Rows[0]["AgentId"]) : -1; agent.AgentCode = dt.Rows[0]["AgentCode"] != null ? dt.Rows[0]["AgentCode"].ToString() : string.Empty; agent.AgentName = dt.Rows[0]["AgentName"] != null?DataSecurityManager.Decrypt(dt.Rows[0]["AgentName"].ToString()) : string.Empty; agent.EmailId = dt.Rows[0]["AgentEmailId"] != null?DataSecurityManager.Decrypt(dt.Rows[0]["AgentEmailId"].ToString()) : string.Empty; agent.Password = dt.Rows[0]["Password"] != null?DataSecurityManager.Decrypt(dt.Rows[0]["Password"].ToString()) : string.Empty; } reader.Close(); cn.Close(); return(agent); } catch (Exception exp) { throw exp; } }
//SELECT DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX, NUMERIC_SCALE, DATETIME_PRECISION //FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'GetSeasons' AND COLUMN_NAME = 'SeasonName' internal void EncryptData(List <ParentItem> items) { StringBuilder sb = new StringBuilder(); List <string> updateQueryCollection = new List <string>(); string updateQuery = string.Empty; List <string> columnNames = new List <string>(); foreach (var parentItem in items) { string tableName = parentItem.ItemName; foreach (var childItem in parentItem.Children) { string columnName = childItem.ItemName; if (childItem.Selected) { ChangeColumnLength(tableName, columnName); } columnNames.Add(columnName); } string query = "select " + string.Join(", ", columnNames) + " from " + tableName; List <ColumnDetail> columnDetails = new List <ColumnDetail>(); var reader = GetData(query); while (reader.Read()) { columnDetails.Clear(); for (int i = 0; i < reader.FieldCount; i++) { ColumnDetail cd = new ColumnDetail(); cd.ColumnName = reader.GetName(i); cd.ColumnType = reader.GetFieldType(i); cd.Value = reader.GetValue(i); columnDetails.Add(cd); } #region Prepare the update part of the query updateQuery = "update " + tableName + " set "; foreach (var columnToBeEncrypted in parentItem.Children.Where(c => c.Selected)) { ColumnDetail cd = columnDetails.FirstOrDefault(c => string.Compare(c.ColumnName, columnToBeEncrypted.ItemName, true) == 0); updateQuery += columnToBeEncrypted.ItemName + " = '" + DataSecurityManager.Encrypt(cd.Value.ToString()) + "', "; } if (updateQuery.Trim().EndsWith(",")) { updateQuery = updateQuery.Trim().Substring(0, updateQuery.Trim().Length - 1); } #endregion #region Prepare The Where Clause updateQuery += " where 1 = 1 "; foreach (var columnToBeEncrypted in parentItem.Children.Where(c => c.Selected)) { var otherColumn = columnDetails.FirstOrDefault(c => string.Compare(c.ColumnName, columnToBeEncrypted.ItemName, true) == 0); if (otherColumn == null) { continue; } string value = otherColumn.Value == DBNull.Value ? "NULL" : otherColumn.Value.ToString(); //Console.WriteLine(otherColumn.Value.ToString()); updateQuery += " and " + otherColumn.ColumnName + DecorateForSQlQuery(otherColumn.ColumnType, value); } #endregion updateQuery += ";"; updateQueryCollection.Add(updateQuery); sb.AppendLine(updateQuery); } reader.Close(); } string qc = sb.ToString(); foreach (var q in updateQueryCollection) { ExecuteNonQuery(q); } }
public BookingTouristDTO[] SearchTourists(string Firstname, string Lastname, string Passportno, int Nationality) { DataSet ds; BookingTouristDTO[] oBookingTouristDTO; oBookingTouristDTO = null; string sProcName; try { oDB = new DatabaseManager(); sProcName = "up_SearchTourists"; oDB.DbCmd = oDB.GetStoredProcCommand(sProcName); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sFirstName", DbType.String, DataSecurityManager.Encrypt(Firstname)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sLastName", DbType.String, DataSecurityManager.Encrypt(Lastname)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sPassportNo", DbType.String, DataSecurityManager.Encrypt(Passportno)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@iNationalityid", DbType.Int32, Nationality); ds = oDB.ExecuteDataSet(oDB.DbCmd); oDB = null; } catch (Exception exp) { oDB = null; ds = null; GF.LogError("clsBookingTouristhandler.GetTouristDetails", exp.Message); } oBookingTouristDTO = FillTouristDetails(ds); return(oBookingTouristDTO); }
public BookingTouristDTO[] GetTouristsftr(string bcode, string email, string ppno, string firstName, DateTime chkin, DateTime chkout, int accomid) { DataSet ds; DataRow dr; BookingTouristDTO[] oBookingTouristDTO; string sProcName; oBookingTouristDTO = null; try { oDB = new DatabaseManager(); sProcName = "up_Get_Touristsftr"; oDB.DbCmd = oDB.GetStoredProcCommand(sProcName); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@BookingCode", DbType.String, bcode); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@name", DbType.String, DataSecurityManager.Encrypt(firstName)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@EmailId", DbType.String, email); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@passportNo", DbType.String, DataSecurityManager.Encrypt(ppno)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@chkindate", DbType.Date, chkin); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@chkoutdate", DbType.Date, chkout); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@accomid", DbType.Int32, accomid); ds = oDB.ExecuteDataSet(oDB.DbCmd); oDB = null; } catch (Exception exp) { oDB = null; ds = null; // GF.LogError("clsBookingTouristHandler.GetTourist", exp.Message); } if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { oBookingTouristDTO = new BookingTouristDTO[ds.Tables[0].Rows.Count]; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { dr = ds.Tables[0].Rows[i]; oBookingTouristDTO[i] = new BookingTouristDTO(); if (dr.ItemArray.GetValue(0) != DBNull.Value) { oBookingTouristDTO[i].BookingCode = Convert.ToString(dr.ItemArray.GetValue(0)); } if (dr.ItemArray.GetValue(1) != DBNull.Value) { oBookingTouristDTO[i].BookingRef = Convert.ToString(dr.ItemArray.GetValue(1)); } if (dr.ItemArray.GetValue(2) != DBNull.Value) { oBookingTouristDTO[i].AgentName = dr.ItemArray.GetValue(2) != DBNull.Value ? DataSecurityManager.Decrypt(Convert.ToString(dr.ItemArray.GetValue(2))) : string.Empty; } //if (dr.ItemArray.GetValue(3) != DBNull.Value) // oBookingTouristDTO[i].ClientName = Convert.ToString(dr.ItemArray.GetValue(3)); if (dr.ItemArray.GetValue(4) != DBNull.Value) { oBookingTouristDTO[i].Gender = Convert.ToChar(dr.ItemArray.GetValue(4)); } if (dr.ItemArray.GetValue(5) != DBNull.Value) { oBookingTouristDTO[i].DateOfBirth = Convert.ToDateTime(dr.ItemArray.GetValue(5)); } if (dr.ItemArray.GetValue(6) != DBNull.Value) { oBookingTouristDTO[i].Nationality = Convert.ToString(dr.ItemArray.GetValue(6)); } if (dr.ItemArray.GetValue(7) != DBNull.Value) { oBookingTouristDTO[i].PassportNo = dr.ItemArray.GetValue(7) != DBNull.Value ? DataSecurityManager.Decrypt(Convert.ToString(dr.ItemArray.GetValue(7))) : string.Empty; } if (dr.ItemArray.GetValue(8) != DBNull.Value) { oBookingTouristDTO[i].AccomName = Convert.ToString(dr.ItemArray.GetValue(8)); } if (dr.ItemArray.GetValue(9) != DBNull.Value) { oBookingTouristDTO[i].CheckinDate = Convert.ToDateTime(dr.ItemArray.GetValue(9)); } if (dr.ItemArray.GetValue(10) != DBNull.Value) { oBookingTouristDTO[i].CheckoutDate = Convert.ToDateTime(dr.ItemArray.GetValue(10)); } if (dr.ItemArray.GetValue(11) != DBNull.Value) { oBookingTouristDTO[i].EmailId = Convert.ToString(dr.ItemArray.GetValue(11)); } if (dr.ItemArray.GetValue(12) != DBNull.Value) { oBookingTouristDTO[i].BookingId = Convert.ToInt32(dr.ItemArray.GetValue(12)); } if (dr.ItemArray.GetValue(13) != DBNull.Value) { oBookingTouristDTO[i].TouristNo = Convert.ToInt32(dr.ItemArray.GetValue(13)); } if (dr.ItemArray.GetValue(14) != DBNull.Value) { oBookingTouristDTO[i].FirstName = DataSecurityManager.Decrypt(Convert.ToString(dr.ItemArray.GetValue(14))); } if (dr.ItemArray.GetValue(15) != DBNull.Value) { oBookingTouristDTO[i].MiddleName = DataSecurityManager.Decrypt(Convert.ToString(dr.ItemArray.GetValue(15))); } if (dr.ItemArray.GetValue(16) != DBNull.Value) { oBookingTouristDTO[i].LastName = DataSecurityManager.Decrypt(Convert.ToString(dr.ItemArray.GetValue(16))); } } } } return(oBookingTouristDTO); }
private bool SaveData(BookingTouristDTO oBookingTouristDTO, Action oAction, out int TouristNo) { int iTouristNo = 0; TouristNo = 0; try { oDB = new DatabaseManager(); string sProcName = ""; if (oAction == Action.insert) { sProcName = "up_Ins_BookingTourist"; } else if (oAction == Action.update) { sProcName = "up_Upd_BookingTourist"; } oDB.DbCmd = oDB.GetStoredProcCommand(sProcName); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@BookingId", DbType.Int32, oBookingTouristDTO.BookingId); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@BookingCode", DbType.String, oBookingTouristDTO.BookingCode == null ? string.Empty : oBookingTouristDTO.BookingCode); if (oAction == Action.update) { oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@TouristNo", DbType.Int32, oBookingTouristDTO.TouristNo); } oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@FirstName", DbType.String, DataSecurityManager.Encrypt(oBookingTouristDTO.FirstName)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@MiddleName", DbType.String, DataSecurityManager.Encrypt(oBookingTouristDTO.MiddleName)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@LastName", DbType.String, DataSecurityManager.Encrypt(oBookingTouristDTO.LastName)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@Gender", DbType.String, oBookingTouristDTO.Gender); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@NationalityId", DbType.Int32, oBookingTouristDTO.NationalityId); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@PassportNo", DbType.String, DataSecurityManager.Encrypt(oBookingTouristDTO.PassportNo)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@DOB", DbType.DateTime, oBookingTouristDTO.DateOfBirth); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@PlaceofBirth", DbType.String, oBookingTouristDTO.PlaceofBirth); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@PPIssueDate", DbType.DateTime, GF.HandleMaxMinDates(oBookingTouristDTO.PassportIssueDate, false)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@PPExpiryDate", DbType.DateTime, GF.HandleMaxMinDates(oBookingTouristDTO.PassportExpiryDate, false)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@VisaNo", DbType.String, DataSecurityManager.Encrypt(oBookingTouristDTO.VisaNo)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@VisaExpiryDate", DbType.DateTime, GF.HandleMaxMinDates(oBookingTouristDTO.VisaExpiryDate, false)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@IndiaEntryDate", DbType.DateTime, GF.HandleMaxMinDates(oBookingTouristDTO.IndiaEntryDate, false)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@ProposedStayInIndia", DbType.String, oBookingTouristDTO.ProposedStayInIndia); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@ArrivalDateTime", DbType.DateTime, GF.HandleMaxMinDates(oBookingTouristDTO.ArrivalDateTime, true)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@ArrivedFrom", DbType.String, String.Empty); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@VehicleNo", DbType.String, String.Empty); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@TransportCompany", DbType.String, String.Empty); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@TransportMode", DbType.String, String.Empty); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@RoomDetails", DbType.String, oBookingTouristDTO.RoomDetails); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@NextDestination", DbType.String, String.Empty); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@DepartureDateTime", DbType.DateTime, GF.HandleMaxMinDates(oBookingTouristDTO.departuredate, true)); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@EmployedinIndia", DbType.Boolean, oBookingTouristDTO.EmployedinIndia); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@VisitPurpose", DbType.String, oBookingTouristDTO.VisitPurpose); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@PermanentAddressInIndia", DbType.String, oBookingTouristDTO.PermanentAddressInIndia); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@MealPlan", DbType.String, String.Empty); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@Allergies", DbType.String, oBookingTouristDTO.Allergies); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@MealPref", DbType.String, oBookingTouristDTO.MealPreferences); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@SpecialMessage", DbType.String, oBookingTouristDTO.SpecialMessage); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@VehicleName", DbType.String, String.Empty); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@DriverName", DbType.String, String.Empty); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@DriverPhoneNo", DbType.String, String.Empty); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@TransportPhoneNo", DbType.String, String.Empty); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@Suffix", DbType.String, oBookingTouristDTO.Suffix); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@EmailId", DbType.String, oBookingTouristDTO.EmailId); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@ArrivalVehicalno", DbType.String, oBookingTouristDTO.arrivalvehiaclno); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@DpartureVehicalno", DbType.String, oBookingTouristDTO.departurevehicalno); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@DepartureCity", DbType.String, oBookingTouristDTO.departureairport); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@ArrivalCity", DbType.String, oBookingTouristDTO.arrivalairport); iTouristNo = 0; if (oAction == Action.insert) { iTouristNo = Convert.ToInt32(oDB.ExecuteScalar(oDB.DbCmd)); } else if (oAction == Action.update) { oDB.ExecuteNonQuery(oDB.DbCmd); } TouristNo = iTouristNo; } catch (Exception exp) { oDB = null; oBookingTouristDTO = null; GF.LogError("clsBookingTouristHandler.SaveData", exp.Message); return(false); } return(true); }
protected void btnCustLogin_Click(object sender, EventArgs e) { if (rdbAgent.Checked == true || rdbCustomer.Checked == true) { } if (rdbAgent.Checked == true && rdbCustomer.Checked == true) { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('Please select only one type')", true); return; } if (rdbCustomer.Checked == true) { if (IsEmailValid(txtCustMailId.Value) == true) { if (Session["CustomerMailId"] == null) { try { // blcus.Email = txtCustMailId.Value blcus.Email = DataSecurityManager.Encrypt(txtCustMailId.Value.Trim()); blcus.action = "checkemail"; DataTable dtCustomer = dlcus.checkmail(blcus); if (dtCustomer != null && dtCustomer.Rows.Count > 0) { string password = DataSecurityManager.Decrypt(dtCustomer.Rows[0]["Password"].ToString()); sendMail(txtCustMailId.Value, password); txtCustMailId.Value = ""; rdbAgent.Checked = false; rdbCustomer.Checked = false; ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('We have send an email with your password,Please check your email')", true); //lblMsg.Text = "We have send an email with your password,Please check your email id"; //lblMsg.ForeColor = System.Drawing.Color.Green; //string BookRef = dtCustomer.Rows[0]["FirstName"].ToString() + dtCustomer.Rows[0]["LastName"].ToString() + "X" + Convert.ToDouble(dtrpax.Compute("SUM(Pax)", string.Empty)).ToString() + "-" + "Direct Client"; //ViewState["BookRef"] = BookRef; } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('This is not registered email')", true); return; } } catch (Exception ex) { throw ex; } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('You are already log in')", true); return; //lblMsg.Text = "You are already log in"; //lblMsg.ForeColor = System.Drawing.Color.Red; } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('Please enter valid email ')", true); return; //lblMsg.Text = "Please enter valid email id"; //lblMsg.ForeColor = System.Drawing.Color.Red; } } if (rdbAgent.Checked == true) { if (IsEmailValid(txtCustMailId.Value) == true) { if (Session["AgentMailId"] == null) { try { // bagnt._EmailId = txtCustMailId.Value; bagnt._EmailId = DataSecurityManager.Encrypt(txtCustMailId.Value.Trim()); bagnt._Action = "checkagentemail"; DataTable dtagent = dagnt.checkagentemail(bagnt); if (dtagent != null && dtagent.Rows.Count > 0) { // string password = dtagent.Rows[0]["Password"].ToString(); string password = DataSecurityManager.Decrypt(dtagent.Rows[0]["Password"].ToString()); sendMail(txtCustMailId.Value, password); txtCustMailId.Value = ""; rdbAgent.Checked = false; rdbCustomer.Checked = false; ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('We have send an email with your password,Please check your email ')", true); //lblMsg.Text = "We have send an email with your password,Please check your email id"; //lblMsg.ForeColor = System.Drawing.Color.Green; //string BookRef = dtCustomer.Rows[0]["FirstName"].ToString() + dtCustomer.Rows[0]["LastName"].ToString() + "X" + Convert.ToDouble(dtrpax.Compute("SUM(Pax)", string.Empty)).ToString() + "-" + "Direct Client"; //ViewState["BookRef"] = BookRef; } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('This is not registered email')", true); return; } } catch (Exception ex) { throw ex; } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('You are already log in ')", true); return; //lblMsg.Text = "You are already log in"; //lblMsg.ForeColor = System.Drawing.Color.Red; } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('Please enter valid email id')", true); return; //lblMsg.Text = "Please enter valid email id"; //lblMsg.ForeColor = System.Drawing.Color.Red; } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('Please select type')", true); return; //lblMsg.Text = "Please select type"; //lblMsg.ForeColor = System.Drawing.Color.Red; } }
protected void btnCustLogin_Click(object sender, EventArgs e) { if (Request.QueryString["bid"] != null) { try { string bid = Request.QueryString["bid"].ToString(); blcus.Email = txtCustMailId.Text.Trim(); blcus.Password = txtCustPass.Text.Trim(); blcus.action = "LoginCustForTEntry"; blcus.BookingId = Convert.ToInt32(bid); DataTable dtCustomer = dlcus.checkemailForTouristEntry(blcus); if (dtCustomer != null) { if (dtCustomer.Rows.Count > 0) { Session["userpass"] = txtCustPass.Text.Trim(); Session["CustMailId"] = txtCustMailId.Text.Trim(); Session["CustName"] = DataSecurityManager.Decrypt(dtCustomer.Rows[0]["FirstName"].ToString()); Session["CustomerCode"] = DataSecurityManager.Decrypt(dtCustomer.Rows[0]["CustId"].ToString()); string bEmail = dtCustomer.Rows[0][4].ToString(); string bPassword = dtCustomer.Rows[0][13].ToString(); string Email = DataSecurityManager.Encrypt(txtCustMailId.Text.Trim()); string Password = DataSecurityManager.Encrypt(txtCustPass.Text.Trim()); if (bEmail == Email) { if (bPassword == Password) { if (Request.QueryString["bid"] != null) { Response.Redirect("http://test1.adventureresortscruises.in/Cruise/Booking/Touristentry.aspx?bid=" + bid); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('Password incorrect')", true); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('Email Id incorrect')", true); } //customerLogin.Visible = false; } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('Password or Email Id incorrect')", true); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('Password or Email Id incorrect')", true); } //Bookingdt = Session["Bookingdt"] as DataTable; // preparetables(Bookingdt); } catch (Exception ex) { } } else { if (Session["CustMailId"] != null) { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('You are already login')", true); return; } else { try { blcus.Email = txtCustMailId.Text.Trim(); blcus.Password = txtCustPass.Text.Trim(); blcus.action = "LoginCust"; DataTable dtCustomer = dlcus.checkDuplicateemail(blcus); if (dtCustomer != null) { if (dtCustomer.Rows.Count > 0) { Session["userpass"] = txtCustPass.Text.Trim(); Session["CustMailId"] = txtCustMailId.Text.Trim(); Session["CustName"] = DataSecurityManager.Decrypt(dtCustomer.Rows[0]["FirstName"].ToString()); Session["CustomerCode"] = DataSecurityManager.Decrypt(dtCustomer.Rows[0]["CustId"].ToString()); if (Session["getavailable"] != null) { Response.Redirect(Session["getavailable"].ToString()); } else { Response.Redirect("../Booking/searchproperty1.aspx"); } //customerLogin.Visible = false; } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('Password or Email Id incorrect')", true); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Showstatus", "javascript:alert('Password or Email Id incorrect')", true); } //Bookingdt = Session["Bookingdt"] as DataTable; // preparetables(Bookingdt); } catch (Exception ex) { } } } }