private void Login(object sender, EventArgs e) { UseWaitCursor = true; if (tbxUsername.Text == "") { MessageBox.Show(Resources.empty_username, Resources.title_information); UseWaitCursor = false; return; } var dm = new CorporateUserDataManager(); var user = dm.Login(tbxUsername.Text, tbxPassword.Text, BaseControl.CorporateId); if (user != null) { var em = new CustomerDataManager(); var corporate = em.GetFirst <CustomerModel>(WhereTerm.Default(user.CorporateId, "id", EnumSqlOperator.Equals)); if (corporate != null) { BaseControl.UserId = user.Id; BaseControl.UserLogin = user.UserName; BaseControl.CorporateName = corporate.Name; BaseControl.BranchId = corporate.BranchId; var branch = new BranchDataManager().GetFirst <BranchModel>(WhereTerm.Default(corporate.BranchId, "id", EnumSqlOperator.Equals)); BaseControl.CityId = branch.CityId; BaseControl.BranchCode = branch.Code; var city = new CityDataManager().GetFirst <CityModel>(WhereTerm.Default(branch.CityId, "id", EnumSqlOperator.Equals)); BaseControl.CityName = city.Name; BaseControl.CountryId = city.CountryId; var country = new CountryDataManager().GetFirst <CountryModel>(WhereTerm.Default(city.CountryId, "id", EnumSqlOperator.Equals)); BaseControl.CountryName = country.Name; Authorization.SetCorporateUserId(BaseControl.UserId); Dispose(); } else { MessageBox.Show(string.Format("{0} {1}", Resources.franchise_account_not_found, Resources.contact_it_support), Resources.title_information); } } else { MessageBox.Show(Resources.invalid_login, Resources.title_login_failed); } UseWaitCursor = false; }
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 }); }
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(); }