Exemplo n.º 1
0
        protected override void BindData()
        {
            if (Action == DatabaseAction.Edit)
            {
                ds_Production.SP_GetProductDistributionHeader.Clear();
                ds_Production.SP_GetProductDistributionHeader.Merge(ProductionManager.GetProductDistributionHeader(ProductDistributionID));
                if (ds_Production.SP_GetProductDistributionHeader.Count == 0)
                {
                    throw new ArgumentException("მონაცემი არ მოიძებნა.", "RecordID");
                }

                ProductDistributionID = ds_Production.SP_GetProductDistributionHeader[0].ProductDistributionID;
                FromBranchID          = ds_Production.SP_GetProductDistributionHeader[0].FromBranchID;
                ToBranchID            = ds_Production.SP_GetProductDistributionHeader[0].ToBranchID;
                StartDate             = ds_Production.SP_GetProductDistributionHeader[0].StartDate;
                dateEndDate.EditValue = ds_Production.SP_GetProductDistributionHeader[0][ds_Production.SP_GetProductDistributionHeader.EndDateColumn];
                RevisionNumber        = ds_Production.SP_GetProductDistributionHeader[0].RevisionNumber;
                //Comment = ds_Production.SP_GetProductDistributionHeader[0].Comment;

                Status         = (DatabaseStatus)ds_Production.SP_GetProductDistributionHeader[0].Status;
                ModifiedUserID = ds_Production.SP_GetProductDistributionHeader[0].ModifiedUserID;
                ModifiedDate   = ds_Production.SP_GetProductDistributionHeader[0].ModifiedDate;
                ApproverUserID = ds_Production.SP_GetProductDistributionHeader[0].ApproverUserID;

                ds_Production.SP_GetProductDistributionDetail.Clear();
                ds_Production.SP_GetProductDistributionDetail.Merge(ProductionManager.GetProductDistributionDetail(ProductDistributionID));

                var rate = CurrencyRate;
                foreach (var row in ds_Production.SP_GetProductDistributionDetail)
                {
                    row._UnitPrice         = row.UnitPrice * rate;
                    row._ResidualQty       = row.Quantity;
                    row.Quantity          += row.DistributeQty;
                    row._DistributeUnitQty = MathHelper.RoundUnit(row.DistributeQty, row.UnitsInStock, 4);
                }

                ds_Production.AcceptChanges();
            }
            else
            {
                ModifiedUserID = BaseGlobalVariable.UserID;
                ModifiedDate   = BaseGlobalVariable.ServerDateTime;

                FromBranchID = GlobalVariable.BranchID;
                StartDate    = BaseGlobalVariable.ServerDateTime;

                AddHeader();
            }
        }