Example #1
0
        private void btnDA_Click(object sender, EventArgs e)
        {
            var ds  = new AWDataSet();
            var dta = new ProductTableAdapter();

            dta.Adapter.SelectCommand = new SqlCommand("SELECT ProductID, Name, ProductNumber, MakeFlag, FinishedGoodsFlag, Color, SafetyStockLevel, ReorderPoint, StandardCost, ListPrice, Size, SizeUnitMeasureCode, WeightUnitMeasureCode, Weight, DaysToManufacture, ProductLine, Class, Style, ProductSubcategoryID, ProductModelID, SellStartDate, SellEndDate, DiscontinuedDate, rowguid, ModifiedDate FROM Production.Product where ProductSubcategoryID is not null");
            dta.Fill(ds.Product);
            consola.Text = "";
            foreach (var rslt in ds.Product
                     .Where(p => p.ProductSubcategoryID == int.Parse(productCategoryIDLabel1.Text))
                     .Take(10)
                     .Select(p => new { id = p.ProductID, nombre = p.Name })
                     )
            {
                consola.Text += $"{rslt.id}\t{rslt.nombre}\n";
            }
            //ds.Product.AddProductRow()
//            var ds = new AWDataSet();
//            var dta = new ProductTableAdapter();
//            var dt = new DataTable();
//            var da = new SqlDataAdapter("SELECT ProductID, Name, ProductNumber, MakeFlag, FinishedGoodsFlag, Color, SafetyStockLevel, ReorderPoint, StandardCost, ListPrice, Size, SizeUnitMeasureCode, WeightUnitMeasureCode, Weight, DaysToManufacture, ProductLine, Class, Style, ProductSubcategoryID, ProductModelID, SellStartDate, SellEndDate, DiscontinuedDate, rowguid, ModifiedDate FROM Production.Product where ProductSubcategoryID is not null",
//                Settings.Default.AWConnectionString
//                );
//            da.Fill(dt);
//            consola.Text = "";
//            foreach(DataRow rslt in dt.Rows
//                //.Where(p => p.ProductSubcategoryID == int.Parse(productCategoryIDLabel1.Text))
//                //.Take(10)
//                //.Select(p => new { id = p.ProductID, nombre = p.Name})
//                ) {
//                    consola.Text += $"{rslt[0]}\t{rslt[1]}\n";
////                    consola.Text += $"{rslt.id}\t{rslt.nombre}\n";
//            }
//            //ds.Product.AddProductRow()
        }
