Ejemplo n.º 1
0
        private void Save()
        {
            receiptTableAdapter   daReceipt   = new receiptTableAdapter();
            orderLineTableAdapter daOrderLine = new orderLineTableAdapter();

            try
            {
                daReceipt.Update(dsEmma.receipt);
                daOrderLine.Update(dsEmma.orderLine);
                dsEmma.AcceptChanges();
                this.lblSave.Text = "Sale has been updated successfully.";
            }
            catch
            {
                dsEmma.RejectChanges();
                this.lblSave.Text = "Unable to add sale - All changes have been rejected.";
            }
        }
Ejemplo n.º 2
0
        private void Save()
        {
            receiptTableAdapter   daReceipt   = new receiptTableAdapter();
            orderLineTableAdapter daOrderLine = new orderLineTableAdapter();

            try
            {
                daReceipt.Update(dsAddSale.receipt);
                daOrderLine.Update(dsAddSale.orderLine);
                dsAddSale.AcceptChanges();
                this.lblSave.Text = "Sale has been added successfully.";
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Sale has been added successfully." + "');", true);
            }
            catch
            {
                dsAddSale.RejectChanges();
                this.lblSave.Text = "Unable to add sale - All changes have been rejected.";
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Unable to add sale - All changes have been rejected." + "');", true);
            }
        }
Ejemplo n.º 3
0
        protected void submit_Click(object sender, EventArgs e)
        {
            DataRow r = dsReceipt.receipt.NewRow();

            r["custID"]    = ListBox2.SelectedValue;
            r["empID"]     = dsReceipt.employee.Select("empLogin = '******'")[0]["id"];
            r["ordDate"]   = DateTime.Now;
            r["paymentID"] = ddlPayment.SelectedValue;
            dsReceipt.receipt.Rows.Add(r);
            object         adapter    = null;
            List <DataRow> ChildRows  = new List <DataRow>();
            DataTable      childTable = null;

            if (Mode == PageMode.Sale)
            {
                childTable = dsReceipt.order_line;
                for (int i = 0; i < selectedProducts?.Rows.Count; i++)
                {
                    if (Convert.ToInt32(Request.Form["ctl00$MainContent$gvSelectedProductsSales$ctl0" + (i + 2).ToString() + "$TextBox1"]) > 0)
                    {
                        DataRow l = dsReceipt.order_line.NewRow();
                        l["inventoryID"] = selectedProducts.Rows[i]["id"];
                        l["orlQuantity"] = Request.Form["ctl00$MainContent$gvSelectedProductsSales$ctl0" + (i + 2).ToString() + "$TextBox1"];
                        l["orlOrderReq"] = Convert.ToInt16(l["orlQuantity"]) > Convert.ToInt32(selectedProducts.Rows[i]["Stock"]);
                        l["orlPrice"]    = Convert.ToBoolean(l["orlOrderReq"]) ? Convert.ToDouble(selectedProducts.Rows[i]["Price"]) * 1.01 : Convert.ToDouble(selectedProducts.Rows[i]["Price"]);
                        ChildRows.Add(l);
                    }
                }
                adapter = new order_lineTableAdapter();
                if (ChildRows.Count == 0)
                {
                    dsReceipt.RejectChanges();
                    lblError.Text = "Please select at least one item to purchase";
                    return;
                }
            }
            else if (Mode == PageMode.Repair)
            {
                childTable = dsReceipt.service_order;
                DataRow eq = dsReceipt.equipment.NewRow();
                eq["equModel"]  = txtModel.Text;
                eq["equSerial"] = txtSerialNumber.Text;
                eq["custID"]    = r["custID"];
                eq["equtypeID"] = ddlType.SelectedValue;
                eq["equManuID"] = ddlManu.SelectedValue;
                dsReceipt.equipment.Rows.Add(eq);
                equipmentTableAdapter daEqu = new equipmentTableAdapter();
                daEqu.Update(dsReceipt.equipment);
                DataRow so = dsReceipt.service_order.NewRow();
                so["serordDateIn"]   = DateTime.Now;
                so["serordIssue"]    = RD.Text;
                so["serordWarranty"] = RadioButtonList1.SelectedValue == "1";
                so["serviceID"]      = ddlService.SelectedValue;
                //for reasons passing understanding,
                //the equipment table adapter does not update the id column in the dataset,
                //while the receipt adapter does
                so["equipID"] = Convert.ToInt32(dsReceipt.equipment.Max(row => row["id"])) + 1;
                ChildRows.Add(so);
                adapter = new service_orderTableAdapter();
            }
            receiptTableAdapter daReceipt = new receiptTableAdapter();

            daReceipt.Update(dsReceipt.receipt);
            foreach (DataRow cr in ChildRows)
            {
                cr["receiptId"] = r["id"];
                childTable.Rows.Add(cr);
            }
            if (adapter is service_orderTableAdapter daService)
            {
                daService.Update(dsReceipt.service_order);
            }
            else if (adapter is order_lineTableAdapter daOrder)
            {
                daOrder.Update(dsReceipt.order_line);
            }
            dsReceipt.AcceptChanges();
            Response.Redirect("~/Default");
        }