private void Initialize() { bomSet = new BomDataSet(AppRes.DB.Connect, null, null); productSet = new ProductDataSet(AppRes.DB.Connect, null, null); partSet = new PartDataSet(AppRes.DB.Connect, null, null); phyMainSet = new PhysicalMainDataSet(AppRes.DB.Connect, null, null); cheMainSet = new ChemicalMainDataSet(AppRes.DB.Connect, null, null); phyQuery = new PhysicalQuery(true); cheQuery = new ChemicalQuery(true); bomRec = new BomColumns(); bookmark = new GridBookmark(bomGridView); AppHelper.SetGridEvenRow(bomGridView); AppHelper.SetGridEvenRow(productGridView); AppHelper.SetGridEvenRow(partGridView); bomAreaColumn.DisplayFormat.FormatType = FormatType.Custom; bomAreaColumn.DisplayFormat.Format = new ReportAreaFormat(); bomRegTimeColumn.DisplayFormat.FormatType = FormatType.Custom; bomRegTimeColumn.DisplayFormat.Format = new ReportDateTimeFormat(); bomAreaCombo.DataSource = EnumHelper.GetNameValues <EReportArea>(); bomAreaCombo.DisplayMember = "Name"; bomAreaCombo.ValueMember = "Value"; }
public void Load(int IdProduct) { try { ProductDataSet dataset = new ProductDataSet(); ProductDataSetTableAdapters.ProductsTableAdapter TableProduct = new ProductDataSetTableAdapters.ProductsTableAdapter(); ProductDataSet.ProductsDataTable dataTable = TableProduct.GetDataProductById(IdProduct); if (dataTable.Rows.Count > 0) { ProductDataSetTableAdapters.Products_ObsTableAdapter Product_obs = new ProductDataSetTableAdapters.Products_ObsTableAdapter(); ProductDataSet.Products_ObsDataTable dataTable_Obs = Product_obs.GetDataProductr_ObsById(IdProduct); _row = (ProductDataSet.ProductsRow)dataTable.Rows[0]; RaisePropertyChanged(nameof(Name)); RaisePropertyChanged(nameof(Code)); RaisePropertyChanged(nameof(Density)); RaisePropertyChanged(nameof(MeasureUnit)); RaisePropertyChanged(nameof(Enabled)); _row_obs = (ProductDataSet.Products_ObsRow)dataTable_Obs.Rows[0]; RaisePropertyChanged(nameof(Observations)); } FormLoadFinished?.Invoke(); } catch (Exception e) { FormLoadError?.Invoke(e); } }
protected void Page_Load(object sender, EventArgs e) { // 資料庫類別 ProductRepository db = new ProductRepository(); //List<ProductModel> items = db.GetAll(); // 取得資料 ProductDataSet ds = db.ExcuteDataSet(); // 報表文件類別 ReportDocument reportdoc = new ReportDocument(); // 讀取報表檔 reportdoc.FileName = Server.MapPath("~/View/Push.rpt"); // 設定資料來源1 reportdoc.SetDataSource(ds); // 設定資料來源2 CrystalReportViewer1.ReportSource = reportdoc; // 建置報表 CrystalReportViewer1.DataBind(); // 設定文字物件 TextObject txt = (TextObject)reportdoc.ReportDefinition.ReportObjects["MyName"]; txt.Text = "Kerry"; txt.Color = System.Drawing.Color.Red; }
protected void Page_Load(object sender, EventArgs e) { // 報表文件類別 ReportDocument reportdoc = new ReportDocument(); // 讀取報表檔(建置動作改為:內容) reportdoc.Load(Server.MapPath("~/Report/Push.rpt")); // 取得資料 ProductRepository db = new ProductRepository(); ProductDataSet ds = db.ExcuteDataSet(); // 設定資料來源 reportdoc.SetDataSource(ds); // 設定報表來源 CrystalReportViewer1.ReportSource = reportdoc; // 建置報表 CrystalReportViewer1.DataBind(); // 文字物件 TextObject txt1 = (TextObject)reportdoc.ReportDefinition.ReportObjects["MyName"]; // 設定文字內容 txt1.Text = "Kerry"; // 設定文字顏色 txt1.Color = System.Drawing.Color.Blue; }
public ProductDataSet ExcuteDataSet() { ProductDataSet ds = new ProductDataSet(); DataTable dt = ds.Tables["ProductDataTable"]; string connectionString = WebConfigurationManager.ConnectionStrings["MsSqlConnectionString"].ConnectionString; string sqlStatement = "select * from Product order by ProductName asc"; using (SqlConnection conn = new SqlConnection(connectionString)) using (SqlCommand command = new SqlCommand(sqlStatement, conn)) { command.CommandType = CommandType.Text; command.CommandTimeout = 180; if (conn.State != ConnectionState.Open) { conn.Open(); } using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { DataRow dr = dt.NewRow(); dr["Id"] = Guid.Parse(reader["Id"].ToString()); dr["ProductName"] = reader["ProductName"].ToString(); dr["Price"] = Convert.ToDecimal(reader["Price"].ToString()); dr["EffectivedDate"] = Convert.ToDateTime(reader["EffectivedDate"].ToString()); dt.Rows.Add(dr); } } } return(ds); }
private void findButton_Click(object sender, EventArgs e) { ProductDataSet set = productSet; bookmark.Get(); AppHelper.ResetGridDataSource(integrationGrid); if (dateCheck.Checked == true) { set.From = fromDateEdit.Value.ToString(AppRes.csDateFormat); set.To = toDateEdit.Value.ToString(AppRes.csDateFormat); } else { set.From = ""; set.To = ""; } set.AreaNo = (EReportArea)areaCombo.SelectedValue; set.Code = itemNoEdit.Text.Trim(); set.JobNo = jobNoEdit.Text.Trim(); set.SelectByValid(); AppHelper.SetGridDataSource(integrationGrid, set); bookmark.Goto(); integrationGrid.Focus(); }
public override global::System.Data.DataSet Clone() { ProductDataSet cln = ((ProductDataSet)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { ProductDataSet ds = new ProductDataSet(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
private static bool validateDatas(string Code, string Name, bool FirstTime, ProductDataSet dataset, ProductDataSetTableAdapters.ProductsTableAdapter tableProduct) { bool validateDatas = true; if (string.IsNullOrEmpty(Code)) { MessageBox.Show("El Código no puede estar en blanco", "Campo Código", MessageBoxButton.OK, MessageBoxImage.Error); validateDatas = false; } else { if (Code.Length > 3) { MessageBox.Show("El Código no puede tener más de 3 caracteres", "Campo Código", MessageBoxButton.OK, MessageBoxImage.Error); validateDatas = false; } else { if (string.IsNullOrEmpty(Name)) { MessageBox.Show("El Nombre no puede estar en blanco", "Campo Nombre", MessageBoxButton.OK, MessageBoxImage.Error); validateDatas = false; } else { if (Name.Length > 100) { MessageBox.Show("El Nombre no puede contener más de 100 caracteres", "Campo Nombre", MessageBoxButton.OK, MessageBoxImage.Error); validateDatas = false; } else { //si es la primera vez no realizamos la validación de codigo de productos repetidos (siempre existira) if (!FirstTime) { int NumberRows = Convert.ToInt32(tableProduct.GetDataProductByCode(Code)); if (NumberRows > 0) { MessageBox.Show("El Código del producto ya existe", "Campo Código", MessageBoxButton.OK, MessageBoxImage.Error); validateDatas = false; } } } } } } return(validateDatas); }
public ChemicalQuery(bool local = false) { this.local = local; if (local == true) { MainSet = new ChemicalMainDataSet(AppRes.DB.Connect, null, null); ImageSet = new ChemicalImageDataSet(AppRes.DB.Connect, null, null); JoinSet = new ChemicalItemJoinDataSet(AppRes.DB.Connect, null, null); P2Set = new ChemicalP2DataSet(AppRes.DB.Connect, null, null); P2ExtendSet = new ChemicalP2ExtendDataSet(AppRes.DB.Connect, null, null); ProfJobSet = new ProfJobDataSet(AppRes.DB.Connect, null, null); ProfJobSchemeSet = new ProfJobSchemeDataSet(AppRes.DB.Connect, null, null); CtrlUs = null; CtrlEu = null; } productSet = new ProductDataSet(AppRes.DB.Connect, null, null); partSet = new PartDataSet(AppRes.DB.Connect, null, null); staffSet = new StaffDataSet(AppRes.DB.Connect, null, null); }
public PhysicalQuery(bool local = false) { this.local = local; if (local == true) { MainSet = new PhysicalMainDataSet(AppRes.DB.Connect, null, null); ImageSet = new PhysicalImageDataSet(AppRes.DB.Connect, null, null); P2Set = new PhysicalP2DataSet(AppRes.DB.Connect, null, null); P3Set = new PhysicalP3DataSet(AppRes.DB.Connect, null, null); P40Set = new PhysicalP40DataSet(AppRes.DB.Connect, null, null); P41Set = new PhysicalP41DataSet(AppRes.DB.Connect, null, null); P5Set = new PhysicalP5DataSet(AppRes.DB.Connect, null, null); ProfJobSet = new ProfJobDataSet(AppRes.DB.Connect, null, null); CtrlUs = null; CtrlEu = null; } else { productSet = new ProductDataSet(AppRes.DB.Connect, null, null); } }
private void Initialize() { productSet = new ProductDataSet(AppRes.DB.Connect, null, null); ctrlUs = new CtrlEditIntegrationUs(); ctrlEu = new CtrlEditIntegrationEu(); bookmark = new GridBookmark(integrationGridView); AppHelper.SetGridEvenRow(integrationGridView); integAreaColumn.DisplayFormat.FormatType = FormatType.Custom; integAreaColumn.DisplayFormat.Format = new ReportAreaFormat(); integRegTimeColumn.DisplayFormat.FormatType = FormatType.Custom; integRegTimeColumn.DisplayFormat.Format = new ReportDateTimeFormat(); areaCombo.DataSource = EnumHelper.GetNameValues <EReportArea>(); areaCombo.DisplayMember = "Name"; areaCombo.ValueMember = "Value"; SetControl(null); }
// GET: Product public ActionResult Index() { // 資料庫類別 ProductRepository db = new ProductRepository(); //List<ProductModel> items = db.GetAll(); // 取得資料 ProductDataSet ds = db.ExcuteDataSet(); // 報表文件類別 ReportClass reportdoc = new ReportClass(); // 讀取報表檔 reportdoc.FileName = Server.MapPath("~/Views/Product/ProductReport.rpt"); // 設定資料來源1 reportdoc.SetDataSource(ds); // 設定輸出楁式為PDF Stream stream = reportdoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); return(File(stream, "application/pdf")); }
// GET: Products public ActionResult Index() { // 報表文件類別 ReportClass reportdoc = new ReportClass(); // 讀取報表檔(建置動作改為:內容) reportdoc.FileName = Server.MapPath("~/Views/Products/ProductReport.rpt"); // 取得資料 ProductRepository db = new ProductRepository(); ProductDataSet ds = db.ExcuteDataSet(); // 設定資料來源 reportdoc.SetDataSource(ds); // 設定報表傳出格式 - PDF //Stream stream = reportdoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); //return File(stream, "application/pdf"); // 設定報表傳出格式 - EXCEL Stream stream = reportdoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel); return(File(stream, "application/vnd.ms-excel")); }
public ProductFormViewModel() { ProductDataSet dataset = new ProductDataSet(); ProductDataSetTableAdapters.ProductsTableAdapter Product = new ProductDataSetTableAdapters.ProductsTableAdapter(); ProductDataSetTableAdapters.Products_ObsTableAdapter Product_obs = new ProductDataSetTableAdapters.Products_ObsTableAdapter(); _row = dataset.Products.NewProductsRow(); _row_obs = dataset.Products_Obs.NewProducts_ObsRow(); //Producto _row.Code = ""; _row.Density = 0; _row.Name = ""; _row.MeasureUnit = 0; _row.ModifiedDate = DateTime.Now; _row.CreatedDate = DateTime.Now; _row.Enabled = true; _row.Id = 0; //observaciones usuasrio _row_obs.Observations = ""; SaveCommand = new RelayCommand(Save, CanSave); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); ProductDataSet ds = new ProductDataSet(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "ProductDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public void Save() { bool validate = true; int indentificadorProduct = 0; try { ProductDataSet dataset = new ProductDataSet(); ProductDataSetTableAdapters.Products_ObsTableAdapter tableAdapterProductObs = new ProductDataSetTableAdapters.Products_ObsTableAdapter(); ProductDataSetTableAdapters.ProductsTableAdapter TableProduct = new ProductDataSetTableAdapters.ProductsTableAdapter(); validate = validateDatas(_row.Code, _row.Name, this.FirstTime, dataset, TableProduct); if (validate) { ProductDataSet.ProductsDataTable dataTable = TableProduct.GetDataProductById(_row.Id); //actualizamnos si existe el registro if (dataTable.Rows.Count > 0) { var rowproduct = dataset.Products.NewProductsRow(); rowproduct = dataTable[0]; rowproduct["Code"] = _row.Code; rowproduct["Name"] = _row.Name; rowproduct["CreatedDate"] = DateTime.Now; rowproduct["ModifiedDate"] = DateTime.Now; rowproduct["Density"] = _row.Density; rowproduct["MeasureUnit"] = 1; rowproduct["Enabled"] = _row.Enabled; int numeroderegistros = TableProduct.Update(rowproduct); //si se actualizado el user actualizamos las observaciones if (numeroderegistros > 0) { //actualizamos la observacion tableAdapterProductObs.UpdateProductObs(_row_obs.Observations, _row.Id); } } //insertamos el nuevo products y las observaciones (product_obs) else { TableProduct = new ProductDataSetTableAdapters.ProductsTableAdapter(); //obtenemos de la tabla product el nuevo registro que se introducira var rowProduct = dataset.Products.NewProductsRow(); rowProduct.Code = _row.Code; rowProduct.Name = _row.Name; rowProduct.CreatedDate = DateTime.Now; rowProduct.ModifiedDate = DateTime.Now; rowProduct.Density = _row.Density; rowProduct.MeasureUnit = 1; rowProduct.Enabled = _row.Enabled; //agregamos la nueva fila dataset.Products.AddProductsRow(rowProduct); //actualizamos la tabla Products en el dataset TableProduct.Update(dataset.Products); //al insertar el registro nuevo en la tabla User Id se actualiza indentificadorProduct = Convert.ToInt32(rowProduct.Id); // a continuación insertamos el resto de datos en la tabla User_obs cepsa con el indentificador del User recient introduzido tableAdapterProductObs = new ProductDataSetTableAdapters.Products_ObsTableAdapter(); //obtenemos de la tabla User_obs el nuevo registro que se introducira var rowProduct_obs = dataset.Products_Obs.NewProducts_ObsRow(); //Id rowProduct_obs.Id = indentificadorProduct; //observations rowProduct_obs.Observations = _row_obs.Observations; //agregamos la nueva fila a tabla User_obs dataset.Products_Obs.AddProducts_ObsRow(rowProduct_obs); //actualizamos la tabla User_obs en el dataset tableAdapterProductObs.Update(dataset.Products_Obs); } FormSaveFinished?.Invoke(); } } catch (Exception e) { FormSaveError?.Invoke(e); } }
static void Main(string[] args) { // PetShop OrdersDataSet cds = new OrdersDataSet(); OrdersDataAdapter cda = new OrdersDataAdapter(); ProductDataSet pds = new ProductDataSet(); ProductDataAdapter pda = new ProductDataAdapter(); pda.FillByCategoryId(pds, "BIRDS"); Console.Out.WriteLine(cds.Orders.Rows.Count); IEnumerator en = pds.Product.GetEnumerator(); while (en.MoveNext()) { ProductDataSet.ProductRow row = (ProductDataSet.ProductRow)en.Current; Console.Out.WriteLine(row.ProductId + " " + row.CategoryId + " " + row.Name + " " + row.Descn); } // fill all the records from the permission table. string[] columns = { "ShipCity", "Courier" }; string[] values = { "Nowhere", "Me" }; DbType[] types = { DbType.AnsiString, DbType.AnsiString }; cda.Fill(cds, columns, values, types); Console.Out.WriteLine(cds.Orders.Rows.Count); Console.Out.WriteLine(cds.Orders.FindByOrderId(1) != null ? cds.Orders.FindByOrderId(1).OrderId.ToString() : "Nope"); Console.Out.WriteLine(cds.Orders.FindByOrderId(4) != null ? cds.Orders.FindByOrderId(4).OrderId.ToString() : "Nope"); Console.In.Read(); cds.Clear(); cda.Fill(cds); OrdersDataSet.OrdersRow newRow = cds.Orders.NewOrdersRow(); newRow.OrderDate = DateTime.Now; newRow.ShipAddr1 = "2001 Nowhere"; newRow.ShipCity = "Nowhere"; newRow.ShipState = "Tx"; newRow.ShipZip = "12345"; newRow.UserId = "joe"; newRow.ShipCountry = "USA"; newRow.BillAddr1 = "2001 UHUH"; newRow.BillCity = "Nowhere"; newRow.BillState = "Tx"; newRow.BillZip = "12345"; newRow.UserId = "yoyDu"; newRow.BillCountry = "USA"; newRow.Courier = "Me"; newRow.TotalPrice = 12.12M; newRow.BillToFirstName = "Yaba"; newRow.BillToLastName = "Daba"; newRow.ShipToFirstName = "Yoko"; newRow.ShipToLastName = "Ono"; newRow.AuthorizationNumber = 123; newRow.Locale = "Here"; cds.Orders.AddOrdersRow(newRow); Console.In.Read(); // make some changes and save //OrdersDataSet.OrdersRow editRow = cds.Orders.FindByOrderId(19); //editRow.BillZip = "33333"; //editRow.Courier = "USPS"; cda.Update(cds); //Console.In.Read(); //// reset changes and save //Console.In.Read(); //// Delete row and update //OrdersDataSet.OrdersRow deleteRow = cds.Orders.FindByOrderId(20); //deleteRow.Delete(); //cda.Update(cds); //Console.In.Read(); }