protected void RadComboShipmentKey_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { int id = int.Parse(this.RadComboShipmentKey.SelectedValue.Split(',')[0]); int shipmentid = int.Parse(this.RadComboShipmentKey.SelectedValue.Split(',')[1]); if (id > 0 && shipmentid > 0) { ViewState["DistributorClientAddress"] = id; ViewState["ShipmentID"] = shipmentid; DistributorClientAddressBO objDistributorClientAddress = new DistributorClientAddressBO(); objDistributorClientAddress.ID = id; objDistributorClientAddress.GetObject(); ShipmentModeBO objShipmentMode = new ShipmentModeBO(); objShipmentMode.ID = shipmentid; objShipmentMode.GetObject(); this.txtShipTo.Text = objDistributorClientAddress.CompanyName; this.txtShipmentMode.Text = objShipmentMode.Name; string state = (objDistributorClientAddress.State != null) ? objDistributorClientAddress.Suburb : string.Empty; this.lblShipmentKeyAddress.Text = objDistributorClientAddress.CompanyName + " , " + objDistributorClientAddress.Address + " , " + objDistributorClientAddress.Suburb + " " + state + " , " + objDistributorClientAddress.objCountry.ShortName + " , " + objDistributorClientAddress.PostCode; this.populateInvoiceOrders(0, id, true, shipmentid, false); } }
protected void btnSaveShippingAddress_ServerClick(object sender, EventArgs e) { if (Page.IsValid) { int id = 0; try { using (TransactionScope ts = new TransactionScope()) { DistributorClientAddressBO objDistributorClientAddress = new DistributorClientAddressBO(this.ObjContext); if (id > 0) { objDistributorClientAddress.ID = id; objDistributorClientAddress.GetObject(); } objDistributorClientAddress.CompanyName = this.txtCOmpanyName.Text; objDistributorClientAddress.Address = this.txtShipToAddress.Text; objDistributorClientAddress.Suburb = this.txtSuburbCity.Text; objDistributorClientAddress.State = this.txtShipToState.Text; objDistributorClientAddress.PostCode = this.txtShipToPostCode.Text; objDistributorClientAddress.ContactPhone = this.txtShipToPhone.Text; objDistributorClientAddress.ContactName = this.txtShipToContactName.Text; objDistributorClientAddress.Country = int.Parse(this.ddlShipToCountry.SelectedValue); objDistributorClientAddress.Port = int.Parse(this.ddlShipToPort.SelectedValue); this.ObjContext.SaveChanges(); ts.Complete(); id = objDistributorClientAddress.ID; } this.PopulateBillTo(id); ViewState["PopulateShippingAddress"] = true; } catch (Exception ex) { IndicoLogging.log.Error("Error occured while Saving Distributor Client Address AddEditInvoice.aspx", ex); } } else { ViewState["PopulateShippingAddress"] = false; } }
private void ProcessForm(int addressid) { try { using (TransactionScope ts = new TransactionScope()) { DistributorClientAddressBO objDistributorClientAddress = new DistributorClientAddressBO(this.ObjContext); if (addressid > 0) { objDistributorClientAddress.ID = addressid; objDistributorClientAddress.GetObject(); } objDistributorClientAddress.Address = this.txtShipToAddress.Text; objDistributorClientAddress.Suburb = this.txtSuburbCity.Text; objDistributorClientAddress.PostCode = this.txtShipToPostCode.Text; objDistributorClientAddress.Country = int.Parse(this.ddlShipToCountry.SelectedValue); objDistributorClientAddress.ContactName = this.txtShipToContactName.Text; objDistributorClientAddress.EmailAddress = this.txtShipToEmail.Text; objDistributorClientAddress.ContactPhone = this.txtShipToPhone.Text; objDistributorClientAddress.CompanyName = this.txtCOmpanyName.Text; objDistributorClientAddress.State = this.txtShipToState.Text; objDistributorClientAddress.Port = int.Parse(this.ddlShipToPort.SelectedValue); //if (rbClient.Checked) //{ // objDistributorClientAddress.Client = int.Parse(this.ddlClient.SelectedValue); // objDistributorClientAddress.Distributor = null; //} //else //{ objDistributorClientAddress.Distributor = int.Parse(this.ddlDistributor.SelectedValue); objDistributorClientAddress.Client = null; //} objDistributorClientAddress.AddressType = int.Parse(this.ddlAdderssType.SelectedValue); objDistributorClientAddress.IsAdelaideWarehouse = false; this.ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { IndicoLogging.log.Error("Error occured while Adding or Updating the Distributor Client Address in ViewShipmentAddress.aspx", ex); } }
//protected void btnSaveChanges_Click(object sender, EventArgs e) //{ // if (this.IsNotRefresh) // { // int addressid = int.Parse(this.hdnSelectedaddressid.Value.Trim()); // if (Page.IsValid) // { // this.ProcessForm(addressid, false); // Response.Redirect("/ViewAgeGroups.aspx"); // } // ViewState["IsPageValied"] = (Page.IsValid); // } //} protected void btnDelete_Click(object sender, EventArgs e) { int addressid = int.Parse(this.hdnSelectedShipmentAddressID.Value.Trim()); if (Page.IsValid && addressid > 0) { using (TransactionScope ts = new TransactionScope()) { DistributorClientAddressBO objDistributorClientAddress = new DistributorClientAddressBO(this.ObjContext); objDistributorClientAddress.ID = addressid; objDistributorClientAddress.GetObject(); objDistributorClientAddress.Delete(); this.ObjContext.SaveChanges(); ts.Complete(); } this.PopulateDataGrid(); } ViewState["IsPageValied"] = (Page.IsValid); ViewState["IsPageValied"] = true; }
protected void RadGridShipmentAddress_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { var item = e.Item as GridDataItem; if (item.ItemIndex > -1 && item.DataItem is DistributorClientAddressBO) { DistributorClientAddressBO objDistributorClientAddress = (DistributorClientAddressBO)item.DataItem; HyperLink linkEdit = (HyperLink)item.FindControl("linkEdit"); HyperLink linkDelete = (HyperLink)item.FindControl("linkDelete"); Literal litCountry = (Literal)item.FindControl("litCountry"); Literal litClient = (Literal)item.FindControl("litClient"); Literal litDistributor = (Literal)item.FindControl("litDistributor"); Literal litPort = (Literal)item.FindControl("litPort"); Literal litAddressType = (Literal)item.FindControl("litAddressType"); litCountry.Text = objDistributorClientAddress.objCountry.ShortName; litPort.Text = (objDistributorClientAddress.Port.HasValue && objDistributorClientAddress.Port > 0) ? objDistributorClientAddress.objPort.Name : string.Empty; if (objDistributorClientAddress.AddressType.HasValue) { litAddressType.Text = (objDistributorClientAddress.AddressType.Value == 1) ? "RESIDENTIAL" : "BUSINESS"; } litClient.Text = (objDistributorClientAddress.Client.HasValue && objDistributorClientAddress.Client > 0) ? objDistributorClientAddress.objClient.Name : string.Empty; litDistributor.Text = (objDistributorClientAddress.Distributor.HasValue && objDistributorClientAddress.Distributor > 0) ? objDistributorClientAddress.objDistributor.Name : string.Empty; linkEdit.Attributes.Add("qid", objDistributorClientAddress.ID.ToString()); linkDelete.Attributes.Add("qid", objDistributorClientAddress.ID.ToString()); linkDelete.Visible = (objDistributorClientAddress.OrdersWhereThisIsBillingAddress.Any() || objDistributorClientAddress.OrdersWhereThisIsDespatchToAddress.Any() || objDistributorClientAddress.OrderDetailsWhereThisIsDespatchTo.Any()) ? false : true; } } }
private void PopulateDataGrid() { // Hide Controls this.dvEmptyContent.Visible = false; this.dvDataContent.Visible = false; this.dvNoSearchResult.Visible = false; // Search text string searchText = this.txtSearch.Text.ToLower().Trim(); // Populate Items // List<int> lstClientIDs = DistributorClientAddressBO objDisClientAddress = new DistributorClientAddressBO(); if (this.LoggedUser.IsDirectSalesPerson) { objDisClientAddress.Distributor = this.Distributor.ID; } List <DistributorClientAddressBO> lstDistributorClientAddress; if ((searchText != string.Empty) && (searchText != "search")) { lstDistributorClientAddress = objDisClientAddress.SearchObjects().Where(m => m.CompanyName.ToUpper().Contains(searchText.ToUpper())).ToList(); } else { lstDistributorClientAddress = objDisClientAddress.SearchObjects(); } //DistributorClientAddressDetailsViewBO lstDistributorClientAddress = new DistributorClientAddressDetailsViewBO(); //if (this.LoggedUser.IsDirectSalesPerson) //{ // lstDistributorClientAddress = lstDistributorClientAddress.Where(m => m.Client > 0 && m.objClient.objClient.Distributor == this.Distributor.ID).ToList(); //} //else if (this.LoggedUserRoleName == UserRole.IndicoAdministrator || this.LoggedUserRoleName == UserRole.IndicoCoordinator) //{ //} // objDistributorClientAddress.DistributorID = //List<DistributorClientAddressDetailsViewBO> lstDistributorClientAddress = new List<DistributorClientAddressDetailsViewBO>(); //if ((searchText != string.Empty) && (searchText != "search")) //{ // lstDistributorClientAddress = (from o in objDistributorClientAddress.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList() // where o.CompanyName.ToLower().Contains(searchText) || // o.ContactName.ToLower().Contains(searchText) || // o.Address.ToLower().Contains(searchText) || // o.Suburb.ToLower().Contains(searchText) || // o.Country.ToLower().Contains(searchText) || // o.Port.ToLower().Contains(searchText) // select o).ToList(); //} //else //{ // lstDistributorClientAddress = objDistributorClientAddress.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList(); //} if (lstDistributorClientAddress.Count > 0) { this.RadGridShipmentAddress.AllowPaging = (lstDistributorClientAddress.Count > this.RadGridShipmentAddress.PageSize); this.RadGridShipmentAddress.DataSource = lstDistributorClientAddress; this.RadGridShipmentAddress.DataBind(); Session["ShipmentAddressDetails"] = lstDistributorClientAddress; this.dvDataContent.Visible = true; } else if ((searchText != string.Empty && searchText != "search")) { this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty); this.dvDataContent.Visible = true; this.dvNoSearchResult.Visible = true; } else { this.dvEmptyContent.Visible = true; this.btnAddAddress.Visible = false; } this.RadGridShipmentAddress.Visible = (lstDistributorClientAddress.Count > 0); }
/// <summary> /// Populate the controls. /// </summary> private void PopulateControls() { this.litHeaderText.Text = ((this.QueryID > 0) ? "Edit " : "New ") + this.ActivePage.Heading; this.spanShipmentError.Visible = false; this.lblShipmentKeyAddress.Text = string.Empty; this.btnIndimanInvoice.Visible = (this.QueryID > 0) ? true : false; var daysTillMonday = (int)DateTime.Today.DayOfWeek - (int)DayOfWeek.Monday; var monday = DateTime.Today.AddDays(-daysTillMonday); // populate RadComboWeek this.RadComboWeek.Items.Clear(); List <WeeklyProductionCapacityBO> lstWeeklyCapacities; if (this.QueryID > 0) { lstWeeklyCapacities = (new WeeklyProductionCapacityBO()).SearchObjects().ToList(); } else { lstWeeklyCapacities = (new WeeklyProductionCapacityBO()).SearchObjects().Where(o => o.WeekendDate >= DateTime.Now.AddMonths(-1) && o.WeekendDate.Year >= DateTime.Now.Year).ToList(); } //List<WeeklyProductionCapacityBO> this.RadComboWeek.DataSource = lstWeeklyCapacities; this.RadComboWeek.DataBind(); // populate Invoice Status this.ddlStatus.Items.Clear(); this.ddlStatus.Items.Add(new ListItem("Select a Status", "0")); List <InvoiceStatusBO> lstStatus = (new InvoiceStatusBO()).GetAllObject().OrderBy(o => o.Name).ToList(); foreach (InvoiceStatusBO ins in lstStatus) { this.ddlStatus.Items.Add(new ListItem(ins.Name, ins.ID.ToString())); } //populate Bank this.ddlBank.Items.Clear(); this.ddlBank.Items.Add(new ListItem("Select a Bank", "0")); List <BankBO> lstBanks = (new BankBO()).GetAllObject(); foreach (BankBO bank in lstBanks) { this.ddlBank.Items.Add(new ListItem(bank.Name + " - " + bank.AccountNo, bank.ID.ToString())); } //populate bill to this.PopulateBillTo(); // populate Destination Port this.ddlShipToPort.Items.Clear(); this.ddlShipToPort.Items.Add(new ListItem("Select Destination Port", "0")); List <DestinationPortBO> lstDestinationPort = (new DestinationPortBO()).GetAllObject(); foreach (DestinationPortBO ds in lstDestinationPort) { this.ddlShipToPort.Items.Add(new ListItem(ds.Name, ds.ID.ToString())); } // Populate Country this.ddlShipToCountry.Items.Clear(); this.ddlShipToCountry.Items.Add(new ListItem("Select Country", "0")); List <CountryBO> lstCountries = (new CountryBO()).GetAllObject().OrderBy(o => o.ShortName).ToList(); foreach (CountryBO country in lstCountries) { this.ddlShipToCountry.Items.Add(new ListItem(country.ShortName, country.ID.ToString())); } Session["InvoiceOrderDetails"] = null; this.populateInvoiceOrders(); if (this.QueryID > 0) { InvoiceBO objInvoice = new InvoiceBO(); objInvoice.ID = this.QueryID; objInvoice.GetObject(); this.RadComboWeek.Items.FindItemByValue(objInvoice.WeeklyProductionCapacity.ToString()).Selected = true; //this.PopulateShipmentDates(this.GetWeeklyProductionCapacityDetails(objInvoice.WeeklyProductionCapacity).WeekendDate, (int)objInvoice.WeeklyProductionCapacity); //this.PopulateShipmentDates(objInvoice.ShipmentDate, (int)objInvoice.WeeklyProductionCapacity); this.PopulateInvoiceShipmentDates(objInvoice.objWeeklyProductionCapacity.WeekendDate, (int)objInvoice.WeeklyProductionCapacity); this.ddlShipmentDates.Items.FindByText(objInvoice.ShipmentDate.ToString("dd MMMM yyyy")).Selected = true; this.PopulateShipmentKey(objInvoice.ShipmentDate); this.txtInvoiceDate.Text = objInvoice.InvoiceDate.ToString("dd MMMM yyyy"); this.txtAwbNo.Text = objInvoice.AWBNo; this.txtShipTo.Text = objInvoice.objShipTo.CompanyName; this.txtShipmentMode.Text = objInvoice.objShipmentMode.Name; this.RadComboShipmentKey.Enabled = false; this.txtInvoiceNo.Text = objInvoice.InvoiceNo; this.txtIndimanInvoiceNo.Text = objInvoice.IndimanInvoiceNo; this.ddlStatus.Items.FindByValue(objInvoice.Status.ToString()).Selected = true; this.chkIsBillTo.Checked = (bool)objInvoice.IsBillTo; this.ddlBillTo.Items.FindByValue(objInvoice.BillTo.ToString()).Selected = true; this.ddlBank.Items.FindByValue(objInvoice.Bank.ToString()).Selected = true; ViewState["DistributorClientAddress"] = objInvoice.ShipTo; ViewState["ShipmentID"] = objInvoice.ShipmentMode; DistributorClientAddressBO objDistributorClientAddress = new DistributorClientAddressBO(); objDistributorClientAddress.ID = objInvoice.ShipTo; objDistributorClientAddress.GetObject(); string state = (objDistributorClientAddress.State != null) ? objDistributorClientAddress.Suburb : string.Empty; this.lblShipmentKeyAddress.Text = objDistributorClientAddress.CompanyName + " , " + objDistributorClientAddress.Address + " , " + objDistributorClientAddress.Suburb + " " + state + " , " + objDistributorClientAddress.objCountry.ShortName + " , " + objDistributorClientAddress.PostCode; //is logged user role Factory Admin or Coordinator RadInvoice.Columns[13].Visible = false; this.populateInvoiceOrders(this.QueryID, objInvoice.ShipTo, false, objInvoice.ShipmentMode, false); } // if Redirect From WeeklySummary Page if (this.WeeklyCapacityDate != new DateTime(1100, 1, 1)) { this.RadComboWeek.Items.FindItemByValue(this.WeeklyCapacityID.ToString()).Selected = true; // this.PopulateShipmentKey(this.WeeklyCapacityID); this.PopulateShipmentDates(this.WeeklyCapacityDate, this.WeeklyCapacityID); } }