示例#1
0
        private IEnumerable <ShipmentModel.ShipmentReportRow> GetPrintDataSource()
        {
            var model = ConvertModel <ShipmentModel, ShipmentModel.ShipmentReportRow>(CurrentModel as ShipmentModel);

            if (model == null)
            {
                return(null);
            }

            using (var customerDm = new CustomerDataManager())
            {
                var customer = customerDm.GetFirst <CustomerModel>(WhereTerm.Default(model.CustomerId ?? 0, "id"));
                if (customer != null)
                {
                    model.CustomerCode = customer.Code;
                }
            }

            using (var serviceTypeDm = new ServiceTypeDataManager())
            {
                var serviceType = serviceTypeDm.GetFirst <ServiceTypeModel>(WhereTerm.Default(model.ServiceTypeId, "id"));
                if (serviceType != null)
                {
                    model.ServiceType = serviceType.Name;
                }
            }

            using (var employeeDm = new EmployeeDataManager())
            {
                var employee = employeeDm.GetFirst <EmployeeModel>(WhereTerm.Default(model.MessengerId ?? 0, "id"));
                if (employee != null)
                {
                    model.MessengerCode = employee.Code;
                }
            }

            using (var paymentMethodDm = new PaymentMethodDataManager())
            {
                var paymentMethod = paymentMethodDm.GetFirst <PaymentMethodModel>(WhereTerm.Default(model.PaymentMethodId, "id"));
                if (paymentMethod != null)
                {
                    model.PaymentMethod = paymentMethod.Name;
                }
            }

            using (var branchDm = new BranchDataManager())
            {
                var branch = branchDm.GetFirst <BranchModel>(WhereTerm.Default(model.BranchId, "id"));
                if (branch != null)
                {
                    model.ShipmentHeader = branch.HeaderShipment;
                }
            }

            using (var packageDm = new PackageTypeDataManager())
            {
                var package = packageDm.GetFirst <PackageTypeModel>(WhereTerm.Default(model.PackageTypeId, "id"));
                if (package != null)
                {
                    model.PackageType = package.Name;
                }
            }

            return(new List <ShipmentModel.ShipmentReportRow>
            {
                model
            });
        }
示例#2
0
        protected override void PopulateForm(ShipmentModel model)
        {
            tbxSearch_Code.Text = model.Code;

            tbxDate.Text        = model.DateProcess.ToString("dd-MM-yyyy");
            tbxOrigin.Text      = model.CityName;
            tbxDestination.Text = model.DestCity;

            using (var customerDataManager = new CustomerDataManager())
            {
                var i =
                    customerDataManager.GetFirst <CustomerModel>(WhereTerm.Default(model.CustomerId ?? 0, "id",
                                                                                   EnumSqlOperator.Equals));
                tbxCustomerCode.Text = (i != null) ? i.Code : "";
            }

            tbxCustomer.Text = model.CustomerName;

            tbxName.Text    = model.ShipperName;
            tbxAddress.Text = model.ShipperAddress;
            tbxPhone.Text   = model.ShipperPhone;

            tbxConsigneeName.Text    = model.ConsigneeName;
            tbxConsigneeAddress.Text = model.ConsigneeAddress;
            tbxConsigneePhone.Text   = model.ConsigneePhone;

            using (var packageTypeDataManager = new PackageTypeDataManager())
            {
                var i = packageTypeDataManager.GetFirst <PackageTypeModel>(WhereTerm.Default(model.PackageTypeId, "id", EnumSqlOperator.Equals));
                tbxPackage.Text = (i != null) ? i.Name : "";
            }

            using (var serviceTypeDataManager = new ServiceTypeDataManager())
            {
                var i = serviceTypeDataManager.GetFirst <ServiceTypeModel>(WhereTerm.Default(model.ServiceTypeId, "id", EnumSqlOperator.Equals));
                tbxService.Text = (i != null) ? i.Name : "";
            }

            using (var paymentMethodDataManager = new PaymentMethodDataManager())
            {
                var i =
                    paymentMethodDataManager.GetFirst <PaymentMethodModel>(WhereTerm.Default(model.PaymentMethodId, "id",
                                                                                             EnumSqlOperator.Equals));
                tbxPayment.Text = (i != null) ? i.Name : "";
            }
            tbxNatureOfGood.Text = model.NatureOfGoods;

            tbxTtlPiece.Value      = model.TtlPiece;
            tbxTtlWeight.Value     = model.TtlGrossWeight;
            tbxTtlChargeable.Value = model.TtlChargeableWeight;

            tbxDate.Enabled        = false;
            tbxOrigin.Enabled      = false;
            tbxDestination.Enabled = false;

            tbxTtlPiece.Enabled      = false;
            tbxTtlWeight.Enabled     = false;
            tbxTtlChargeable.Enabled = false;

            _SetControlEnableState(pnlShipperInformation, false);
            _SetControlEnableState(pnlConsigneeInformation, false);
            _SetControlEnableState(pnlOtherInformation, false);

            rbData_New.Enabled    = false;
            rbData_Save.Enabled   = false;
            rbData_Delete.Enabled = false;

            RefreshGrid();
            tbxSearch_Code.Focus();
        }