private void btmOK_Click(object sender, EventArgs e) { if (this.invUpdate.intNumber != int.Parse(this.tbNumber.Text.Trim())) { InvoiceItem iiSearchLoc = new InvoiceItem(); InvoiceItem iiUpdateLoc = new InvoiceItem(); iiSearchLoc.intInvoiceNumber = this.invUpdate.intNumber; DataSet dsInvoiceItemsLoc = InvoiceItem.GetInvoiceItems(this.cnConnection, iiSearchLoc); for (int i = 0; i < dsInvoiceItemsLoc.Tables["tabInvoiceItems"].Rows.Count; i++) { iiUpdateLoc.intID = (int)dsInvoiceItemsLoc.Tables["tabInvoiceItems"].Rows[i]["intID"]; iiUpdateLoc.intInvoiceNumber = int.Parse(this.tbNumber.Text.Trim()); iiUpdateLoc.intRequest = (int)dsInvoiceItemsLoc.Tables["tabInvoiceItems"].Rows[i]["intRequestNumber"]; iiUpdateLoc.strEquipStorecode = dsInvoiceItemsLoc.Tables["tabInvoiceItems"].Rows[i]["nvcStoreCode"].ToString(); iiUpdateLoc.dblAmount = (double)dsInvoiceItemsLoc.Tables["tabInvoiceItems"].Rows[i]["floAmount"]; iiUpdateLoc.dblPrice = (double)dsInvoiceItemsLoc.Tables["tabInvoiceItems"].Rows[i]["floPrice"]; iiUpdateLoc.Update(this.cnConnection); } } //this.invUpdate.strBuyerCoID = SelectEmployee.strCoID; //this.invUpdate.intVendorNumber = SelectVendor.intNumberSelectedVendor; this.invUpdate.intNumber = int.Parse(this.tbNumber.Text.Trim()); this.invUpdate.intInvoiceNumberofVendor = int.Parse(this.tbInvoiceNumberofVendor.Text.Trim()); this.invUpdate.dtDate = this.dtpDate.Value; this.invUpdate.Update(this.cnConnection); Invoices frmInvoices = (Invoices)this.Owner; frmInvoices.SearchInvoices(); this.Close(); }
public void SearchInvoiceItems() { this.dsInvoiceItems = InvoiceItem.GetInvoiceItems(this.cnConnection, this.iiSearch); this.dgvInvoiceItems.DataSource = this.dsInvoiceItems; this.dgvInvoiceItems.DataMember = "tabInvoiceItems"; for (int i = 0; i < this.dsInvoiceItems.Tables["tabInvoiceItems"].Rows.Count; i++) { if ((int)this.dsInvoiceItems.Tables["tabInvoiceItems"].Rows[i]["intRequestNumber"] == -1) { this.dgvInvoiceItems.Rows[i].Cells["intRequestNumberAsName"].Value = "بدون درخواست"; } else { this.dgvInvoiceItems.Rows[i].Cells["intRequestNumberAsName"].Value = this.dsInvoiceItems.Tables["tabInvoiceItems"].Rows[i]["intRequestNumber"]; } this.dgvInvoiceItems.Rows[i].Cells["nvcStoreCodeAsName"].Value = StoreCode.GetMaterialTypeFromStoreCode(this.cnConnection, this.dsInvoiceItems.Tables["tabInvoiceItems"].Rows[i]["nvcStoreCode"].ToString()); this.dobTotalCost += (double)this.dsInvoiceItems.Tables["tabInvoiceItems"].Rows[i]["floAmount"] * (double)this.dsInvoiceItems.Tables["tabInvoiceItems"].Rows[i]["floPrice"]; this.dgvInvoiceItems.Rows[i].Cells["floTotalCost"].Value = (double)this.dsInvoiceItems.Tables["tabInvoiceItems"].Rows[i]["floAmount"] * (double)this.dsInvoiceItems.Tables["tabInvoiceItems"].Rows[i]["floPrice"]; } this.labTotalCost.Text = String.Format("{0:n0}", this.dobTotalCost); }
public void SearchInvoices() { this.InvSearch = new Invoice(); DateTime dtFromLoc = new DateTime(); DateTime dtToLoc = new DateTime(); if (this.tbNumber.Text.Trim().Length != 0) { this.InvSearch.intNumber = int.Parse(this.tbNumber.Text.Trim()); } if (this.tbInvoiceNumberofVendor.Text.Trim().Length != 0) { this.InvSearch.intInvoiceNumberofVendor = int.Parse(this.tbInvoiceNumberofVendor.Text.Trim()); } if (this.cbDate.Checked) { dtFromLoc = this.dtpFrom.Value; dtToLoc = this.dtpTo.Value; } this.InvSearch.intVendorNumber = SelectVendor.intNumberSelectedVendor; this.dsInvoices = Invoice.GetInvoices(this.cnConnection, this.InvSearch, dtFromLoc, dtToLoc); this.dgvInvoices.DataSource = this.dsInvoices; this.dgvInvoices.DataMember = "tabInvoices"; for (int i = 0; i < this.dgvInvoices.Rows.Count; i++) { this.dgvInvoices.Rows[i].Cells["nvcVendorName"].Value = Vendor.GetNameByNumber(this.cnConnection, (int)this.dsInvoices.Tables["tabInvoices"].Rows[i]["intVendorNumber"]); this.dgvInvoices.Rows[i].Cells["nvcBuyerCoIDByName"].Value = Employee.GetNameByCoID(this.cnConnection, this.dsInvoices.Tables["tabInvoices"].Rows[i]["nvcBuyerCoID"].ToString()); InvoiceItem iiSearchLoc = new InvoiceItem(); iiSearchLoc.intInvoiceNumber = (int)this.dsInvoices.Tables["tabInvoices"].Rows[i]["intNumber"]; DataSet dsInvoiceItemsLoc = InvoiceItem.GetInvoiceItems(this.cnConnection, iiSearchLoc); double dobTotalCostLoc = 0; for (int j = 0; j < dsInvoiceItemsLoc.Tables["tabInvoiceItems"].Rows.Count; j++) { dobTotalCostLoc += (double)dsInvoiceItemsLoc.Tables["tabInvoiceItems"].Rows[j]["floAmount"] * (double)dsInvoiceItemsLoc.Tables["tabInvoiceItems"].Rows[j]["floPrice"]; } this.dgvInvoices.Rows[i].Cells["floTotalCost"].Value = dobTotalCostLoc.ToString(); } }