private void BtnOrderDetail_Click(object sender, EventArgs e) { if (txtOrderID.Text.Trim() == "") { MessageBox.Show("Please select an order!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { frmOrderDetail frm = new frmOrderDetail(); frm.Owner = this; frm.getOrderID(txtOrderID.Text); frm.Show(); } }
public void addNewOrder() { try { con.Open(); cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "[InsertOrder]"; cmd.CommandType = CommandType.StoredProcedure; #region SQL param SqlParameter param = new SqlParameter(); param = new SqlParameter(); param.ParameterName = "@custid"; param.SqlDbType = SqlDbType.Int; param.Value = int.Parse(txtCustomerID.Text); cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@empid"; param.SqlDbType = SqlDbType.Int; param.Value = int.Parse(txtEmployeeID.Text); cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@orderdate"; param.SqlDbType = SqlDbType.DateTime; param.Value = dtpOrderDate.Value; cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@requireddate"; param.SqlDbType = SqlDbType.DateTime; param.Value = dtpRequireDate.Value; cmd.Parameters.Add(param); if (ckNotShip.Checked == true) { param = new SqlParameter(); param.ParameterName = "@shippeddate"; param.SqlDbType = SqlDbType.DateTime; param.Value = DBNull.Value; cmd.Parameters.Add(param); } else { param = new SqlParameter(); param.ParameterName = "@shippeddate"; param.SqlDbType = SqlDbType.DateTime; param.Value = dtpShipDate.Value; cmd.Parameters.Add(param); } param = new SqlParameter(); param.ParameterName = "@shipperid"; param.SqlDbType = SqlDbType.Int; param.Value = int.Parse(txtShipperID.Text); cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@freight"; param.SqlDbType = SqlDbType.Money; param.Value = txtFreight.Text; cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@shipname"; param.SqlDbType = SqlDbType.NVarChar; param.Size = 40; param.Value = txtShipName.Text; cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@shipaddress"; param.SqlDbType = SqlDbType.NVarChar; param.Size = 60; param.Value = txtShipAddress.Text; cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@shipcity"; param.SqlDbType = SqlDbType.NVarChar; param.Size = 15; param.Value = txtShipCity.Text; cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@shipregion"; param.SqlDbType = SqlDbType.NVarChar; param.Size = 15; param.Value = txtShipRegion.Text; cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@shippostalcode"; param.SqlDbType = SqlDbType.NVarChar; param.Size = 10; param.Value = txtShipPostalCode.Text; cmd.Parameters.Add(param); param = new SqlParameter(); param.ParameterName = "@shipcountry"; param.SqlDbType = SqlDbType.NVarChar; param.Size = 15; param.Value = txtShipCountry.Text; cmd.Parameters.Add(param); #endregion cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Add Success"); LoadDatabase(); #region openForm DialogResult rs = MessageBox.Show("Want to add order detail ????", "Confirm", MessageBoxButtons.YesNoCancel); if (rs == DialogResult.Yes) { string orderID = dgOrder.Rows[dgOrder.RowCount - 1].Cells[0].Value.ToString(); frmOrderDetail frm = new frmOrderDetail(); frm.Owner = this; frm.getOrderID(orderID); frm.Show(); #endregion } } catch (Exception e) { MessageBox.Show(e.Message); con.Close(); } }