Beispiel #1
0
        protected override bool SaveData()
        {
            view.CloseEditor();
            bsDetail.EndEdit();

            DS_ProductDistribution.SP_GetProductDistributionDetailDataTable table = DataSetHelper.PackAlternationTypedDataTable <DS_ProductDistribution.SP_GetProductDistributionDetailDataTable>(ds_Production.SP_GetProductDistributionDetail);
            DataSetHelper.RemoveColumns(table, true, table.ProductDistributionDetailIDColumn,
                                        table.ProductLocationIDColumn,
                                        table.DistributeQtyColumn,
                                        table.UnitPriceColumn,
                                        table.OrdinalNumberColumn,
                                        table.ActionColumn);

            var ds = new DataSet("root");

            ds.Tables.Add(table);

            var id = ProductionManager.AddOrEditProductDistribution(ProductDistributionID, FromBranchID, ToBranchID, StartDate, EndDate, SubTotal, TaxAmt, Freight, TotalDue, CurrencyCode, CurrencyRateID, Comment, RevisionNumber, Status, BaseGlobalVariable.UserID, BaseGlobalVariable.ServerDateTime, ApproverUserID, Action, DataSetHelper.InnerBytesData(ds));

            if (id > 0)
            {
                if (Action == DatabaseAction.Add)
                {
                    ds_Production.SP_GetProductDistributionHeader[0].ProductDistributionID = id;
                    foreach (var row in ds_Production.SP_GetProductDistributionDetail)
                    {
                        if (row.RowState == DataRowState.Deleted)
                        {
                            continue;
                        }
                        row.ProductDistributionID = id;
                    }
                    ProductDistributionID = id;
                }
            }

            ds_Production.AcceptChanges();
            return(id > 0);
        }