示例#1
0
        protected void PurchaseOrderFormView_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            DataKey key = PurchaseOrderFormView.DataKey;

            TextBox txtOrderDate = (TextBox)PurchaseOrderFormView.FindControl("txtOrderDate");
            TextBox txtPartId    = (TextBox)PurchaseOrderFormView.FindControl("txtPartId");
            TextBox txtPartName  = (TextBox)PurchaseOrderFormView.FindControl("txtPartName");

            TextBox txtCarModel = (TextBox)PurchaseOrderFormView.FindControl("txtCarModel");
            TextBox txtQuantity = (TextBox)PurchaseOrderFormView.FindControl("txtQuantity");
            TextBox txtCost     = (TextBox)PurchaseOrderFormView.FindControl("txtCost");
            TextBox txtTax      = (TextBox)PurchaseOrderFormView.FindControl("txtTax");
            TextBox txtTotal    = (TextBox)PurchaseOrderFormView.FindControl("txtTotal");

            double dbQty  = Double.Parse(txtQuantity.Text);
            double dbCost = Double.Parse(txtCost.Text);
            double dbTax  = Double.Parse(txtTax.Text);

            double dbTaxPer   = (dbTax / 100);
            double dbTotal    = (dbQty * dbCost);
            double dbSubtotal = (dbTaxPer * dbTotal);
            double dblResults = (dbTotal + dbSubtotal);

            txtTotal.Text = dblResults.ToString();



            TextBox txtName    = (TextBox)PurchaseOrderFormView.FindControl("txtName");
            TextBox txtAddress = (TextBox)PurchaseOrderFormView.FindControl("txtAddress");
            TextBox txtPhone   = (TextBox)PurchaseOrderFormView.FindControl("txtPhone");
            TextBox txtEmail   = (TextBox)PurchaseOrderFormView.FindControl("txtEmail");

            SqlConnection conn = new SqlConnection(connStr);

            com.Connection  = conn;
            com.CommandText = "UPDATE ORDER_DETAILS SET orderdate ='" + txtOrderDate.Text + "',part_id ='" + txtPartId.Text + "',part_name ='" + txtPartName.Text + "',carmodel ='" + txtCarModel.Text + "', cost ='" + txtCost.Text + "', quantity ='" + txtQuantity.Text + "',tax ='" + txtTax.Text + "' , amt ='" + txtTotal.Text + "', org_name ='" + txtName.Text + "' , add1 ='" + txtAddress.Text + "',  phone1 ='" + txtPhone.Text + "' ,email1 ='" + txtEmail.Text + "' WHERE order_id='" + key.Value.ToString() + "'";
            conn.Open();
            com.ExecuteNonQuery();

            bindgrid();
            conn.Close();
        }
示例#2
0
        protected void PurchaseOrderFormView_ItemInserting(object sender, FormViewInsertEventArgs e)
        {
            TextBox txtOrderId   = (TextBox)PurchaseOrderFormView.FindControl("txtOrderId");
            TextBox txtOrderDate = (TextBox)PurchaseOrderFormView.FindControl("txtOrderDate");
            TextBox txtPartId    = (TextBox)PurchaseOrderFormView.FindControl("txtPartId");
            TextBox txtPartName  = (TextBox)PurchaseOrderFormView.FindControl("txtPartName");

            TextBox txtCarModel = (TextBox)PurchaseOrderFormView.FindControl("txtCarModel");
            TextBox txtQuantity = (TextBox)PurchaseOrderFormView.FindControl("txtQuantity");
            TextBox txtCost     = (TextBox)PurchaseOrderFormView.FindControl("txtCost");
            TextBox txtTax      = (TextBox)PurchaseOrderFormView.FindControl("txtTax");
            TextBox txtTotal    = (TextBox)PurchaseOrderFormView.FindControl("txtTotal");
            double  dbQty       = Double.Parse(txtQuantity.Text);
            double  dbCost      = Double.Parse(txtCost.Text);
            double  dbTax       = Double.Parse(txtTax.Text);

            double dbTaxPer   = (dbTax / 100);
            double dbTotal    = (dbQty * dbCost);
            double dbSubtotal = (dbTaxPer * dbTotal);
            double dblResults = (dbTotal + dbSubtotal);

            txtTotal.Text = dblResults.ToString();

            TextBox       txtName    = (TextBox)PurchaseOrderFormView.FindControl("txtName");
            TextBox       txtAddress = (TextBox)PurchaseOrderFormView.FindControl("txtAddress");
            TextBox       txtPhone   = (TextBox)PurchaseOrderFormView.FindControl("txtPhone");
            TextBox       txtEmail   = (TextBox)PurchaseOrderFormView.FindControl("txtEmail");
            SqlConnection conn       = new SqlConnection(connStr);

            com.Connection  = conn;
            com.CommandText = "INSERT INTO ORDER_DETAILS Values('" + txtOrderId.Text + "','" + txtOrderDate.Text + "', '" + txtPartId.Text + "','" + txtPartName.Text + "' ,'" + txtCarModel.Text + "', '" + txtCost.Text + "','" + txtQuantity.Text + "' , '" + txtTax.Text + "', '" + txtTotal.Text + "', '" + txtName.Text + "', '" + txtAddress.Text + "', '" + txtPhone.Text + "','" + txtEmail.Text + "' )";
            conn.Open();
            com.ExecuteNonQuery();

            bindgrid();
            conn.Close();
        }