public static void GetRegexOptions(out SqlInt32 regexOptions) { regexOptions = (int)defaultRegexOptions; }
public static IEnumerable ReadTerminatedBlocks(SqlFileInfo fileInfo, SqlInt64 offset, SqlBytes searchTerminator, [DefaultValue("1")] SqlBoolean omitTerminator, [DefaultValue("NULL")] SqlInt32 maxCount) { if (fileInfo.IsNull || searchTerminator.IsNull) { yield break; } var terminator = searchTerminator.Value; using (var fs = fileInfo.FileInfo.OpenRead()) { if (!offset.IsNull) { fs.Position = offset.Value; } var position = fs.Position; foreach (var block in fs.ReadCollection(s => s.TryReadBytes(terminator, omitTerminator.IsTrue), maxCount.IsNull ? int.MaxValue : maxCount.Value)) { yield return(Tuple.Create(position, block)); position = fs.Position; } } }
public static IEnumerable SplitLimAt(SqlRegex regex, [SqlFacet(MaxSize = -1)] SqlString input, [DefaultValue("NULL")] SqlInt32 count, [DefaultValue("NULL")] SqlInt32 startat) { if (regex == null) { throw new ArgumentNullException("regex"); } if (regex.IsNull || input.IsNull) { yield break; } var results = regex.Regex.Split(input.Value, !count.IsNull ? count.Value : int.MaxValue, !startat.IsNull ? startat.Value : 0); for (int i = 0; i < results.Length; i++) { yield return(results[i]); } }
public override DataTable SelectOne() { SqlCommand scmCmdToExecute = new SqlCommand(); scmCmdToExecute.CommandText = "dbo.[pr_CongViec_KetQua_SelectOne]"; scmCmdToExecute.CommandType = CommandType.StoredProcedure; DataTable dtToReturn = new DataTable("CongViec_KetQua"); SqlDataAdapter sdaAdapter = new SqlDataAdapter(scmCmdToExecute); // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection; try { scmCmdToExecute.Parameters.Add(new SqlParameter("@ID_CongViec_KetQua", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, m_iID_CongViec_KetQua)); if (m_bMainConnectionIsCreatedLocal) { // Open connection. m_scoMainConnection.Open(); } else { if (m_cpMainConnectionProvider.IsTransactionPending) { scmCmdToExecute.Transaction = m_cpMainConnectionProvider.CurrentTransaction; } } // Execute query. sdaAdapter.Fill(dtToReturn); if (dtToReturn.Rows.Count > 0) { m_iID_CongViec_KetQua = (Int32)dtToReturn.Rows[0]["ID_CongViec_KetQua"]; m_iID_CongViec = dtToReturn.Rows[0]["ID_CongViec"] == System.DBNull.Value ? SqlInt32.Null : (Int32)dtToReturn.Rows[0]["ID_CongViec"]; m_sNoiDung = dtToReturn.Rows[0]["NoiDung"] == System.DBNull.Value ? SqlString.Null : (string)dtToReturn.Rows[0]["NoiDung"]; m_dcGiaTri = dtToReturn.Rows[0]["GiaTri"] == System.DBNull.Value ? SqlDecimal.Null : (Decimal)dtToReturn.Rows[0]["GiaTri"]; m_iID_DonVi_KetQua = dtToReturn.Rows[0]["ID_DonVi_KetQua"] == System.DBNull.Value ? SqlInt32.Null : (Int32)dtToReturn.Rows[0]["ID_DonVi_KetQua"]; m_iID_NguoiLap = (Int32)dtToReturn.Rows[0]["ID_NguoiLap"]; m_daNgay_Lap = (DateTime)dtToReturn.Rows[0]["Ngay_Lap"]; m_daNgay_BatDau = dtToReturn.Rows[0]["Ngay_BatDau"] == System.DBNull.Value ? SqlDateTime.Null : (DateTime)dtToReturn.Rows[0]["Ngay_BatDau"]; m_daNgay_HoanThanh = dtToReturn.Rows[0]["Ngay_HoanThanh"] == System.DBNull.Value ? SqlDateTime.Null : (DateTime)dtToReturn.Rows[0]["Ngay_HoanThanh"]; } return(dtToReturn); } catch (Exception ex) { // some error occured. Bubble it to caller and encapsulate Exception object throw new Exception("clsCongViec_KetQua::SelectOne::Error occured.", ex); } finally { if (m_bMainConnectionIsCreatedLocal) { // Close connection. m_scoMainConnection.Close(); } scmCmdToExecute.Dispose(); sdaAdapter.Dispose(); } }
public new SqlBoolean Prepared(SqlInt32 objectId) { return base.Prepared(objectId); }
/// <summary> /// Legge i dati per l'oggetto dalla base dati /// </summary> public void Read() { SqlDataReader reader = null; string sqlCommand = null; DbCommand dbCommand = null; try { Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING"); sqlCommand = @" SELECT FUNZIONALITA.FNT_ID_FUNZIONALITA, FUNZIONALITA.FUN_FNT_ID_FUNZIONALITA, FUNZIONALITA.fnt_acronimo_funzionalita, FUNZIONALITA.fnt_accesso_predefinito, FUNZIONALITA.fnt_descrizione_ita, FUNZIONALITA.fnt_livello, FUNZIONALITA.fnt_posizione, FUNZIONALITA.fnt_pagina_asp, FUNZIONALITA.fnt_parametri, FUNZIONALITA.fnt_flag_foglia, FUNZIONALITA.fnt_flag_visibilita_menu, FUNZIONALITA.fnt_flag_apri_nuova, FUNZIONALITA.fnt_descrizione_eng, FUNZIONALITA.fnt_data_creazione, FUNZIONALITA.fnt_data_aggiornamento, FUNZIONALITA.fnt_creato_da, FUNZIONALITA.fnt_aggiornato_da, FUNZIONALITA.fnt_flag_figura, FUNZIONALITA.fnt_flag_eliminato, FUNZIONALITA.fnt_icona_menu, FUNZIONALITA.fnt_chiave_dizionario FROM FUNZIONALITA WHERE (FNT_ID_FUNZIONALITA =@fnt_id_funzionalita) " ; dbCommand = db.GetSqlStringCommand(sqlCommand); db.AddInParameter(dbCommand, "fnt_id_funzionalita", DbType.Int32, fnt_id_funzionalita); reader = ((RefCountingDataReader)db.ExecuteReader(dbCommand)).InnerReader as SqlDataReader; while (reader.Read()) { fnt_id_funzionalita = reader.GetSqlInt32(0); fun_fnt_id_funzionalita = reader.GetSqlInt32(1); fnt_acronimo_funzionalita = reader.GetSqlString(2); fnt_accesso_predefinito = reader.GetSqlInt32(3); fnt_descrizione_ita = reader.GetSqlString(4); fnt_livello = reader.GetSqlInt32(5); fnt_posizione = reader.GetSqlInt32(6); fnt_pagina_asp = reader.GetSqlString(7); fnt_parametri = reader.GetSqlInt32(8); fnt_flag_foglia = reader.GetSqlBoolean(9); fnt_flag_visibilita_menu = reader.GetSqlBoolean(10); fnt_flag_apri_nuova = reader.GetSqlBoolean(11); fnt_descrizione_eng = reader.GetSqlString(12); fnt_data_creazione = reader.GetSqlDateTime(13); fnt_data_aggiornamento = reader.GetSqlDateTime(14); fnt_creato_da = reader.GetSqlInt32(15); fnt_aggiornato_da = reader.GetSqlInt32(16); fnt_flag_figura = reader.GetSqlInt32(17); fnt_flag_eliminato = reader.GetSqlInt32(18); fnt_icona_menu = reader.GetSqlString(19); fnt_chiave_dizionario = reader.GetSqlString(20); } } catch (Exception ex) { ex.Data.Add("Class.Method", "Funzionalita.Read."); ex.Data.Add("SQL", GenericError.SubstituteParameters(dbCommand.CommandText, dbCommand.Parameters)); // Gestione messaggistica all'utente e trace in DB dell'errore ExceptionPolicy.HandleException(ex, "Direct Data Access Policy"); } finally { if (reader != null) { ((IDisposable)reader).Dispose(); } } }
public override DataTable SelectOne() { SqlCommand scmCmdToExecute = new SqlCommand(); scmCmdToExecute.CommandText = "dbo.[pr_SoTayKinhNghiem_SelectOne]"; scmCmdToExecute.CommandType = CommandType.StoredProcedure; DataTable dtToReturn = new DataTable("SoTayKinhNghiem"); SqlDataAdapter sdaAdapter = new SqlDataAdapter(scmCmdToExecute); // Use base class' connection object scmCmdToExecute.Connection = m_scoMainConnection; try { scmCmdToExecute.Parameters.Add(new SqlParameter("@iID_SoTay", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, m_iID_SoTay)); if (m_bMainConnectionIsCreatedLocal) { // Open connection. m_scoMainConnection.Open(); } else { if (m_cpMainConnectionProvider.IsTransactionPending) { scmCmdToExecute.Transaction = m_cpMainConnectionProvider.CurrentTransaction; } } // Execute query. sdaAdapter.Fill(dtToReturn); if (dtToReturn.Rows.Count > 0) { m_iID_SoTay = (Int32)dtToReturn.Rows[0]["ID_SoTay"]; m_daNgay_Thang = (DateTime)dtToReturn.Rows[0]["Ngay_Thang"]; m_iID_BoPhan = (Int32)dtToReturn.Rows[0]["ID_BoPhan"]; m_sMoTa = (string)dtToReturn.Rows[0]["MoTa"]; m_sMucDo_AnhHuong = (string)dtToReturn.Rows[0]["MucDo_AnhHuong"]; m_sNguyenNhan = (string)dtToReturn.Rows[0]["NguyenNhan"]; m_sBienPhap = (string)dtToReturn.Rows[0]["BienPhap"]; m_sGhiChu = (string)dtToReturn.Rows[0]["GhiChu"]; m_daNgay_Lap = (DateTime)dtToReturn.Rows[0]["Ngay_Lap"]; m_iID_NguoiLap = (Int32)dtToReturn.Rows[0]["ID_NguoiLap"]; } return(dtToReturn); } catch (Exception ex) { // some error occured. Bubble it to caller and encapsulate Exception object throw new Exception("clsSoTayKinhNghiem::SelectOne::Error occured.", ex); } finally { if (m_bMainConnectionIsCreatedLocal) { // Close connection. m_scoMainConnection.Close(); } scmCmdToExecute.Dispose(); sdaAdapter.Dispose(); } }
public static SqlBoolean LessThan(SqlInt32 x, SqlInt32 y) { return (x < y); }
public static SqlBoolean LessThanOrEqual(SqlInt32 x, SqlInt32 y) { return (x <= y); }
public static SqlBoolean GreaterThan(SqlInt32 x, SqlInt32 y) { return (x > y); }
public static SqlBoolean GreaterThanOrEqual(SqlInt32 x, SqlInt32 y) { return (x >= y); }
public static SqlBoolean Equals(SqlInt32 x, SqlInt32 y) { return (x == y); }
public static SqlInt32 Divide(SqlInt32 x, SqlInt32 y) { return (x/y); }
private int CompareSqlInt32(SqlInt32 value) { if (value.IsNull) { return 1; } else { return this.value.CompareTo(value.Value); } }
public static IEnumerable MatchesAt(SqlRegex regex, [SqlFacet(MaxSize = -1)] SqlString input, [DefaultValue("NULL")] SqlInt32 startat) { if (regex == null) { throw new ArgumentNullException("regex"); } if (regex.IsNull || input.IsNull) { yield break; } MatchCollection matches = regex.Regex.Matches(input.Value, !startat.IsNull ? startat.Value : 0); for (int i = 0; i < matches.Count; i++) { Match match = matches[i]; for (int j = 0; j < match.Groups.Count; j++) { Group group = match.Groups[j]; if (!group.Success) { yield return(new MatchRow(i, j, -1, group.Success, regex.Regex.GroupNameFromNumber(j), group.Index, group.Length, group.Value)); } else { for (int k = 0; k < group.Captures.Count; k++) { Capture capture = group.Captures[k]; yield return(new MatchRow(i, j, k, group.Success, regex.Regex.GroupNameFromNumber(j), capture.Index, capture.Length, capture.Value)); } } } } }
public static SqlInt32 Modulus(SqlInt32 x, SqlInt32 y) { return (x%y); }
public SqlString GetItem(SqlInt32 index) { return(!index.IsNull && _array[index.Value] != null ? _array[index.Value] : SqlString.Null); }
public static SqlInt32 Multiply(SqlInt32 x, SqlInt32 y) { return (x*y); }
public static void Clr_ExecAndLogAllMsgs(SqlChars SqlCmd, out SqlInt32 MaxSeverity, out SqlChars Msgs) { SqlCommand cmd; string LocalMsgs; // must be a local variable to be manipulated before returned by output param Int32 LocalMaxSeverity; // must be a local variable to be manipulated before returned by output param // Using implies an automatic dispose of the connexion object using (SqlConnection conn = new SqlConnection("context connection=true;")) { try { // Assumes that "conn" represents a SqlConnection object. conn.Open(); conn.FireInfoMessageEventOnUserErrors = true; // don't stop on first error message, want info message to catch them all // here is the inline delegate trick. This block of code is called back // when SQL Info messages are raised (informational or error) conn.InfoMessage += delegate(object sender, SqlInfoMessageEventArgs args) { LocalMaxSeverity = 0; String message; // use a string builder to cumulate messages StringBuilder SbMsgs = new StringBuilder(""); foreach (SqlError err in args.Errors) { if (!(err.Message == null)) { message = err.Message; if (err.Class == 0) { // don't put special info for messages produced by the print statement // SbMsgs.AppendFormat("{0} ", message); SbMsgs.AppendLine(message); } else { if (err.Class > 10) // error messages { string s; if (err.LineNumber > 0) { s = String.Format(" at line {0} in proc {1} ", err.LineNumber, err.Procedure); } else { s = ""; } SbMsgs.AppendFormat("Error {0}, Severity {1}, level {2} : {3}{4}", err.Number, err.Class, err.State, message, s); SbMsgs.AppendLine(); } else // informational messages { SbMsgs.AppendFormat("Warning Severity {0}, level {1} : {2}", err.Class, err.State, message); SbMsgs.AppendLine(); } if (err.Class > LocalMaxSeverity) { LocalMaxSeverity = err.Class; // this allows to know if a real error occured (severity > 10) } } } } LocalMsgs = SbMsgs.ToString(); }; // end of inline delegate code to trap and stored informational and error messages // execute SP using (cmd = new SqlCommand("sp_executeSql", conn)) { string sql; LocalMsgs = ""; // avoid compile warnings that says that the variable is not initialized LocalMaxSeverity = 0; // avoid compile warnings that says that the variable is not initialized sql = new string(SqlCmd.Buffer); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@statement", @SqlCmd)); cmd.ExecuteNonQuery(); Msgs = new SqlChars(LocalMsgs.ToCharArray()); // return local value into output parameter MaxSeverity = LocalMaxSeverity; // return local value into output parameter } } catch (SqlException ex) { throw new ApplicationException(ex.Message); } } }
public static SqlBoolean NotEquals(SqlInt32 x, SqlInt32 y) { return (x != y); }
public void InsertItem(SqlInt32 index, SqlInt64 value) { _list.Insert(index.IsNull ? _list.Count : index.Value, value.IsNull ? default(Int64?) : value.Value); }
public static SqlInt32 OnesComplement(SqlInt32 x) { return ~x; }
/// <summary> /// Propósito: Método SELECT. Este método hace Select de una fila existente en la base de datos, basado en la llave primaria. /// </summary> /// <returns>DataTable object si tuvo éxito, sino genera una Exception. </returns> /// <remarks> /// Propiedades necesarias para este método: /// <UL> /// <LI>CAR_USUARIO</LI> /// </UL> /// Propiedades actualizadas luego de una llamada exitosa a este método: /// <UL> /// <LI>CodError</LI> /// <LI>NOM_USUARIO</LI> /// <LI>CON_USUARIO</LI> /// <LI>CAR_USUARIO</LI> /// <LI>FK_IDTIPOUSUARIO</LI> /// </UL> /// Llena todas las propiedades que corresponden al campo en tabla con el valor de la fila seleccionada. /// </remarks> public override DataTable SeleccionarUno() { SqlCommand cmdAEjecutar = new SqlCommand(); cmdAEjecutar.CommandText = "dbo.[pr_SGMUUSUARIO_SeleccionarUno]"; cmdAEjecutar.CommandType = CommandType.StoredProcedure; DataTable toReturn = new DataTable("SGMUUSUARIO"); SqlDataAdapter adapter = new SqlDataAdapter(cmdAEjecutar); // Usar el objeto conexión de la clase base cmdAEjecutar.Connection = _conexionBD; try { cmdAEjecutar.Parameters.Add(new SqlParameter("@sCAR_USUARIO", SqlDbType.VarChar, 20, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, _cAR_USUARIO)); cmdAEjecutar.Parameters.Add(new SqlParameter("@iCodError", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _codError)); if (_conexionBDEsCreadaLocal) { // Abre una conexión. _conexionBD.Open(); } else { if (_conexionBDProvider.IsTransactionPending) { cmdAEjecutar.Transaction = _conexionBDProvider.CurrentTransaction; } } // Ejecuta la consulta. adapter.Fill(toReturn); _codError = Int32.Parse(cmdAEjecutar.Parameters["@iCodError"].Value.ToString()); if (_codError != (int)ITCRError.AllOk) { // Genera un error. throw new Exception("Procedimiento Almacenado 'pr_SGMUUSUARIO_SeleccionarUno' reportó el error Código: " + _codError); } if (toReturn.Rows.Count > 0) { _nOM_USUARIO = (string)toReturn.Rows[0]["NOM_USUARIO"]; _cON_USUARIO = (byte[])toReturn.Rows[0]["CON_USUARIO"]; _cAR_USUARIO = (string)toReturn.Rows[0]["CAR_USUARIO"]; _fK_IDTIPOUSUARIO = (Int32)toReturn.Rows[0]["FK_IDTIPOUSUARIO"]; } return(toReturn); } catch (Exception ex) { // Ocurrió un error. le hace Bubble a quien llama y encapsula el objeto Exception throw new Exception("cSGMUUSUARIOBase::SeleccionarUno::Ocurrió un error." + ex.Message, ex); } finally { if (_conexionBDEsCreadaLocal) { // Cierra la conexión. _conexionBD.Close(); } cmdAEjecutar.Dispose(); adapter.Dispose(); } }
public static SqlInt32 Subtract(SqlInt32 x, SqlInt32 y) { return (x - y); }
public int CompareTo(SqlInt32 value) { return this.CompareSqlInt32(value); }
public static SqlInt32 Xor(SqlInt32 x, SqlInt32 y) { return (x ^ y); }
public virtual void SetSqlInt32(int ordinal, SqlInt32 value) { EnsureSubclassOverride(); ValueUtilsSmi.SetSqlInt32(_eventSink, _recordBuffer, ordinal, GetSmiMetaData(ordinal), value); }
public static SqlInt32 Add(SqlInt32 x, SqlInt32 y) { return (x + y); }
private static void MatchesFillRow(object obj, out SqlInt32 MatchNumber, out SqlInt32 GroupNumber, out SqlInt32 CaptureNumber, out SqlBoolean GroupSuccess, [SqlFacet(MaxSize = 255)] out SqlString GroupName, out SqlInt32 Index, out SqlInt32 Length, [SqlFacet(MaxSize = -1)] out SqlString Value) { MatchRow matchRow = (MatchRow)obj; MatchNumber = new SqlInt32(matchRow.MatchNumber); GroupNumber = new SqlInt32(matchRow.GroupNumber); CaptureNumber = new SqlInt32(matchRow.CaptureNumber); GroupSuccess = new SqlBoolean(matchRow.GroupSuccess); GroupName = new SqlString(matchRow.GroupName); Index = matchRow.GroupSuccess ? new SqlInt32(matchRow.Index) : SqlInt32.Null; Length = matchRow.GroupSuccess ? new SqlInt32(matchRow.Length) : SqlInt32.Null; Value = matchRow.GroupSuccess ? new SqlString(matchRow.Value) : SqlString.Null; }
public static SqlInt32 BitwiseAnd(SqlInt32 x, SqlInt32 y) { return (x & y); }
public static SqlRegex Create([SqlFacet(MaxSize = -1)] SqlString pattern, SqlInt32 options) { return(pattern.IsNull ? SqlRegex.Null : new SqlRegex(pattern.Value, options.IsNull ? defaultRegexOptions : (RegexOptions)options.Value)); }
protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(hidCheckInID.Value) || hidCheckInID.Value == "0") { lblStatus.Text = "The Reservation is invalid. Not Checked In"; return; } if (drpBillServices.SelectedValue == "-1") { lblStatus.Text = "Please choose a Bill Service"; return; } if (drpCheckIn.SelectedValue == "-1") { lblStatus.Text = "Please Bill Service"; return; } Reservation_Payments rp = new Reservation_Payments(); rp.Reservation_ID = SqlInt32.Parse(drpCheckIn.SelectedValue); rp.CreatedDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Today); rp.PaymentPersonnel = Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name); rp.AvailedService_Type = PAYMENT_AVAILED_SERVICETYPES.BILLS_SERVICES; rp.Rate_ID = SqlInt32.Parse(drpBillServices.SelectedValue); rp.UnitsConsumed = SqlInt32.Parse(txtQuantity.Text); rp.TotalCost_Before_Discount = SqlMoney.Parse(txtPrice.Text); rp.Invoice = txtInvoice.Text == string.Empty ? string.Empty : txtInvoice.Text; rp.PaymentStatus = 1;//Active; rp.Discount_Offered = txtDiscount.Text == string.Empty ? 0 : SqlMoney.Parse(txtDiscount.Text); rp.Cost_After_Discount = rp.Discount_Offered == 0 ? rp.TotalCost_Before_Discount : SqlMoney.Parse(lblAfterDiscount.Text); rp.AmountReceived = txtAmountReceived.Text == string.Empty ? 0 : SqlMoney.Parse(txtAmountReceived.Text); if (rp.AmountReceived > 0) { if (drpPaymentModes.SelectedValue == "-1") { lblStatus.Text = "Please select a Payment Mode"; lblStatus.ForeColor = Color.Red; return; } else { rp.PaymentMode = SqlInt32.Parse(drpPaymentModes.SelectedValue); } } if (rp.Insert()) { rp.InsertServiceInvoice(); lblStatus.Text = "Payment Saved"; lblStatus.ForeColor = Color.Green; // return; //---------------for Printing the Amenity invoice---------------------------------------- DataTable amenitytbl = new DataTable(); DataColumn Id = new DataColumn("ID", typeof(int)); DataColumn ReservationID = new DataColumn("ReservationID", typeof(int)); DataColumn RoomId = new DataColumn("RoomID", typeof(string)); DataColumn ServiceName = new DataColumn("ServiceName", typeof(string)); DataColumn Invoice = new DataColumn("Invoice", typeof(string)); DataColumn Cost = new DataColumn("Cost", typeof(double)); DataColumn Qty = new DataColumn("Quantity", typeof(int)); DataColumn TotCost = new DataColumn("TotCost", typeof(double)); DataColumn Discount = new DataColumn("Discount", typeof(double)); DataColumn AfterDiscount = new DataColumn("AfterDiscount", typeof(double)); DataColumn AmountReceived = new DataColumn("AmountRecevied", typeof(double)); DataColumn PaymentMode = new DataColumn("PaymentMode", typeof(string)); DataColumn CreatedBy = new DataColumn("CreatedBy", typeof(string)); DataColumn InvoiceNo = new DataColumn("InvoiceNo", typeof(string)); amenitytbl.Columns.Add(Id); amenitytbl.Columns.Add(ReservationID); amenitytbl.Columns.Add(RoomId); amenitytbl.Columns.Add(ServiceName); amenitytbl.Columns.Add(Invoice); amenitytbl.Columns.Add(Cost); amenitytbl.Columns.Add(Qty); amenitytbl.Columns.Add(TotCost); amenitytbl.Columns.Add(Discount); amenitytbl.Columns.Add(AfterDiscount); amenitytbl.Columns.Add(AmountReceived); amenitytbl.Columns.Add(PaymentMode); amenitytbl.Columns.Add(CreatedBy); amenitytbl.Columns.Add(InvoiceNo); DataRow row = amenitytbl.NewRow(); row["Id"] = 1; row["ReservationID"] = Int32.Parse(rp.Reservation_ID.ToString()); row["ServiceName"] = drpBillServices.SelectedItem.Text; row["Invoice"] = txtInvoice.Text; row["Cost"] = double.Parse(lblPrice.Text); row["Quantity"] = int.Parse(rp.UnitsConsumed.ToString()); row["TotCost"] = double.Parse(rp.TotalCost_Before_Discount.ToString()); row["Discount"] = double.Parse(rp.Discount_Offered.ToString()); row["AfterDiscount"] = double.Parse(rp.Cost_After_Discount.ToString()); row["AmountRecevied"] = double.Parse(rp.AmountReceived.ToString()); row["PaymentMode"] = drpPaymentModes.SelectedItem.Text; row["CreatedBy"] = HttpContext.Current.User.Identity.Name; row["InvoiceNo"] = rp.ServiceNo.ToString(); amenitytbl.Rows.Add(row); Session["Inv"] = amenitytbl; string popupScript = "<script language='javascript'>" + "window.open('AmenityInvView.aspx','ThisPopUp1', " + "'left = 300, top=150, " + "menubar=no, scrollbars=yes, resizable=yes')" + "</script>"; Page.ClientScript.RegisterStartupScript(GetType(), "PopupScript", popupScript); //---------------------------------------------------------------------------------- } else { lblStatus.Text = rp.ErrorDesc.ToString() + " Error Playment Not saved !!!"; lblStatus.ForeColor = Color.Red; return; } }
public DataTable SelectByHospitalID(SqlInt32 HospitalID) { HospitalWiseReportDAL dalHospitalWiseReport = new HospitalWiseReportDAL(); return(dalHospitalWiseReport.SelectByHospitalID(HospitalID)); }
public ShortRegister GetShortRegister(SqlInt32 index) { return(ShortRegisters[index.Value]); }
public void FillRange([SqlFacet(MaxSize = -1)] SqlString value, SqlInt32 index, SqlInt32 count) { int indexValue = !index.IsNull ? index.Value : count.IsNull ? 0 : _array.Length - count.Value; int countValue = !count.IsNull ? count.Value : index.IsNull ? 0 : _array.Length - index.Value; _array.Fill(!value.IsNull ? value.Value : null, indexValue, countValue); }
private static void SplitToInt32FillRow(object obj, out SqlInt32 Value) { Value = default(Int32?).Equals(obj) ? SqlInt32.Null : (Int32)obj; }
/// <summary> /// Crea l'oggetto corrispondente nella base dati. /// </summary> public void Create() { string sqlCommand = null; DbCommand dbCommand = null; SqlDataReader reader = null; //Funzionalita objFnt = new Funzionalita(); //objFnt.Fnt_id_funzionalita = this.Fnt_id_funzionalita; //objFnt.Read(); //aggPosizione(-1, (int)objFnt.Fnt_posizione); try { Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING"); sqlCommand = @" INSERT INTO FUNZIONALITA ( FUN_FNT_ID_FUNZIONALITA, fnt_acronimo_funzionalita, fnt_accesso_predefinito, fnt_descrizione_ita, fnt_livello, fnt_posizione, fnt_pagina_asp, fnt_parametri, fnt_flag_foglia, fnt_flag_visibilita_menu, fnt_flag_apri_nuova, fnt_descrizione_eng, fnt_data_creazione, fnt_data_aggiornamento, fnt_creato_da, fnt_aggiornato_da, fnt_flag_figura, fnt_icona_menu, fnt_chiave_dizionario) VALUES ( @fun_fnt_id_funzionalita, @fnt_acronimo_funzionalita, @fnt_accesso_predefinito, @fnt_descrizione_ita, @fnt_livello, @fnt_posizione, @fnt_pagina_asp, @fnt_parametri, @fnt_flag_foglia, @fnt_flag_visibilita_menu, @fnt_flag_apri_nuova, @fnt_descrizione_eng, @fnt_data_creazione, @fnt_data_aggiornamento, @fnt_creato_da, @fnt_aggiornato_da, @fnt_flag_figura, @fnt_icona_menu, @fnt_chiave_dizionario) ; SELECT SCOPE_IDENTITY()" ; dbCommand = db.GetSqlStringCommand(sqlCommand); db.AddInParameter(dbCommand, "fun_fnt_id_funzionalita", DbType.Int32, fun_fnt_id_funzionalita); db.AddInParameter(dbCommand, "fnt_acronimo_funzionalita", DbType.String, fnt_acronimo_funzionalita); db.AddInParameter(dbCommand, "fnt_accesso_predefinito", DbType.Int32, fnt_accesso_predefinito); db.AddInParameter(dbCommand, "fnt_descrizione_ita", DbType.String, fnt_descrizione_ita); db.AddInParameter(dbCommand, "fnt_livello", DbType.Int32, fnt_livello); db.AddInParameter(dbCommand, "fnt_posizione", DbType.Int32, fnt_posizione); db.AddInParameter(dbCommand, "fnt_pagina_asp", DbType.String, fnt_pagina_asp); db.AddInParameter(dbCommand, "fnt_parametri", DbType.Int32, fnt_parametri); db.AddInParameter(dbCommand, "fnt_flag_foglia", DbType.Boolean, fnt_flag_foglia); db.AddInParameter(dbCommand, "fnt_flag_visibilita_menu", DbType.Boolean, fnt_flag_visibilita_menu); db.AddInParameter(dbCommand, "fnt_flag_apri_nuova", DbType.Boolean, fnt_flag_apri_nuova); db.AddInParameter(dbCommand, "fnt_descrizione_eng", DbType.String, fnt_descrizione_eng); db.AddInParameter(dbCommand, "fnt_data_creazione", DbType.DateTime, fnt_data_creazione); db.AddInParameter(dbCommand, "fnt_data_aggiornamento", DbType.DateTime, fnt_data_aggiornamento); db.AddInParameter(dbCommand, "fnt_creato_da", DbType.Int32, fnt_creato_da); db.AddInParameter(dbCommand, "fnt_aggiornato_da", DbType.Int32, fnt_aggiornato_da); db.AddInParameter(dbCommand, "fnt_flag_figura", DbType.Int32, fnt_flag_figura); db.AddInParameter(dbCommand, "fnt_icona_menu", DbType.String, fnt_icona_menu); db.AddInParameter(dbCommand, "fnt_chiave_dizionario", DbType.String, fnt_chiave_dizionario); reader = ((RefCountingDataReader)db.ExecuteReader(dbCommand)).InnerReader as SqlDataReader; while (reader.Read()) { fnt_id_funzionalita = Convert.ToInt32(reader[0]); } //la Funzionalità appena inserita va messa anche nei Permessi di Accesso //Per tutti i Ruoli si mette la Funzionalità con il suo Permesso di Accesso predefinito sqlCommand = @""; sqlCommand += @"INSERT INTO PERMESSO_ACCESSO ( FNT_ID_FUNZIONALITA, PMS_ID_MODALITA_ACCESSO, RUL_ID_RUOLO) SELECT FUNZIONALITA.FNT_ID_FUNZIONALITA, FUNZIONALITA.FNT_ACCESSO_PREDEFINITO, RUOLI.RUL_ID_RUOLO FROM FUNZIONALITA, RUOLI WHERE FNT_ID_FUNZIONALITA NOT IN (SELECT FNT_ID_FUNZIONALITA FROM PERMESSO_ACCESSO) "; dbCommand = db.GetSqlStringCommand(sqlCommand); db.ExecuteNonQuery(dbCommand); //Il Ruolo Administrator deve avere sempre per esso DELETE sqlCommand = @""; sqlCommand += @"UPDATE PERMESSO_ACCESSO SET PMS_ID_MODALITA_ACCESSO = (SELECT MAX(PMS_ID_MODALITA_ACCESSO) FROM PERMESSI_LOOKUP) WHERE RUL_ID_RUOLO = 1 AND FNT_ID_FUNZIONALITA=" + fnt_id_funzionalita.Value; dbCommand = db.GetSqlStringCommand(sqlCommand); db.ExecuteNonQuery(dbCommand); } catch (Exception ex) { // E' successo qualcosa di strano throw ex; } }
public static SqlChars ToStringByCpId(SqlBytes input, SqlInt64 index, SqlInt64 count, SqlInt32 cpId) { if (input.IsNull) { return(SqlChars.Null); } if (!index.IsNull && (index.Value < 0 || index > input.Length)) { throw new ArgumentOutOfRangeException("index"); } if (!count.IsNull && (count.Value < 0 || count > input.Length - (index.IsNull ? 0 : index.Value))) { throw new ArgumentOutOfRangeException("count"); } long indexValue = !index.IsNull ? index.Value : count.IsNull ? 0 : input.Length - count.Value; long countValue = !count.IsNull ? count.Value : index.IsNull ? input.Length : input.Length - index.Value; Encoding encoding = cpId.IsNull ? SqlRuntime.TextEncoding : Encoding.GetEncoding(cpId.Value); return(new SqlChars(encoding.GetChars(input.Buffer, (int)indexValue, (int)countValue))); }
/// <summary> /// Purpose: Select method. This method will Select one existing row from the database, based on the Primary Key. /// </summary> /// <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns> /// <remarks> /// Properties needed for this method: /// <UL> /// <LI>CatStatusTrasManId</LI> /// </UL> /// Properties set after a succesful call of this method: /// <UL> /// <LI>ErrorCode</LI> /// <LI>CatStatusTrasManId</LI> /// <LI>CatStatusTrasManOrden</LI> /// <LI>CatStatusTrasManDescrip</LI> /// </UL> /// Will fill all properties corresponding with a field in the table with the value of the row selected. /// </remarks> public override DataTable SelectOne() { SqlCommand cmdToExecute = new SqlCommand(); cmdToExecute.CommandText = "dbo.[sp_post_CatStatusTrasMan_SelectOne]"; cmdToExecute.CommandType = CommandType.StoredProcedure; DataTable toReturn = new DataTable("CatStatusTrasMan"); SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute); // Use base class' connection object cmdToExecute.Connection = _mainConnection; try { cmdToExecute.Parameters.Add(new SqlParameter("@iCatStatusTrasManId", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _catStatusTrasManId)); cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode)); if (_mainConnectionIsCreatedLocal) { // Open connection. _mainConnection.Open(); } else { if (_mainConnectionProvider.IsTransactionPending) { cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction; } } // Execute query. adapter.Fill(toReturn); _errorCode = (Int32)cmdToExecute.Parameters["@iErrorCode"].Value; if (_errorCode != (int)LLBLError.AllOk) { // Throw error. throw new Exception("Stored Procedure 'sp_post_CatStatusTrasMan_SelectOne' reported the ErrorCode: " + _errorCode); } if (toReturn.Rows.Count > 0) { _catStatusTrasManId = (Int32)toReturn.Rows[0]["CatStatusTrasManId"]; _catStatusTrasManOrden = (string)toReturn.Rows[0]["CatStatusTrasManOrden"]; _catStatusTrasManDescrip = (string)toReturn.Rows[0]["CatStatusTrasManDescrip"]; } return(toReturn); } catch (Exception ex) { // some error occured. Bubble it to caller and encapsulate Exception object throw new Exception("CatStatusTrasMan::SelectOne::Error occured.", ex); } finally { if (_mainConnectionIsCreatedLocal) { // Close connection. _mainConnection.Close(); } cmdToExecute.Dispose(); adapter.Dispose(); } }
public static SqlBytes FromStringByCpId([SqlFacet(MaxSize = -1)] SqlChars input, SqlInt32 cpId) { return(!input.IsNull ? new SqlBytes((!cpId.IsNull ? Encoding.GetEncoding(cpId.Value) : SqlRuntime.TextEncoding).GetBytes(input.Buffer, 0, (int)input.Length)) : SqlBytes.Null); }
public SqlInt64 GetItem(SqlInt32 index) { return(!index.IsNull && _list[index.Value].HasValue ? _list[index.Value].Value : SqlInt64.Null); }
public static SqlBytes FromInt32(SqlInt32 input) { return(!input.IsNull ? new SqlBytes(BitConverter.GetBytes(input.Value)) : SqlBytes.Null); }
public virtual void SetSqlInt32(object o, int index, SqlInt32 value) { SetValue(o, index, value); }
public static IEnumerable ReadLinesByCpId(SqlFileInfo fileInfo, SqlInt64 offset, SqlString searchTerminator, SqlString delimiter, [DefaultValue("''")] SqlString newTerminator, [DefaultValue("NULL")] SqlInt32 maxCount, SqlBoolean detectEncoding, SqlInt32 cpId) { if (fileInfo.IsNull || searchTerminator.IsNull) { yield break; } var fileEncoding = cpId.IsNull ? SqlRuntime.FileEncoding : Encoding.GetEncoding(cpId.Value); var terminatorsList = searchTerminator.IsNull || delimiter.Value.Length == 0 ? new[] { searchTerminator.Value } : searchTerminator.Value.Split(new[] { delimiter.Value }, StringSplitOptions.RemoveEmptyEntries); using (var fs = fileInfo.FileInfo.OpenRead()) { if (detectEncoding.IsTrue) { var preamble = EncodingPreamble.Detect(fs.ReadBytesMost(1, 4) ?? new byte[0]); if (preamble != null) { fileEncoding = Encoding.GetEncoding(preamble.CodePage); } else { fs.Position = 0; } } if (!offset.IsNull) { fs.Position = offset.Value; } var position = fs.Position; foreach (var line in fs.ReadLines(fileEncoding, terminatorsList, newTerminator.IsNull ? null : newTerminator.Value, maxCount.IsNull ? int.MaxValue : maxCount.Value)) { yield return(Tuple.Create(position, line)); position = fs.Position; } } }
/// <summary> /// Purpose: Select method. This method will Select one existing row from the database, based on the Primary Key. /// </summary> /// <returns>DataTable object if succeeded, otherwise an Exception is thrown. </returns> /// <remarks> /// Properties needed for this method: /// <UL> /// <LI>NRightsLevelID</LI> /// </UL> /// Properties set after a succesful call of this method: /// <UL> /// <LI>ErrorCode</LI> /// <LI>NRightsLevelID</LI> /// <LI>StrDescription</LI> /// <LI>DtLastEditDate</LI> /// <LI>NEmployeeID</LI> /// </UL> /// Will fill all properties corresponding with a field in the table with the value of the row selected. /// </remarks> public override DataTable SelectOne() { SqlCommand cmdToExecute = new SqlCommand(); cmdToExecute.CommandText = "dbo.[sp_tblRightsLevel_SelectOne]"; cmdToExecute.CommandType = CommandType.StoredProcedure; DataTable toReturn = new DataTable("tblRightsLevel"); SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute); // Use base class' connection object cmdToExecute.Connection = _mainConnection; try { cmdToExecute.Parameters.Add(new SqlParameter("@inRightsLevelID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, _nRightsLevelID)); cmdToExecute.Parameters.Add(new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, _errorCode)); if (_mainConnectionIsCreatedLocal) { // Open connection. _mainConnection.Open(); } else { if (_mainConnectionProvider.IsTransactionPending) { cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction; } } // Execute query. adapter.Fill(toReturn); _errorCode = (SqlInt32)cmdToExecute.Parameters["@iErrorCode"].Value; if (_errorCode != (int)LLBLError.AllOk) { // Throw error. throw new Exception("Stored Procedure 'sp_tblRightsLevel_SelectOne' reported the ErrorCode: " + _errorCode); } if (toReturn.Rows.Count > 0) { _nRightsLevelID = (Int32)toReturn.Rows[0]["nRightsLevelID"]; _strDescription = toReturn.Rows[0]["strDescription"] == System.DBNull.Value ? SqlString.Null : (string)toReturn.Rows[0]["strDescription"]; _dtLastEditDate = toReturn.Rows[0]["dtLastEditDate"] == System.DBNull.Value ? SqlDateTime.Null : (DateTime)toReturn.Rows[0]["dtLastEditDate"]; _nEmployeeID = (Int32)toReturn.Rows[0]["nEmployeeID"]; } return(toReturn); } catch (Exception ex) { // some error occured. Bubble it to caller and encapsulate Exception object throw new Exception("TblRightsLevel::SelectOne::Error occured.", ex); } finally { if (_mainConnectionIsCreatedLocal) { // Close connection. _mainConnection.Close(); } cmdToExecute.Dispose(); adapter.Dispose(); } }
public static IEnumerable Enumerate(SqlDirectoryInfo dirInfo, SqlString searchPattern, SqlInt32 maxDepth, SqlInt32 traversalOptions) { if (dirInfo.IsNull) { yield break; } DirectoryInfo di = dirInfo.DirectoryInfo; if (!di.Exists) { yield break; } foreach (var hfsi in di.CreateHierarchicalDirectoryInfo(null).EnumerateHierarchicalFileSystemInfos(searchPattern.IsNull ? null : searchPattern.Value, maxDepth.IsNull ? int.MaxValue : maxDepth.Value, traversalOptions.IsNull ? 0 : (FileSystemTraversalOptions)traversalOptions.Value, default(Func <FileSystemInfo, bool>), default(Comparison <FileSystemInfo>))) { yield return(hfsi); } }
public static SqlBoolean op_Explicit(SqlInt32 x) { if (x.IsNull) return SqlBoolean.Null; return new SqlBoolean(x.Value != 0); }
public static IEnumerable ReadSizedBlocks(SqlFileInfo fileInfo, SqlInt64 offset, SqlByte sizing, [DefaultValue("NULL")] SqlInt32 maxCount) { if (fileInfo.IsNull || sizing.IsNull) { yield break; } var sizeEncoding = (SizeEncoding)sizing.Value; if (sizeEncoding == SizeEncoding.NO) { yield break; } using (var fs = fileInfo.FileInfo.OpenRead()) { if (!offset.IsNull) { fs.Position = offset.Value; } var position = fs.Position; foreach (var block in fs.ReadCollection(s => s.TryReadBytes(sizeEncoding), maxCount.IsNull ? int.MaxValue : maxCount.Value)) { yield return(Tuple.Create(position, block)); position = fs.Position; } } }
public void SqlTypes_SqlInt32() { NpgsqlParameter parameter; SqlInt32 value = new SqlInt32(5); #if NET_2_0 parameter = new NpgsqlParameter (); parameter.NpgsqlValue = value; Assert.AreEqual (NpgsqlDbType.Integer, parameter.NpgsqlDbType, "#A:NpgsqlDbType"); Assert.AreEqual (value, parameter.NpgsqlValue, "#A:NpgsqlValue"); Assert.AreEqual (value, parameter.Value, "#A:Value"); parameter = new NpgsqlParameter (); parameter.NpgsqlValue = SqlInt32.Null; Assert.AreEqual (NpgsqlDbType.Integer, parameter.NpgsqlDbType, "#B:NpgsqlDbType"); Assert.AreEqual (SqlInt32.Null, parameter.NpgsqlValue, "#B:NpgsqlValue"); Assert.AreEqual (SqlInt32.Null, parameter.Value, "#B:Value"); #endif parameter = new NpgsqlParameter(); parameter.Value = value; Assert.AreEqual(NpgsqlDbType.Integer, parameter.NpgsqlDbType, "#C:NpgsqlDbType"); #if NET_2_0 Assert.AreEqual (value, parameter.NpgsqlValue, "#C:NpgsqlValue"); #endif Assert.AreEqual(value, parameter.Value, "#C:Value"); }
public static SqlInt32 BitwiseOr(SqlInt32 x, SqlInt32 y) { return (x | y); }