//Get Purshase processed public static PurshaseInfo GetPurshase(string id_purshase) { string cmd = string.Format("EXEC GetPurshaseProcessed '{0}'", id_purshase); DataSet data = Utilities.execute(cmd); List <Purshase_Product> products = new List <Purshase_Product>(); if (data.Tables[0].Rows.Count != 0) { var id_customer = data.Tables[0].Rows[0]["id_customer"].ToString().Trim(); var customer_name = data.Tables[0].Rows[0]["customer_name"].ToString().Trim(); customer_name += " " + data.Tables[0].Rows[0]["customer_lastname"].ToString().Trim(); var date = data.Tables[0].Rows[0]["purshase_date"].ToString().Trim(); for (int i = 0; i < data.Tables[0].Rows.Count; i++) { var row = data.Tables[0].Rows[i]; var product = new Purshase_Product( row["id_item"].ToString().Trim(), row["item_name"].ToString().Trim(), row["item_mark"].ToString().Trim(), double.Parse(row["item_price"].ToString().Trim()), int.Parse(row["item_purshased_quantity"].ToString().Trim()), double.Parse(row["item_purshased_amount"].ToString().Trim()), double.Parse(row["purshase_amount"].ToString().Trim()) ); products.Add(product); } return(new PurshaseInfo(id_purshase, id_customer, customer_name, date, products)); } else { return(new PurshaseInfo()); } }
public override void Save() { string id_product = dgvProducts.Rows[dgvProducts.SelectedCells[0].RowIndex].Cells[0].Value.ToString(); string name = dgvProducts.Rows[dgvProducts.SelectedCells[0].RowIndex].Cells[1].Value.ToString(); string mark = dgvProducts.Rows[dgvProducts.SelectedCells[0].RowIndex].Cells[2].Value.ToString(); double price = double.Parse(dgvProducts.Rows[dgvProducts.SelectedCells[0].RowIndex].Cells[3].Value.ToString()); int quantity = int.Parse(dgvProducts.Rows[dgvProducts.SelectedCells[0].RowIndex].Cells[4].Value.ToString()); double amount = double.Parse(dgvProducts.Rows[dgvProducts.SelectedCells[0].RowIndex].Cells[5].Value.ToString()); double total_amount = double.Parse(txtCurrentAmount.Text); var product = new Purshase_Product(id_product, name, mark, price, quantity, amount, total_amount); ReturnDetails returnDetails = new ReturnDetails(txtIdPurshase.Text, product); returnDetails.updateQuantity = new ReturnDetails.UpdateQuantity(UpdateQuantityEventHandler); returnDetails.ShowDialog(); }
public override void Save() { if (ckbCancelOrder.Checked) { try { Purshase.CancelSaleOrder(txtIdPurshase.Text); MessageBox.Show("The order has been cancel.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); var dialog = MessageBox.Show("Do you want to process a new order?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dialog == DialogResult.OK) { Initialize(); } else { this.Close(); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { string id_product = dgvProducts.Rows[dgvProducts.SelectedCells[0].RowIndex].Cells[0].Value.ToString(); string name = dgvProducts.Rows[dgvProducts.SelectedCells[0].RowIndex].Cells[1].Value.ToString(); string mark = dgvProducts.Rows[dgvProducts.SelectedCells[0].RowIndex].Cells[2].Value.ToString(); double price = double.Parse(dgvProducts.Rows[dgvProducts.SelectedCells[0].RowIndex].Cells[3].Value.ToString()); int quantity = int.Parse(dgvProducts.Rows[dgvProducts.SelectedCells[0].RowIndex].Cells[4].Value.ToString()); double amount = double.Parse(dgvProducts.Rows[dgvProducts.SelectedCells[0].RowIndex].Cells[5].Value.ToString()); double total_amount = double.Parse(txtCurrentAmount.Text); var product = new Purshase_Product(id_product, name, mark, price, quantity, amount, total_amount); ReturnDetails returnDetails = new ReturnDetails(txtIdPurshase.Text, product); returnDetails.updateQuantity = new ReturnDetails.UpdateQuantity(UpdateQuantityEventHandler); returnDetails.ShowDialog(); } }
public ReturnDetails(string id_purshase, Purshase_Product product) { InitializeComponent(); this._product = product; txtOrder.Text = id_purshase; }