protected void AddProducts() { System.Data.DataRow prod = null; PositionDetailsForm pdfrm = new PositionDetailsForm(this.cConnection, ref prod); if( this.last_buyer >= 0 ) pdfrm.BuyerId = this.last_buyer; if( this.last_receiver >= 0 ) pdfrm.ReceiverId = this.last_receiver; if (this.cbxDiscountCards.SelectedIndex >= 0) pdfrm.Discount = this.cards.Rows[this.cbxDiscountCards.SelectedIndex]["DiscountPercent"]; pdfrm.ProductName = (string)this.products.Rows[this.lbxProducts.SelectedIndices[0]]["ProductName"]; pdfrm.ProductId = (Guid)this.products.Rows[this.lbxProducts.SelectedIndices[0]]["ProductID"]; if( pdfrm.ShowDialog() == DialogResult.OK ){ int icount = this.lbxProducts.SelectedItems.Count; for (int i = 0; i < icount; i++){ DataRow nrow = this.contents.NewRow(); int k = this.lbxProducts.SelectedIndices[i]; //this.cConnection.Open(); //System.Data.SqlClient.SqlCommand idcmd = new System.Data.SqlClient.SqlCommand("SELECT NEWID() AS ContentID FROM Purchases.ReceiptContents", this.cConnection); //Guid rec_id = (Guid)idcmd.ExecuteScalar(); //this.cConnection.Close(); nrow["ContentID"] = Purchases.ReceiptContent.NewID(this.cConnection); nrow["ReceiptID"] = this.receipt["ReceiptID"]; nrow["Position"] = this.contents.Rows.Count + 1; nrow["ProductID"] = this.products.Rows[k]["ProductID"]; nrow["ProductName"] = this.products.Rows[k]["ProductName"]; nrow["Buyer"] = pdfrm.BuyerId; nrow["Receiver"] = pdfrm.ReceiverId; nrow["BuyerFullName"] = pdfrm.BuyerFullName; nrow["ReceiverFullName"] = pdfrm.ReceiverFullName; nrow["Amount"] = pdfrm.Amount; nrow["Price"] = pdfrm.Price; nrow["Discount"] = pdfrm.Discount; nrow["Units"] = pdfrm.Units; this.contents.Rows.Add(nrow); this.last_buyer = (int)pdfrm.BuyerId; this.last_receiver = (int)pdfrm.ReceiverId; } // if (this.contents.Rows.Count == 1){ // this.dgvReceiptContent.Rows.Add(); // } this.RecalculateReceipt(); } return; }
protected void AddProducts() { System.Data.DataRow prod = null; PositionDetailsForm pdfrm = new PositionDetailsForm(this.cConnection, ref prod); if( this.last_buyer >= 0 ) pdfrm.BuyerId = this.last_buyer; if( this.last_receiver >= 0 ) pdfrm.ReceiverId = this.last_receiver; if (this.cbxDiscountCards.SelectedIndex >= 0) pdfrm.Discount = this.cards.Rows[this.cbxDiscountCards.SelectedIndex]["DiscountPercent"]; pdfrm.ProductName = (string)this.products.Rows[this.lbxProducts.SelectedIndices[0]]["ProductName"]; pdfrm.ProductId = (int)this.products.Rows[this.lbxProducts.SelectedIndices[0]]["ProductID"]; if( pdfrm.ShowDialog() == DialogResult.OK ){ int icount = this.lbxProducts.SelectedItems.Count; for (int i = 0; i < icount; i++){ DataRow nrow = this.contents.NewRow(); int k = this.lbxProducts.SelectedIndices[i]; nrow["ReceiptID"] = this.receipt["ReceiptID"]; nrow["Position"] = this.contents.Rows.Count + 1; nrow["ProductID"] = this.products.Rows[k]["ProductID"]; nrow["ProductName"] = this.products.Rows[k]["ProductName"]; nrow["Buyer"] = pdfrm.BuyerId; nrow["Receiver"] = pdfrm.ReceiverId; nrow["BuyerFullName"] = pdfrm.BuyerFullName; nrow["ReceiverFullName"] = pdfrm.ReceiverFullName; nrow["Amount"] = pdfrm.Amount; nrow["Price"] = pdfrm.Price; nrow["Discount"] = pdfrm.Discount; nrow["Units"] = pdfrm.Units; this.contents.Rows.Add(nrow); this.last_buyer = (int)pdfrm.BuyerId; this.last_receiver = (int)pdfrm.ReceiverId; } // if (this.contents.Rows.Count == 1){ // this.dgvReceiptContent.Rows.Add(); // } this.RecalculateReceipt(); } return; }
private void tsmiChangePosition_Click(object sender, EventArgs e) { if (this.dgvReceiptContent.SelectedRows.Count == 1){ // System.Data.DataRow prod = this.dgvReceiptContent.SelectedRows[0]; System.Data.DataRow prod = ((DataRowView)this.dgvReceiptContent.SelectedRows[0].DataBoundItem).Row; PositionDetailsForm pf = new PositionDetailsForm(this.cConnection, ref prod); pf.ProductId = -1; if (pf.ShowDialog() == DialogResult.OK){ prod["Buyer"] = pf.BuyerId; prod["Receiver"] = pf.ReceiverId; prod["BuyerFullName"] = pf.BuyerFullName; prod["ReceiverFullName"] = pf.ReceiverFullName; prod["Amount"] = pf.Amount; prod["Price"] = pf.Price; prod["Discount"] = pf.Discount; prod["Units"] = pf.Units; this.RecalculateReceipt(); } } return; }