Exemplo n.º 1
0
        private void ListProductGetDetail()
        {
            this.listProductDetailList.RaiseListChangedEvents = false;
            this.listProductDetailList.Clear();
            if (this.ProductID >= 0)
            {
                ListProductDTS.ListProductDetailDataTable detailDataTable = this.DetailTableAdapter.GetData(this.ProductID);

                if (detailDataTable.Count > 0)
                {
                    foreach (ListProductDTS.ListProductDetailRow detailRow in detailDataTable.Rows)
                    {
                        this.listProductDetailList.Add(new ListProductDetail(detailRow.CommonID, detailRow.CommonValue, detailRow.Remarks));
                    }
                }
            }
            this.listProductDetailList.RaiseListChangedEvents = true;
            this.listProductDetailList.ResetBindings();
        }
Exemplo n.º 2
0
        private bool SaveDetail(int productID)
        {
            int serialID = 0; int rowsAffected = 0;


            #region <Save collection>

            serialID = 0;

            ListProductDTS.ListProductDetailDataTable detailDataTable = new ListProductDTS.ListProductDetailDataTable();

            foreach (ListProductDetail listProductDetail in this.ListProductDetailList)
            {
                ListProductDTS.ListProductDetailRow detailRow = detailDataTable.NewListProductDetailRow();

                detailRow.ProductID = productID;
                detailRow.SerialID  = ++serialID;

                detailRow.CommonID    = listProductDetail.CommonID;
                detailRow.CommonValue = listProductDetail.CommonValue;

                detailRow.Remarks = listProductDetail.Remarks;

                detailDataTable.AddListProductDetailRow(detailRow);
            }

            rowsAffected = this.DetailTableAdapter.Update(detailDataTable);
            if (rowsAffected != this.listProductDetailList.Count)
            {
                throw new System.ArgumentException("Insufficient save", "Save detail");
            }


            #endregion <Save collection>


            return(true);
        }