Example #2
0
        private void FormProduct_Load(object sender, EventArgs e)
        {
            string        conn_str = "Server=.;Database=MiniMart;Integrated Security=true;";
            SqlConnection conn     = new SqlConnection(conn_str);

            cate_adapter            = new CategoryTableAdapter();
            cate_adapter.Connection = conn;
            cate_adapter.Fill(invent.Category);

            unit_adapter            = new UnitTypeTableAdapter();
            unit_adapter.Connection = conn;
            unit_adapter.Fill(invent.UnitType);

            pro_adapter            = new ProductTableAdapter();
            pro_adapter.Connection = conn;
            pro_adapter.Fill(invent.Product);

            //bind to controls
            cboCategory.DisplayMember = invent.Category.NameColumn.ColumnName;
            cboCategory.ValueMember   = invent.Category.IDColumn.ColumnName;
            cboCategory.DataSource    = invent.Category;

            cboUnitType.DisplayMember = invent.UnitType.NameColumn.ColumnName;
            cboUnitType.ValueMember   = invent.UnitType.IDColumn.ColumnName;
            cboUnitType.DataSource    = invent.UnitType;

            dataGridView1.DataSource = invent.Product;
            (dataGridView1.Columns[invent.Product.ImageColumn.ColumnName]  as DataGridViewImageColumn).ImageLayout = DataGridViewImageCellLayout.Zoom;

            lblTotal.Text = "Total: " + invent.Product.Rows.Count.ToString();
        }
        // this class is used to create objects from the data in the database, using the dataset
        private DatabaseController()
        {
            this.DataSet                     = new KantoorInrichtingDataSet();
            this.TableAdapterManager         = new KantoorInrichtingDataSetTableAdapters.TableAdapterManager();
            this.CategoryTableAdapter        = new KantoorInrichtingDataSetTableAdapters.categoryTableAdapter();
            this.ProductTableAdapter         = new KantoorInrichtingDataSetTableAdapters.productTableAdapter();
            this.PlacementTableAdapter       = new KantoorInrichtingDataSetTableAdapters.placementTableAdapter();
            this.RoleTableAdapter            = new KantoorInrichtingDataSetTableAdapters.roleTableAdapter();
            this.SpaceTableAdapter           = new KantoorInrichtingDataSetTableAdapters.spaceTableAdapter();
            this.StaticPlacementTableAdapter = new KantoorInrichtingDataSetTableAdapters.static_placementTableAdapter();
            this.StaticProductTableAdapter   = new KantoorInrichtingDataSetTableAdapters.static_productTableAdapter();
            this.UserTableAdapter            = new KantoorInrichtingDataSetTableAdapters.userTableAdapter();

            CategoryTableAdapter.Fill(DataSet.category);
            ProductTableAdapter.Fill(DataSet.product);
            PlacementTableAdapter.Fill(DataSet.placement);
            RoleTableAdapter.Fill(DataSet.role);
            SpaceTableAdapter.Fill(DataSet.space);
            StaticPlacementTableAdapter.Fill(DataSet.static_placement);
            StaticProductTableAdapter.Fill(DataSet.static_product);
            UserTableAdapter.Fill(DataSet.user);


            GetCategories_FromDatabase();
            GetProducts_FromDatabase();
            GetStaticProducts_FromDatabase();
            GetSpaces_FromDatabase();
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)  //if not logged in
            {
                Response.Redirect("/");
            }

            receiptID = Request.QueryString["ID"];
            if (receiptID == null)
            {
                Response.Redirect("~/Sales/");
            }

            try
            {
                dsSales.Clear();
                daReceipt.Fill(dsSales.Receipt);
                daCustomerInfo.Fill(dsSales.CustomerInfo);
                daEmployeeNames.Fill(dsSales.EmployeeName);
                daOL.Fill(dsSales.OrderLine);
                daServiceOrder.Fill(dsSales.ServiceOrder);
                daInventory.Fill(dsSales.Inventory);
                daProduct.Fill(dsSales.Product);
                daPayment.Fill(dsSales.Payment);
                daService.Fill(dsSales.Service);
                daEquipmentModel.Fill(dsSales.EquipmentModel);
                sale = dsSales.Receipt.FindByid(Convert.ToInt32(receiptID));
            }
            catch (Exception ex)
            {
                //prompt users the failure
                return;
            }

            if (sale == null)
            {
                lblTitle.Text   = "Record Not Found";
                pnlInfo.Visible = false;
                return;
            }

            if (Request.QueryString["Delete"] == "1" && User.IsInRole("Admin"))
            {
                pnlDeleteConfirm.Visible = true;
                lblTitle.Text            = "Delete Sale";
            }

            DisplayCustomer();
            DisplaySale();
            DisplayOrders();
            DisplayRepairs();
        }
