protected void Button1Click(object sender, DirectEventArgs e) { SpacialDataSet sd = new SpacialDataSet(); sd.vehicule = vehicule.Text; sd.dateDepart = DateTime.Parse(dateDepart.Text) + TimeSpan.Parse(HD.Text); sd.dateArivee = DateTime.Parse(dateArivee.Text) + TimeSpan.Parse(HA.Text); if (pm.Checked == true) { SqlGeometry sqlG = SqlGeometry.Parse(trajet.Text); sd.trajet = DbGeometry.FromBinary(sqlG.STAsBinary().Buffer); } else if (pm.Checked == false) { SqlGeometry sqlG = SqlGeometry.Parse(trajet.Text); sd.trajet = DbGeometry.FromBinary(sqlG.STAsBinary().Buffer); } sd.active = (bool?)SqlBoolean.Parse(active.Text); db = new demoDB(); db.SpacialDataSets.Add(sd); db.SaveChanges(); X.Msg.Alert("INFO", "l'opération a été effectuée avec succès").Show(); ResetInputs(); Store1.Reload(); X.Call("resetMap"); }
public override Expression Build() { object value = null; switch (_typeName) { case ("SqlBoolean"): value = SqlBoolean.Parse(_stringValue); break; case ("SqlInt32"): value = SqlInt32.Parse(_stringValue); break; case ("SqlString"): value = new SqlString(_stringValue); break; case ("SqlDouble"): value = SqlDouble.Parse(_stringValue); break; case ("SqlDateTime"): value = SqlDateTime.Parse(_stringValue); break; } Expression result = Expression.Constant(value, typeof(object)); return(result); }
public void Parse() { Assert.True(SqlBoolean.Parse("True").Value); Assert.True(SqlBoolean.Parse(" True").Value); Assert.True(SqlBoolean.Parse("True ").Value); Assert.True(SqlBoolean.Parse("tRuE").Value); Assert.False(SqlBoolean.Parse("False").Value); Assert.False(SqlBoolean.Parse(" False").Value); Assert.False(SqlBoolean.Parse("False ").Value); Assert.False(SqlBoolean.Parse("fAlSe").Value); }
public void Parse() { String error = "Parse method does not work correctly "; Assert.IsTrue(SqlBoolean.Parse("True").Value, "#1 " + error); Assert.IsTrue(SqlBoolean.Parse(" True").Value, "#2 " + error); Assert.IsTrue(SqlBoolean.Parse("True ").Value, "#3 " + error); Assert.IsTrue(SqlBoolean.Parse("tRuE").Value, "#4 " + error); Assert.IsTrue(!SqlBoolean.Parse("False").Value, "#5 " + error); Assert.IsTrue(!SqlBoolean.Parse(" False").Value, "#6 " + error); Assert.IsTrue(!SqlBoolean.Parse("False ").Value, "#7 " + error); Assert.IsTrue(!SqlBoolean.Parse("fAlSe").Value, "#8 " + error); }
public void Parse() { string error = "Parse method does not work correctly "; Assert.True(SqlBoolean.Parse("True").Value); Assert.True(SqlBoolean.Parse(" True").Value); Assert.True(SqlBoolean.Parse("True ").Value); Assert.True(SqlBoolean.Parse("tRuE").Value); Assert.True(!SqlBoolean.Parse("False").Value); Assert.True(!SqlBoolean.Parse(" False").Value); Assert.True(!SqlBoolean.Parse("False ").Value); Assert.True(!SqlBoolean.Parse("fAlSe").Value); }
/// <summary> /// Converts the specified <see cref="System.String"/> representation of a logical value /// to its <see cref="PBoolean"/> equivalent. /// </summary> /// <param name="s"> /// The <see cref="System.String"/> to be converted. /// </param> /// <param name="type"></param> /// <returns> /// An <see cref="PBoolean"/> structure containing the parsed value. /// </returns> public static PBoolean Parse(string s, PValueType type) { PBoolean sp; if (string.IsNullOrEmpty(s)) { sp = new PBoolean(type); } else { sp = SqlBoolean.Parse(s); } return(sp); }
protected virtual SqlBoolean GetUnderlyingValue(Object dataItem) { SqlBoolean underlyingValue; object dataItemDescriptorValue = dataItem; if (this.boundFieldDesc != null) { dataItemDescriptorValue = this.boundFieldDesc.GetValue(dataItem); } try { underlyingValue = SqlBoolean.Parse(dataItemDescriptorValue.ToString()); } catch { underlyingValue = SqlBoolean.Null; } return(underlyingValue); }
protected void ButtonSubmit_OnClick(object sender, EventArgs e) { searchBid.FullName = fullname.Value; searchBid.Email = email.Value; searchBid.ConfirmInvestments = SqlBoolean.Parse(confirminvestments.Checked.ToString()); searchBid.ConfirmServices = SqlBoolean.Parse(confirmservices.Checked.ToString()); searchBid.RequiredRevenue = decimal.Parse(requirerevenue.Value); searchBid.RequiredRevenueExplanation = requirerevenueexplanation.Value; searchBid.AncillaryServices = ancillaryservices.Value; searchBid.SaveRecordToDatabase(new Guid("17F6FCEB-CF02-E411-9726-D8D385C29900")); foreach (RepeaterItem item in RepeaterSearchQuestions.Items) { HiddenField hiddenField = (HiddenField)item.FindControl("SearchQuestionId"); SearchQuestion searchQuestion = new SearchQuestion(new Guid(hiddenField.Value.ToString())); SearchBidQuestion searchBidQuestion = searchBidQuestions.Find(x => x.SearchQuestionId == searchQuestion.Id); CheckBox checkBox = (CheckBox)item.FindControl("SearchQuestionAnswer"); searchBidQuestion.AnswerValue = SqlBoolean.Parse(checkBox.Checked.ToString()); searchBidQuestion.SaveRecordToDatabase(new Guid("17F6FCEB-CF02-E411-9726-D8D385C29900")); } }
private void btnSave_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(cboIsFinalist.Text)) { CurrentSearchBid.IsFinalist = null; } else { CurrentSearchBid.IsFinalist = SqlBoolean.Parse(cboIsFinalist.Text.ToLower()); } if (String.IsNullOrWhiteSpace(cboIsRecommended.Text)) { CurrentSearchBid.IsRecommended = null; } else { CurrentSearchBid.IsRecommended = SqlBoolean.Parse(cboIsRecommended.Text.ToLower()); } CurrentSearchBid.Notes = txtNotes.Text; CurrentSearchBid.SaveRecordToDatabase(frmMain_Parent.CurrentUser.UserId); this.Close(); }
public static SqlBooleanRegularArray Parse(SqlString s) { if (s.IsNull) { return(Null); } return(new SqlBooleanRegularArray(SqlFormatting.ParseRegular <Boolean?>(s.Value, t => !t.Equals(SqlFormatting.NullText, StringComparison.InvariantCultureIgnoreCase) ? SqlBoolean.Parse(t).Value : default(Boolean?)))); }
private void LoadDgvServices(bool refresh = false) { int currentCellRow = 0; int currentCellCol = 0; if (dgvServices.CurrentCell != null) { currentCellRow = dgvServices.CurrentCell.RowIndex; currentCellCol = dgvServices.CurrentCell.ColumnIndex; } DataTable dataTable = new DataTable(); /// Set the datatable based on the SelectedIndex of <see cref="cboServicesView"/>. /*switch (cboServicesView.SelectedIndex) * { * case 0: * dataTable = Service.GetActive(); * break; * case 1: * dataTable = Service.GetInactive(); * break; * default: * return; * }*/ switch (cboServicesView.SelectedIndex) { case 0: dataTable = ProductService.GetAssociatedOfferedActive(new Product(CurrentPlanRecordKeeperProduct.ProductId)); break; case 1: dataTable = ProductService.GetAssociatedOfferedInactive(new Product(CurrentPlanRecordKeeperProduct.ProductId)); break; default: return; } dataTable = dataTable.AsEnumerable().Where(x => x["Type"].ToString() == "Record Keeper").CopyToDataTable(); //dataTable.Columns.Add("ServiceOffered", typeof(bool)); dataTable.Columns.Add("Notes"); dgvServices.DataSource = dataTable; // Display/order the columns. dgvServices.Columns["ServiceId"].Visible = false; dgvServices.Columns["Type"].Visible = false; dgvServices.Columns["CreatedBy"].Visible = false; dgvServices.Columns["CreatedOn"].Visible = false; dgvServices.Columns["ModifiedBy"].Visible = false; dgvServices.Columns["ModifiedOn"].Visible = false; dgvServices.Columns["StateCode"].Visible = false; dgvServices.Columns["ServiceId1"].Visible = false; dgvServices.Columns["ProductId"].Visible = false; dgvServices.Columns["ProductServiceId"].Visible = false; dgvServices.Columns["CreatedBy1"].Visible = false; dgvServices.Columns["CreatedOn1"].Visible = false; dgvServices.Columns["ModifiedBy1"].Visible = false; dgvServices.Columns["ModifiedOn1"].Visible = false; dgvServices.Columns["StateCode1"].Visible = false; dgvServices.Columns["Name"].DisplayIndex = 0; dgvServices.Columns["Name"].ReadOnly = true; dgvServices.Columns["Category"].DisplayIndex = 1; dgvServices.Columns["Category"].ReadOnly = true; dgvServices.Columns["ServiceOffered"].DisplayIndex = 2; dgvServices.Columns["ServiceOffered"].ReadOnly = false; dgvServices.Columns["Notes"].DisplayIndex = 3; dgvServices.Columns["Notes"].ReadOnly = false; // set service offered values if (refresh == true) { DataTable planRkPdServices = PlanRecordKeeperProductService.GetAssociated(CurrentPlanRecordKeeperProduct); //foreach (DataGridViewRow drServices in dgvServices.Rows) for (int rowIndex = 0; rowIndex < dgvServices.Rows.Count; rowIndex++) { DataGridViewRow drServices = dgvServices.Rows[rowIndex]; Guid serviceId = new Guid(drServices.Cells["ServiceId"].Value.ToString()); var ps = planRkPdServices.AsEnumerable().Where(x => x.Field <Guid>("ServiceId") == serviceId); if (ps.Any()) // rk product already has service record, so update it { DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)drServices.Cells["ServiceOffered"]; var serviceOffered = SqlBoolean.Parse(ps.CopyToDataTable().Rows[0]["ServiceOffered"].ToString()).IsTrue; drServices.Cells["ServiceOffered"].Value = serviceOffered.ToString(); var notes = ps.CopyToDataTable().Rows[0]["Notes"].ToString(); drServices.Cells["Notes"].Value = notes; } } } if (dgvServices.RowCount > 0 && dgvServices.ColumnCount > 0) { DataGridViewCell selectedCell = dgvServices.Rows[currentCellRow].Cells[currentCellCol]; if (selectedCell != null && selectedCell.Visible) { dgvServices.CurrentCell = selectedCell; } else { dgvServices.CurrentCell = dgvServices.FirstDisplayedCell; } } }
public static PBoolean Parse(string s, PValueType type) => string.IsNullOrEmpty(s) ? new PBoolean(type) : SqlBoolean.Parse(s);
public override object Parse(ColumnTypeInfo colTypeInfo, object sourceValue) { Debug.Assert(sourceValue != null); return(SqlBoolean.Parse(sourceValue.ToString())); }
private void LoadDgvServices(bool refresh = false) { int currentCellRow = 0; int currentCellCol = 0; if (dgvServices.CurrentCell != null) { currentCellRow = dgvServices.CurrentCell.RowIndex; currentCellCol = dgvServices.CurrentCell.ColumnIndex; } DataTable dataTable = new DataTable(); /// Set the datatable based on the SelectedIndex of <see cref="cboServicesView"/>. switch (cboServicesView.SelectedIndex) { case 0: dataTable = Service.GetActive(); break; case 1: dataTable = Service.GetInactive(); break; default: return; } dataTable = dataTable.AsEnumerable().Where(x => x["Type"].ToString() == "Record Keeper").CopyToDataTable(); dataTable.Columns.Add("ServiceRequired", typeof(bool)); dataTable.Columns.Add("ServicePreferred", typeof(bool)); dataTable.Columns.Add("ServiceOptional", typeof(bool)); dgvServices.DataSource = dataTable; // Display/order the columns. dgvServices.Columns["ServiceId"].Visible = false; dgvServices.Columns["Type"].Visible = false; dgvServices.Columns["CreatedBy"].Visible = false; dgvServices.Columns["CreatedOn"].Visible = false; dgvServices.Columns["ModifiedBy"].Visible = false; dgvServices.Columns["ModifiedOn"].Visible = false; dgvServices.Columns["StateCode"].Visible = false; dgvServices.Columns["Name"].DisplayIndex = 0; dgvServices.Columns["Name"].ReadOnly = true; dgvServices.Columns["Category"].DisplayIndex = 1; dgvServices.Columns["Category"].ReadOnly = true; dgvServices.Columns["ServiceRequired"].DisplayIndex = 2; dgvServices.Columns["ServiceRequired"].ReadOnly = false; dgvServices.Columns["ServicePreferred"].DisplayIndex = 3; dgvServices.Columns["ServicePreferred"].ReadOnly = false; dgvServices.Columns["ServiceOptional"].DisplayIndex = 4; dgvServices.Columns["ServiceOptional"].ReadOnly = false; // set service offered values if (refresh == true) { DataTable planRkServices = SearchService.GetAssociated(CurrentSearch); int rowIndex = 0; foreach (DataGridViewRow drServices in dgvServices.Rows) { Guid serviceId = new Guid(drServices.Cells["ServiceId"].Value.ToString()); var ps = planRkServices.AsEnumerable().Where(x => x.Field <Guid>("ServiceId") == serviceId); if (ps.Any()) // rk product already has service record, so update it { var serviceRequired = SqlBoolean.Parse(ps.CopyToDataTable().Rows[0]["ServiceRequired"].ToString()).IsTrue; dgvServices.Rows[rowIndex].Cells["ServiceRequired"].Value = serviceRequired.ToString(); var servicePreferred = SqlBoolean.Parse(ps.CopyToDataTable().Rows[0]["ServicePreferred"].ToString()).IsTrue; dgvServices.Rows[rowIndex].Cells["ServicePreferred"].Value = servicePreferred.ToString(); var serviceOptional = SqlBoolean.Parse(ps.CopyToDataTable().Rows[0]["ServiceOptional"].ToString()).IsTrue; dgvServices.Rows[rowIndex].Cells["ServiceOptional"].Value = serviceOptional.ToString(); } rowIndex++; } } if (dgvServices.RowCount > 0 && dgvServices.ColumnCount > 0) { DataGridViewCell selectedCell = dgvServices.Rows[currentCellRow].Cells[currentCellCol]; if (selectedCell != null && selectedCell.Visible) { dgvServices.CurrentCell = selectedCell; } else { dgvServices.CurrentCell = dgvServices.FirstDisplayedCell; } } }
public static SqlBoolean InitMethod([SqlFacet(MaxSize = -1)] SqlString sqlDataValue, SqlString sqlDataType) { String dataValue = sqlDataValue.ToString().Trim(); String dataType = sqlDataType.ToString().Trim(); GroupCollection typeGroups = splitType.Match(dataType).Groups; String typeText = typeGroups["type"].Value; String typePrecision = typeGroups["precision"].Value; String typeScale = typeGroups["scale"].Value; try { switch (typeText.ToLower()) { case "bit": SqlBoolean.Parse(dataValue); break; case "tinyint": SqlByte.Parse(dataValue); break; case "smallint": SqlInt16.Parse(dataValue); break; case "int": SqlInt32.Parse(dataValue); break; case "bigint": SqlInt64.Parse(dataValue); break; case "smallmoney": if (NumberOfDecimals(dataValue) > 4) { throw new OverflowException(); } SqlMoney smallmoneyValue = SqlMoney.Parse(dataValue); if (SqlMoney.LessThan(smallmoneyValue, smallmoneyMinValue) || SqlMoney.GreaterThan(smallmoneyValue, smallmoneyMaxValue)) { throw new OverflowException(); } break; case "money": if (NumberOfDecimals(dataValue) > 4) { throw new OverflowException(); } SqlMoney.Parse(dataValue); break; case "decimal": case "numeric": if (NumberOfDecimals(dataValue) > Convert.ToInt32(typeScale)) { throw new OverflowException(); } SqlDecimal.Parse(dataValue); break; case "real": SqlSingle singleValue = SqlSingle.Parse(dataValue); if (singleValue.ToString().Length != dataValue.Length + (NumberOfWholes(dataValue) == 0 ? 1 : 0)) { throw new OverflowException(); } break; case "float": SqlDouble doubleValue = SqlDouble.Parse(dataValue); if (doubleValue.ToString().Length != dataValue.Length + (NumberOfWholes(dataValue) == 0 ? 1 : 0)) { throw new OverflowException(); } break; case "date": case "datetime": case "datetime2": SqlDateTime.Parse(dataValue); break; case "char": case "varchar": case "nchar": case "nvarchar": if (typePrecision != "max" && dataValue.Length > Convert.ToInt32(typePrecision)) { throw new OverflowException(); } break; case "uniqueidentifier": SqlGuid.Parse(dataValue); break; case "geometry": SqlGeometry.Parse(dataValue); break; case "geography": SqlGeography.Parse(dataValue); break; // we do not handle these at this time case "xml": case "time": case "datetimeoffset": case "hierarchyid": case "image": case "text": case "ntext": case "rowversion": case "sql_variant": case "table": case "timestamp": case "varbinary": default: break; } return(SqlBoolean.True); } catch { return(SqlBoolean.False); } }
public override object FromStringValue(string xml) { return(SqlBoolean.Parse(xml)); }
private void LoadDgvServices(bool refresh = false) { DataTable dataTable = new DataTable(); /// Set the datatable based on the SelectedIndex of <see cref="cboServicesView"/>. switch (cboServicesView.SelectedIndex) { case 0: dataTable = Service.GetActive(); break; case 1: dataTable = Service.GetInactive(); break; default: return; } dataTable = dataTable.AsEnumerable().Where(x => x["Type"].ToString() == "Advisor").CopyToDataTable(); dataTable.Columns.Add("ServiceOffered", typeof(bool)); dgvServices.DataSource = dataTable; // Display/order the columns. dgvServices.Columns["ServiceId"].Visible = false; dgvServices.Columns["Type"].Visible = false; dgvServices.Columns["CreatedBy"].Visible = false; dgvServices.Columns["CreatedOn"].Visible = false; dgvServices.Columns["ModifiedBy"].Visible = false; dgvServices.Columns["ModifiedOn"].Visible = false; dgvServices.Columns["StateCode"].Visible = false; dgvServices.Columns["Name"].DisplayIndex = 0; dgvServices.Columns["Name"].ReadOnly = true; dgvServices.Columns["Category"].DisplayIndex = 1; dgvServices.Columns["Category"].ReadOnly = true; dgvServices.Columns["ServiceOffered"].DisplayIndex = 2; dgvServices.Columns["ServiceOffered"].ReadOnly = false; // set service offered values if (refresh == true) { DataTable planAdvisorServices = AdvisorService.GetAssociated(CurrentPlanAdvisor); int rowIndex = 0; foreach (DataGridViewRow drServices in dgvServices.Rows) { Guid serviceId = new Guid(drServices.Cells["ServiceId"].Value.ToString()); var ps = planAdvisorServices.AsEnumerable().Where(x => x.Field <Guid>("ServiceId") == serviceId); if (ps.Any()) // rk product already has service record, so update it { DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)dgvServices.Rows[rowIndex].Cells["ServiceOffered"]; var serviceOffered = SqlBoolean.Parse(ps.CopyToDataTable().Rows[0]["ServiceOffered"].ToString()).IsTrue; dgvServices.Rows[rowIndex].Cells["ServiceOffered"].Value = serviceOffered.ToString(); } rowIndex++; } } }
private bool CheckColumnValue(ref StringBuilder value) { long curline = lines + 1; if (value.Length == 0 || value.ToString().ToUpper() == globals.nullstr) { if (globals.Columns[curcol].Nullable == true) { return(true); } else { return(false); } } switch (globals.Columns[curcol].Type) { case "char": case "nchar": case "varchar": case "nvarchar": if (globals.Columns[curcol].Length != -1 && value.Length > globals.Columns[curcol].Length) { return(OutputValueErrMsg(ref value, "String truncation", "\0x1A")); } break; case "int": try { SqlInt32 i = SqlInt32.Parse(value.ToString()); } catch (Exception e) { return(OutputValueErrMsg(ref value, e.Message, "-28")); } break; case "bigint": try { SqlInt64 i = SqlInt64.Parse(value.ToString()); } catch (Exception e) { return(OutputValueErrMsg(ref value, e.Message, "-28")); } break; case "tinyint": try { SqlByte i = SqlByte.Parse(value.ToString()); } catch (Exception e) { return(OutputValueErrMsg(ref value, e.Message, "28")); } break; case "smallint": try { SqlInt16 i = SqlInt16.Parse(value.ToString()); } catch (Exception e) { return(OutputValueErrMsg(ref value, e.Message, "-28")); } break; case "numeric": case "decimal": try { // SqlDecimal d = SqlDecimal.Parse(value.ToString()); // for very large values this may work, while .Net decimal overflows decimal d = decimal.Parse(value.ToString()); // the DataTable uses .Net types, so overflows will cause exceptions in outer loop } catch (Exception e) { return(OutputValueErrMsg(ref value, e.Message, "-28.28")); } break; case "float": case "real": try { SqlSingle s = SqlSingle.Parse(value.ToString()); } catch (Exception e) { return(OutputValueErrMsg(ref value, e.Message, "-28.28")); } break; case "datetime": case "datetime2": case "smalldatetime": try { if (Convert.ToInt32(value.ToString().Substring(0, 4)) < (globals.Columns[curcol].Type == "datetime" ? 1753 : (globals.Columns[curcol].Type == "datetime2" ? 1 : 1900))) { return(OutputValueErrMsg(ref value, "Year value is too small", null)); } int dot = value.ToString().IndexOf("."); if (dot > 0) // fractional seconds given? { if (globals.Columns[curcol].Type == "smalldatetime") // strip fractional seconds off smalldatetime { string tmp = value.ToString(); value.Clear(); value.Append(tmp.Substring(0, tmp.IndexOf('.'))); } else { if (value.Length - dot > 3) { string tmp = value.ToString(); value.Clear(); value.Append(tmp.Substring(0, dot + 3)); // limitation here is .NET datetime - in theory this could be a datetime2(1), which would fail... } } } SqlDateTime dt = SqlDateTime.Parse(value.ToString()); } catch (Exception e) { return(OutputValueErrMsg(ref value, e.Message, null)); } break; case "date": case "time": try { DateTime d = DateTime.Parse(value.ToString()); } catch (Exception e) { return(OutputValueErrMsg(ref value, e.Message, null)); } break; case "uniqueidentifier": try { SqlGuid u = SqlGuid.Parse(value.ToString()); } catch (Exception e) { return(OutputValueErrMsg(ref value, e.Message, "00000000-0000-0000-0000-000000000000")); } break; case "bit": try { SqlBoolean u = SqlBoolean.Parse(value.ToString()); } catch (Exception e) { return(OutputValueErrMsg(ref value, e.Message, "0")); } break; } return(true); }