Example #5
0
 private void Form1_Load(object sender, EventArgs e)
 {
     BalanceTableAdapter.Fill(stockDataSet.Остатки);
     TaxingTableAdapter.Fill(stockDataSet.Таксировка);
     TaxTableAdapter.Fill(stockDataSet.Налоги);
     BankTableAdapter.Fill(stockDataSet.Банк);
     OrganizationTableAdapter.Fill(stockDataSet.Организация);
     InvoiceTableAdapter.Fill(stockDataSet.Накладные);
     MoveProductTableAdapter.Fill(stockDataSet.Движение_товара);
     DivisionsTableAdapter.Fill(stockDataSet.Подразделения);
     ProductTableAdapter.Fill(stockDataSet.Товар);
     CategoryTableAdapter.Fill(stockDataSet.Категории_товара);
 }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)  //if not logged in
            {
                Response.Redirect("/");
            }

            if (String.IsNullOrEmpty(Request.QueryString["ID"]))
            {
                Response.Redirect("/Inventory");
            }

            try
            {
                dsInventory.Clear();
                daInventory.Fill(dsInventory.Inventory);
                daInvLookUp.Fill(dsInventory.InventoryLookUp);
                daProduct.Fill(dsInventory.Product);
            }
            catch { }

            if (IsPostBack)
            {
                return;
            }

            try
            {
                id = Convert.ToInt32(Request.QueryString["ID"]);
                DataRow ServiceOrder = dsInventory.InventoryLookUp.FindByid(id); // Find the related Record and fill the fields in the page with the data

                txtDescription.Text = ServiceOrder.ItemArray[6].ToString();
                txtQuantity.Text    = ServiceOrder.ItemArray[1].ToString();
                txtPrice.Text       = ServiceOrder.ItemArray[3].ToString();
                txtBrand.Text       = ServiceOrder.ItemArray[5].ToString();

                txtSize.Text = ServiceOrder.ItemArray[2].ToString();

                ddlMeasures.SelectedValue = ServiceOrder.ItemArray[8].ToString();
                ddlProducts.SelectedValue = ServiceOrder.ItemArray[0].ToString();
            }
            catch (Exception)
            {
                lblMessage.Text    = "Unable to load data";
                lblMessage.Visible = true;
            }
        }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)  //if not logged in
            {
                Response.Redirect("/");
            }

            if (this.IsPostBack)
            {
                return;
            }
            InventoryLookUpTableAdapter daInventory = new InventoryLookUpTableAdapter();
            ProductTableAdapter         daProduct   = new ProductTableAdapter();

            daInventory.Fill(dsInventory.InventoryLookUp);
            daProduct.Fill(dsInventory.Product);
        }
Example #8
0
        private static void ADOShowProducts()
        {
            int    counter      = 0;
            string prompt_input = "";

            if (DataADO.Product.Rows.Count == 0)
            {
                using (ProductTableAdapter ProdTabAdpt = new ProductTableAdapter())
                {
                    ProdTabAdpt.Fill(DataADO.Product);
                }
            }

            foreach (ADOM9Dataset.ProductRow Producto in DataADO.Product.Rows)
            {
                Console.WriteLine("ID: {0} " +
                                  "- Nombre producto {1}",
                                  Producto.ProductID,
                                  Producto.IsNull("Name") ? "----" : Producto.Name);
                counter++;

                if (counter % 10 == 0)
                {
                    Console.Write("Introduzca X para salir. Si quiere 10 elementos siguientes, pulse una tecla: ");
                    prompt_input = Console.ReadLine();

                    if (prompt_input.ToLower() == "x")
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }
Example #9
0
        private static void ADOAddQuoteDetail(int OrdHeaderID)
        {
            int     ProdID    = 0;
            short   ProdQty   = 0;
            decimal ProdPrice = 0M;

            ADOM9Dataset.SalesOrderDetailRow Row;
            //ADOM9Dataset.SalesOrderHeaderRow HeaderRow;

            //Creamos fila vacía con configuraciones a partir de definición de tabla.
            Row = DataADO.SalesOrderDetail.NewSalesOrderDetailRow();
            //Console.WriteLine("Estado de fila recien creada: {0}", Row.RowState);

            //Relacionamos el pedido y datos por defecto.
            Row.SalesOrderID = OrdHeaderID;

            //Restriccion clave compuesta producto y descuento producto

            /*ALTER TABLE [Sales].[SalesOrderDetail]  WITH CHECK
             * ADD  CONSTRAINT [FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID] FOREIGN KEY([SpecialOfferID], [ProductID])
             * REFERENCES [Sales].[SpecialOfferProduct] ([SpecialOfferID], [ProductID])
             * GO*/

            //Implicitamente, asumimos que si no exist en la tabla de configuración de descuentos, no existira producto.
            //Por eso no peta de forma directa si metemos IDProducto mal
            Row.SpecialOfferID    = 1;
            Row.UnitPriceDiscount = 0M;
            Row.rowguid           = Guid.NewGuid();
            Row.ModifiedDate      = DateTime.Today;

            do
            {
                Console.Write("Introduzca ID producto: ");
            }while (!int.TryParse(Console.ReadLine(), out ProdID));
            Row.ProductID = ProdID;

            //Comprobación forzada de producto
            if (DataADO.Product.Rows.Count == 0)
            {
                using (ProductTableAdapter ProdTabAdpt = new ProductTableAdapter())
                {
                    ProdTabAdpt.Fill(DataADO.Product);

                    if (DataADO.Product.FindByProductID(ProdID) == null)
                    {
                        Console.WriteLine("Producto no existe");
                        Row.RejectChanges();
                        return;
                    }
                }
            }

            do
            {
                Console.Write("Introduzca cantidad: ");
            }while (!short.TryParse(Console.ReadLine(), out ProdQty));
            Row.OrderQty = ProdQty;

            do
            {
                Console.Write("Introduzca precio unitario: ");
            }while (!decimal.TryParse(Console.ReadLine(), out ProdPrice));
            Row.UnitPrice = ProdPrice;

            Console.WriteLine("Estado de fila antes de incluir: {0}", Row.RowState);
            //Añadimos la fila instanciada al dataset/tabla para poder disponer de esta tanto en local como en remoto
            try
            {
                DataADO.SalesOrderDetail.AddSalesOrderDetailRow(Row);
            }
            catch (ConstraintException e)
            {
                Console.WriteLine("ERROR: Violación de restricción en comando Add. Detalle: {0}", e.Message);
                return;
            }
            catch (NoNullAllowedException e)
            {
                Console.WriteLine("ERROR: No se admite valor nulo de campo en comando Add. Detalle: {0}", e.Message);
                return;
            }

            Console.WriteLine("Estado de fila recien atachada: {0}", Row.RowState);
            //Recalculamos precio total de cabecera de pedido
            //Lo hace el trigger al editar detalle
            //HeaderRow = DataADO.SalesOrderHeader.FindBySalesOrderID(OrdHeaderID);
            //HeaderRow.SubTotal += ProdPrice * ProdQty;
            //SendSalesOrderHeader(HeaderRow);
            SendSalesOrderDetail(Row);

            Console.WriteLine("Estado de fila al final de comando: {0}", Row.RowState);
        }
Example #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)  //if not logged in
            {
                Response.Redirect("/");
            }

            if (Request.QueryString["Mode"] == "Edit")
            {
                edit      = true;
                receiptID = Request.QueryString["ID"];

                if (!User.IsInRole("Admin") && ddlEmployee.SelectedValue != User.Identity.Name)
                {
                    Response.Redirect("SaleRecord.aspx?ID=" + receiptID);
                }
                //if not admin nor creator, redirect to details

                lblTitle.Text  = "Edit Sale";
                btnModify.Text = "Save Changes";
                btnModify.Attributes["aria-label"] = "Save changes made for this sale along with the orders";
            }

            ScriptManager.RegisterStartupScript(Page, GetType(), "UiFix", "setHeight();", true);
            //use js to resize listbox

            if (IsPostBack)
            {
                return;
            }

            try
            {
                dsSales.Clear();
                daCustomerNames.Fill(dsSales.CustomerName);
                daPayments.Fill(dsSales.Payment);
                daEmployeeNames.Fill(dsSales.EmployeeName);
                daProducts.Fill(dsSales.Product);
                daInventories.Fill(dsSales.Inventory);
                daReceipts.Fill(dsSales.Receipt);
                daOL.Fill(dsSales.OrderLine);
            }
            catch (Exception ex)
            {
                //prompt
                return;
            }

            txtDate.Text = DateTime.Today.ToShortDateString();

            DisplayCustomerList(receiptID);
            DisplayPaymentList(receiptID);
            DisplayEmployeeList();
            DisplayProductList();  //populate ddl

            if (edit)
            {
                DataRow sale = dsSales.Receipt.FindByid(Convert.ToInt32(receiptID));
                txtDate.Text = Convert.ToDateTime(sale.ItemArray[2]).ToShortDateString();

                DataRow[] orders = sale.GetChildRows("fk_orderline_receipt");  //get orders

                lsbOrders.Items.Clear();
                foreach (DataRow o in orders)
                {
                    DataRow product = o.GetParentRow("fk_orderline_inventory")  //inventory
                                      .GetParentRow("fk_inventory_product");
                    string noteAppended = (o.ItemArray[4] == null) ? String.Empty :
                                          " - Note: " + o.ItemArray[4].ToString();
                    lsbOrders.Items.Add(
                        new ListItem(product.ItemArray[1].ToString() +
                                     " (" + product.ItemArray[3].ToString() + ")" +
                                     " x" + o.ItemArray[2].ToString() + noteAppended,
                                     o.ItemArray[0].ToString())
                        ); //add to list box
                }
            }

            Session["newOrders"] = new Dictionary <int, Order>();  //init
        }
Example #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated || !User.IsInRole("Admin"))
            {
                //if not admin or even not logged in
                Response.Redirect("/");
            }

            try
            {
                dsSales.Clear();
                daReceipt.Fill(dsSales.Receipt);
                daCustomerNames.Fill(dsSales.CustomerName);
                daEmployeeNames.Fill(dsSales.EmployeeName);
                daOL.Fill(dsSales.OrderLine);
                daServiceOrder.Fill(dsSales.ServiceOrder);
                daInventory.Fill(dsSales.Inventory);
                daProduct.Fill(dsSales.Product);
            }
            catch (Exception ex)
            {
                //prompt users the failure
                return;
            }

            //data loaded successfully

            DateTime lastWeek = DateTime.Today - new TimeSpan(7, 0, 0, 0);

            DataRow[] sales = dsSales.Receipt.Select(
                "ordDate > #" + lastWeek.ToShortDateString() + "# AND ordPaid = True"
                );


            switch (sales.Length)
            {
            case 0:
                lblSales.Text = "No records found.";
                break;

            case 1:
                lblSales.Text = "1 paid sale displayed.";
                break;

            default:
                lblSales.Text = sales.Length.ToString() + " paid sales displayed.";
                break;
            }
            DataTable dtSales = new DataTable();

            dtSales.Columns.Add("Sale Number");
            dtSales.Columns.Add("Date");
            dtSales.Columns.Add("Customer");
            dtSales.Columns.Add("Sales Rep");
            dtSales.Columns.Add("Amount");
            foreach (DataRow sale in sales)
            {
                DataRow nrSale = dtSales.NewRow();
                nrSale["Sale Number"] = sale.ItemArray[1];                                     //Sale Number
                nrSale["Date"]        = ((DateTime)sale.ItemArray[2]).ToShortDateString();     //Date
                nrSale["Customer"]    = sale.GetParentRow("fk_receipt_custName").ItemArray[1]; //Customer
                nrSale["Sales Rep"]   = sale.GetParentRow("fk_receipt_empName").ItemArray[1];  //Sales Rep

                double total = 0.0;
                foreach (DataRow o in sale.GetChildRows("fk_orderline_receipt"))
                {
                    total += Convert.ToDouble(o.ItemArray[1]) * Convert.ToInt32(o.ItemArray[2]);
                }
                foreach (DataRow r in sale.GetChildRows("fk_serord_receipt"))
                {
                    if (r.ItemArray[4] == null || !(bool)r.ItemArray[4])
                    {
                        DataRow service = r.GetParentRow("fk_serord_service");
                        total += Convert.ToDouble(service.ItemArray[3]);
                    }
                }
                nrSale["Amount"] = total.ToString("C2");  //Amount

                dtSales.Rows.Add(nrSale);
            }
            gvSales.DataSource = dtSales;
            gvSales.DataBind();


            DataTable dtBreakDown = new DataTable();

            dtBreakDown.Columns.Add(" ");
            dtBreakDown.Columns.Add("Count");
            dtBreakDown.Columns.Add("Amount");
            dtBreakDown.Columns.Add("Emma's 2%");

            DataRow nrRepair = dtBreakDown.NewRow();
            DataRow nrOrder  = dtBreakDown.NewRow();
            DataRow nrAll    = dtBreakDown.NewRow();

            nrRepair[0] = "Repair Records";
            nrOrder[0]  = "Orders";
            nrAll[0]    = "All Records";

            int    cntRepair = 0, cntOrder = 0;
            double amtRepair = 0.0, amtOrder = 0.0;

            foreach (DataRow sale in sales)
            {
                cntRepair += sale.GetChildRows("fk_serord_receipt").Length;
                foreach (DataRow repair in sale.GetChildRows("fk_serord_receipt"))
                {
                    if (repair.ItemArray[4] != null && !(bool)repair.ItemArray[4])
                    {
                        amtRepair += Convert.ToDouble(repair.GetParentRow("fk_serord_service").ItemArray[3]);
                    }
                }

                cntOrder += sale.GetChildRows("fk_orderline_receipt").Length;
                foreach (DataRow order in sale.GetChildRows("fk_orderline_receipt"))
                {
                    amtOrder += Convert.ToDouble(order.ItemArray[1]);
                }
            }

            nrRepair[1] = cntRepair;
            nrOrder[1]  = cntOrder;
            nrAll[1]    = cntRepair + cntOrder;
            nrRepair[2] = amtRepair.ToString("C2");
            nrOrder[2]  = amtOrder.ToString("C2");
            nrAll[2]    = (amtRepair + amtOrder).ToString("C2");
            nrRepair[3] = (amtRepair * 0.02).ToString("C2");
            nrOrder[3]  = (amtOrder * 0.02).ToString("C2");
            nrAll[3]    = ((amtRepair + amtOrder) * 0.02).ToString("C2");

            dtBreakDown.Rows.Add(nrRepair);
            dtBreakDown.Rows.Add(nrOrder);
            dtBreakDown.Rows.Add(nrAll);

            gvBreakDown.DataSource = dtBreakDown;
            gvBreakDown.DataBind();


            DataTable dtOrdered = new DataTable();

            dtOrdered.Columns.Add("Inventory ID");
            dtOrdered.Columns.Add("Product");
            dtOrdered.Columns.Add("Inventory Usage");
            dtOrdered.Columns.Add("# Ordered");
            dtOrdered.Columns.Add("Amount for Inventory");
            dtOrdered.Columns.Add("Amount for the Ordered");
            dtOrdered.Columns.Add("Total Amount");

            foreach (DataRow inv in dsSales.Inventory.Rows)
            {
                int    cntInv = 0, cntOrdered = 0;
                double amtInv = 0.0, amtOrdered = 0.0;
                foreach (DataRow order in inv.GetChildRows("fk_orderline_inventory"))
                {
                    if (Convert.ToDateTime(order.GetParentRow("fk_orderline_receipt")[2]) > lastWeek)
                    {
                        if (order[3] != null && (bool)order[3])
                        {
                            cntOrdered += Convert.ToInt32(order[2]);
                            amtOrdered += Convert.ToDouble(order[1]);
                        }
                        else
                        {
                            cntInv += Convert.ToInt32(order[2]);
                            amtInv += Convert.ToDouble(order[1]);
                        }
                    }
                }
                if (cntInv + cntOrdered == 0)
                {
                    continue;
                }

                DataRow nrOrdered = dtOrdered.NewRow();
                nrOrdered[0] = inv[0];
                nrOrdered[1] = inv.GetParentRow("fk_inventory_product")[1];
                nrOrdered[2] = cntInv;
                nrOrdered[3] = cntOrdered;
                nrOrdered[4] = amtInv.ToString("C2");
                nrOrdered[5] = amtOrdered.ToString("C2");
                nrOrdered[6] = (amtInv + amtOrdered).ToString("C2");
                dtOrdered.Rows.Add(nrOrdered);
            }
            gvOrdered.DataSource = dtOrdered;
            gvOrdered.DataBind();
            switch (dtBreakDown.Rows.Count)
            {
            case 0:
                lblOrdered.Text = "No records found.";
                break;

            case 1:
                lblOrdered.Text = "1 record displayed.";
                break;

            default:
                lblOrdered.Text = dtBreakDown.Rows.Count.ToString() + " records displayed.";
                break;
            }
        }