protected void btnSaveAdvertiser_Click(object sender, System.EventArgs e) { AdminController aCont = new AdminController(); AdvertiserInfo Advertiser = new AdvertiserInfo(); Advertiser.PortalId = PortalId; Advertiser.LastModifiedById = UserId; Advertiser.LastModifiedDate = DateTime.Now; Advertiser.AdvertiserName = txtAdvertiserName.Text; Advertiser.Carrier = Convert.ToInt32(ddlAdvertiserCarrier.SelectedValue); Advertiser.CarrierNumber = txtAdvertiserCarrierNum.Text; Advertiser.Freight = Convert.ToInt32(ddlAdvertiserFreight.SelectedValue); Advertiser.Address1 = txtAdvertiserAddress1.Text; Advertiser.Address2 = txtAdvertiserAddress2.Text; Advertiser.City = txtAdvertiserCity.Text; Advertiser.State = txtAdvertiserState.Text; Advertiser.Zip = txtAdvertiserZip.Text; Advertiser.Country = txtAdvertiserCountry.Text; Advertiser.Phone = txtAdvertiserPhone.Text; Advertiser.Fax = txtAdvertiserFax.Text; Advertiser.ClientType = Convert.ToInt16(ddlAdvertiserClientType.SelectedValue); Advertiser.CustomerReference = txtAdvertiserCustomerReference.Text; if (txtSelectedAdvertiser.Value == "-1") { //save new Advertiser Advertiser.CreatedById = UserId; Advertiser.DateCreated = DateTime.Now; int AdvertiserId = aCont.Add_Advertiser(Advertiser); //save advertiseragencies List <AgencyInfo> ags = new List <AgencyInfo>(); //aCont.Delete_AdvertiserAgencyByAdvertiserId(); foreach (ListItem li in ddlAdvertiserAgency.Items) { if (li.Selected) { aCont.Add_AdvertiserAgency(AdvertiserId, Convert.ToInt32(li.Value)); } } txtSelectedAdvertiser.Value = AdvertiserId.ToString(); txtAdvertiserCreatedBy.Value = UserId.ToString(); txtAdvertiserCreatedDate.Value = DateTime.Now.Ticks.ToString(); lblAdvertiserMessage.Text = "Advertiser Saved."; btnDeleteAdvertiser.Enabled = true; btnSaveAdvertiserAs.Enabled = true; } else { //update existing Advertiser AdvertiserInfo adv = aCont.Get_AdvertiserById(Convert.ToInt32(txtSelectedAdvertiser.Value)); Advertiser.QuickbooksListId = adv.QuickbooksListId; Advertiser.QuickbooksEditSequence = adv.QuickbooksEditSequence; Advertiser.QuickbooksErrNum = adv.QuickbooksErrNum; Advertiser.QuickbooksErrMsg = adv.QuickbooksErrMsg; Advertiser.CreatedById = Convert.ToInt32(txtAdvertiserCreatedBy.Value); Advertiser.DateCreated = new DateTime(Convert.ToInt64(txtAdvertiserCreatedDate.Value)); Advertiser.Id = Convert.ToInt32(txtSelectedAdvertiser.Value); aCont.Update_Advertiser(Advertiser); //save advertiseragencies List <AgencyInfo> ags = new List <AgencyInfo>(); aCont.Delete_AdvertiserAgencyByAdvertiserId(Advertiser.Id); foreach (ListItem li in ddlAdvertiserAgency.Items) { if (li.Selected) { aCont.Add_AdvertiserAgency(Advertiser.Id, Convert.ToInt32(li.Value)); } } lblAdvertiserMessage.Text = "Advertiser Updated."; } if (Application["Advertisers"] != null) { Application.Remove("Advertisers"); } FillAdvertiserList(); //fillDropDowns("Advertiser"); try { ddlAdvertiserClientType.SelectedValue = Advertiser.ClientType.ToString(); } catch { ddlAdvertiserClientType.SelectedIndex = 0; } try { ddlAdvertiserCarrier.SelectedValue = Advertiser.Carrier.ToString(); } catch { ddlAdvertiserCarrier.SelectedIndex = 0; } try { ddlAdvertiserFreight.SelectedValue = Advertiser.Freight.ToString(); } catch { ddlAdvertiserFreight.SelectedIndex = 0; } }
protected void Page_Load(object sender, EventArgs e) { AdminController aCont = new AdminController(); if (Tasks.Count() > 0) { lblWOId.Text = Tasks[0].WorkOrderId.ToString(); lblCompletionDate.Text = Tasks[0].DeliveryOrderDateComplete.ToShortDateString(); if (Tasks[0].CreatedById != -1) { UserInfo user = UserController.GetUserById(PortalId, Convert.ToInt32(Tasks[0].CreatedById)); lblOrderUser.Text = user.DisplayName; } lblDeliveryMethod.Text = Tasks[0].DeliveryMethod; WorkOrderInfo wo = aCont.Get_WorkOrderById(Tasks[0].WorkOrderId); AdvertiserInfo billTo = new AdvertiserInfo(); if (wo.BillToId != -1) { billTo = aCont.Get_AdvertiserById(wo.BillToId); } else { billTo = aCont.Get_AdvertiserById(wo.AdvertiserId); } litBillTo.Text = billTo.AdvertiserName + "<br />"; litBillTo.Text += billTo.Address1 + "<br />"; if (billTo.Address2 != "") { litBillTo.Text += billTo.Address2 + "<br />"; } litBillTo.Text += billTo.City + ", " + billTo.State + " " + billTo.Zip + "<br />"; WOGroupStationInfo wogroupStation = aCont.Get_WorkOrderGroupStationById(Tasks[0].StationId); StationInfo station = aCont.Get_StationById(wogroupStation.StationId); litShipTo.Text = station.StationName + "<br />"; litShipTo.Text += station.CallLetter + "<br />"; litShipTo.Text += station.Address1 + "<br />"; if (station.Address2 != "") { litShipTo.Text += station.Address2 + "<br />"; } if (station.Phone != "") { litShipTo.Text += "Tel: " + station.Phone + "<br />"; } if (station.Fax != "") { litShipTo.Text += "Fax: " + station.Fax + "<br />"; } if (station.Email != "") { litShipTo.Text += "Email: " + station.Email + "<br />"; } if (station.AttentionLine != "") { litShipTo.Text += "ATTENTION: " + station.AttentionLine + "<br />"; } litShipTo.Text += station.City + ", " + station.State + " " + station.Zip + "<br />"; plTasks.Controls.Clear(); foreach (TaskInfo Task in Tasks) { LibraryItemInfo lib = aCont.Get_LibraryItemById(Task.LibraryId); Literal lit = new Literal(); lit.Text = "<div class=\"pmtRow\"><div class=\"pmtCell2 outline\">" + Task.Quantity.ToString() + "</div>"; string desc = ""; try { desc = Task.Description.Substring(Task.Description.IndexOf("Station:"), (Task.Description.IndexOf(", Delivery Method")) - Task.Description.IndexOf("Station:")); } catch { } lit.Text += "<div class=\"pmtCell2 outline\">" + lib.Title + "</div>"; lit.Text += "<div class=\"pmtCell2 outline\">" + lib.ProductDescription + "</div>"; lit.Text += "<div class=\"pmtCell2 outline\">" + Task.DeliveryMethod + "</div>"; lit.Text += "<div class=\"pmtCell2 outline\">" + lib.MediaType.ToUpper() + "</div>"; lit.Text += "<div class=\"pmtCell2 outline\">" + lib.Standard + "</div>"; lit.Text += "<div class=\"pmtCell2 outline\">" + lib.MediaLength + "</div></div>"; plTasks.Controls.Add(lit); } } }
protected void gvAdvertiser_SelectedIndexChanged(object sender, System.EventArgs e) { FillAdvertiserList(); AdminController aCont = new AdminController(); txtSelectedAdvertiser.Value = (gvAdvertiser.SelectedRow.FindControl("hdngvAdvertiserId") as HiddenField).Value; AdvertiserInfo Advertiser = aCont.Get_AdvertiserById(Convert.ToInt32(txtSelectedAdvertiser.Value)); if (Advertiser.Id != -1) { btnDeleteAdvertiser.Enabled = true; btnSaveAdvertiserAs.Enabled = true; //ddlAdvertiserAgency.SelectedValue = Advertiser.Agency.ToString(); ddlAdvertiserAgency.ClearSelection(); foreach (ListItem li in ddlAdvertiserAgency.Items) { foreach (AgencyInfo adv in Advertiser.Agencies) { if (li.Value == adv.Id.ToString()) { li.Selected = true; } } } try { ddlAdvertiserCarrier.SelectedValue = Advertiser.Carrier.ToString(); } catch { ddlAdvertiserCarrier.SelectedIndex = 0; } txtAdvertiserCarrierNum.Text = Advertiser.CarrierNumber; try { ddlAdvertiserFreight.SelectedValue = Advertiser.Freight.ToString(); } catch { ddlAdvertiserFreight.SelectedIndex = 0; } txtAdvertiserAddress1.Text = Advertiser.Address1; txtAdvertiserAddress2.Text = Advertiser.Address2; txtAdvertiserCity.Text = Advertiser.City; txtAdvertiserCountry.Text = Advertiser.Country; txtAdvertiserCreatedBy.Value = Advertiser.CreatedById.ToString(); txtAdvertiserCreatedDate.Value = Advertiser.DateCreated.Ticks.ToString(); txtAdvertiserCustomerReference.Text = Advertiser.CustomerReference; txtAdvertiserFax.Text = Advertiser.Fax; txtAdvertiserName.Text = Advertiser.AdvertiserName; txtAdvertiserPhone.Text = Advertiser.Phone; txtAdvertiserState.Text = Advertiser.State; txtAdvertiserZip.Text = Advertiser.Zip; try { ddlAdvertiserClientType.SelectedValue = Advertiser.ClientType.ToString(); } catch { ddlAdvertiserClientType.SelectedIndex = 0; } //lblAdvertiserMessage.Text = ""; } else { btnDeleteAdvertiser.Enabled = false; btnSaveAdvertiserAs.Enabled = false; clearAdvertiser(); lblAdvertiserMessage.Text = "There was an error loading this Advertiser."; } //clearAll("Advertiser"); }
public string buildRequest(string ticket) { string req = ""; string[] custCodes = new string[6] { "CUSTOMIZATION 30 MIN", "HD CUSTOMIZATION 30 MIN", "SPOT CUSTOMIZATION", "HD CUSTOMIZATION SPOT", "CUSTOMIZATION 5 MIN", "HD CUSTOMIZATION 5 MIN" }; int custIndex = 2; int i = 1; string xmlString = ""; List <InvoiceInfo> invs = aCont.Get_InvoicesByToSend(); if (invs.Count > 0) { xmlString += "<?xml version=\"1.0\" encoding=\"utf-8\"?><?qbxml version=\"6.0\"?><QBXML><QBXMLMsgsRq onError=\"stopOnError\">"; //build array of xml foreach (InvoiceInfo inv in invs) { xmlString += "<InvoiceAddRq requestID=\"" + inv.Id.ToString() + "\"><InvoiceAdd>";// List <int> woIds = aCont.Get_WOInsByInvoiceId(inv.Id); if (woIds.Count > 0 && woIds[0] > 0) { WorkOrderInfo wo1 = aCont.Get_WorkOrderById(woIds[0]); AdvertiserInfo billto = aCont.Get_AdvertiserById(wo1.BillToId); if (billto.Id == -1) { billto = aCont.Get_AdvertiserById(wo1.AdvertiserId); } i++; xmlString += "<CustomerRef><FullName>" + billto.AdvertiserName.Trim().Replace("&", "&") + "</FullName></CustomerRef>"; xmlString += "<BillAddress><Addr1>" + billto.AdvertiserName.Trim().Replace("&", "&") + "</Addr1><Addr2>" + billto.Address1.Trim().Replace("&", "&"); if (billto.Address2.Trim() != "") { xmlString += " - " + billto.Address2.Trim().Replace("&", "&"); } xmlString += "</Addr2><City>" + billto.City.Trim().Replace("&", "&") + "</City><State>" + billto.State.Trim().Replace("&", "&") + "</State><PostalCode>" + billto.Zip.Trim().Replace("&", "&") + "</PostalCode><Country>" + billto.Country.Trim().Replace("&", "&") + "</Country></BillAddress>"; string po = wo1.PONumber; if (po == "") { try { po = wo1.Groups[0].LibraryItems[0].PMTMediaId.Replace("&", "&"); } catch { } } xmlString += "<PONumber>" + po.Replace("&", "&") + "</PONumber>"; if (woIds.Count == 1) { xmlString += "<FOB>WO: " + woIds[0].ToString() + "</FOB>"; } else if (woIds.Count > 1) { xmlString += "<FOB>SEE BELOW</FOB>"; } xmlString += "<Memo>" + inv.Id.ToString() + "</Memo>"; AgencyInfo ag = aCont.Get_AgencyById(wo1.AgencyId); xmlString += "<Other>" + ag.AgencyName.Trim().Replace("&", "&") + "</Other>"; foreach (int woId in woIds) { WorkOrderInfo wo = aCont.Get_WorkOrderById(woId); List <TaskInfo> tasks = aCont.Get_TasksByWOId(wo.Id); int groupId = -1; bool groupNew = true; for (int j = 0; j < tasks.Count; j++) { TaskInfo task = tasks[j]; if (groupId == -1) { groupId = task.WOGroupId; } if (task.WOGroupId != groupId) { groupNew = true; groupId = task.WOGroupId; } if (task.DeliveryStatus.ToLower() != "cancelled" && !task.isDeleted) { if (task.TaskType != GroupTypeEnum.Delivery) { WOGroupInfo group = aCont.Get_WorkOrderGroupById(task.WOGroupId); List <QBCodeInfo> servCodes = aCont.FindQBCodesByTask(task.Id, 0, true); LibraryItemInfo lib = aCont.Get_LibraryItemById(task.LibraryId); MasterItemInfo master = new MasterItemInfo(); if (task.TaskType == GroupTypeEnum.Non_Deliverable) { master = aCont.Get_MasterItemById(task.MasterId); } //foreach (ServiceInfo serv in group.Services) if (groupNew) { foreach (QBCodeInfo code in servCodes) { if (task.TaskType != GroupTypeEnum.Non_Deliverable) { xmlString += "<InvoiceLineAdd>"; xmlString += "<ItemRef><FullName>" + code.QBCode.Replace("&", "&") + "</FullName></ItemRef>"; xmlString += "<Desc>" + lib.Title.Replace("&", "&"); //code.QBCode.Replace("&", "&"); if (woIds.Count > 1 && j == 0) { xmlString += " WO " + wo.Id.ToString(); } xmlString += "</Desc>"; if (task.Quantity == 0) { task.Quantity = 1; } xmlString += "<Quantity>" + group.LibraryItems.Count.ToString() + "</Quantity>"; xmlString += "<Other1></Other1>"; xmlString += "<Other2></Other2></InvoiceLineAdd>"; } else { xmlString += "<InvoiceLineAdd>"; xmlString += "<ItemRef><FullName>" + code.QBCode.Replace("&", "&") + "</FullName></ItemRef>"; xmlString += "<Desc>" + master.Title.Replace("&", "&"); if (woIds.Count > 1 && j == 0) { xmlString += " WO " + wo.Id.ToString(); } xmlString += "</Desc>"; if (task.Quantity == 0) { task.Quantity = 1; } xmlString += "<Quantity>" + task.Quantity + "</Quantity>"; xmlString += "<Other1>" + lib.ProductDescription.Trim().Replace("&", "&") + "</Other1>"; xmlString += "<Other2>" + lib.ISCICode.Trim().Replace("&", "&") + "</Other2></InvoiceLineAdd>"; } } groupNew = false; } } if (task.TaskType == GroupTypeEnum.Bundle || task.TaskType == GroupTypeEnum.Delivery || task.TaskType == GroupTypeEnum.Customized) { LibraryItemInfo lib = aCont.Get_LibraryItemById(task.LibraryId); bool isHd = lib.MediaType.IndexOf("HD") != -1; string[] pcs = lib.MediaLength.Split(':'); int secs = 0; if (pcs.Length == 2) { try { secs = 60 * Convert.ToInt32(pcs[0]) + Convert.ToInt32(pcs[1]); } catch { } } if (secs <= 120 && !isHd) { custIndex = 2; } else if (secs <= 120 && isHd) { custIndex = 3; } else if (secs >= 1500 && secs <= 1800 && !isHd) { custIndex = 0; } else if (secs >= 1500 && secs <= 1800 && isHd) { custIndex = 1; } else if (secs >= 180 && secs <= 300 && !isHd) { custIndex = 4; } else if (secs >= 180 && secs <= 300 && !isHd) { custIndex = 5; } xmlString += "<InvoiceLineAdd>"; if (task.TaskType != GroupTypeEnum.Customized) { xmlString += "<ItemRef><FullName>" + task.QBCode.Trim().Replace("&", "&") + "</FullName></ItemRef>"; } else { xmlString += "<ItemRef><FullName>" + custCodes[custIndex] + "</FullName></ItemRef>"; } xmlString += "<Desc>" + lib.Title.Trim().Replace("&", "&"); if (woIds.Count > 1 && j == 0) { xmlString += " WO " + wo.Id.ToString(); } xmlString += "</Desc>"; if (task.Quantity == 0) { task.Quantity = 1; } xmlString += "<Quantity>" + task.Quantity + "</Quantity>"; xmlString += "<Other1>" + lib.ProductDescription.Trim().Replace("&", "&") + "</Other1>"; if (lib.TapeCode.Trim() == "") { xmlString += "<Other2>" + lib.ISCICode.Trim().Replace("&", "&") + "</Other2></InvoiceLineAdd>"; } else { xmlString += "<Other2>" + lib.TapeCode.Trim().Replace("&", "&") + "</Other2></InvoiceLineAdd>"; } WOGroupStationInfo station = aCont.Get_WorkOrderGroupStationById(task.StationId); if (station.DeliveryMethod.ToLower().IndexOf("tf_") != -1) { //check to see if we need to add shipping if (station.ShippingMethodId == -1) { int weight = 1; TapeFormatInfo tape = aCont.Get_TapeFormatById(Convert.ToInt32(station.DeliveryMethod.Replace("tf_", ""))); if (station.Quantity * tape.Weight > 1.0) { weight = 2; } string shippingPrice = ""; if (weight == 1) { if (station.PriorityId == 1) { shippingPrice = ConfigurationManager.AppSettings["FedEx1LbPriority"].ToString(); } else if (station.PriorityId == 2) { shippingPrice = ConfigurationManager.AppSettings["FedEx1LbStandard"].ToString(); } else if (station.PriorityId == 3) { shippingPrice = ConfigurationManager.AppSettings["FedEx1Lb2Day"].ToString(); } } else { if (station.PriorityId == 1) { shippingPrice = ConfigurationManager.AppSettings["FedEx2LbPriority"].ToString(); } else if (station.PriorityId == 2) { shippingPrice = ConfigurationManager.AppSettings["FedEx2LbStandard"].ToString(); } else if (station.PriorityId == 3) { shippingPrice = ConfigurationManager.AppSettings["FedEx2Lb2Day"].ToString(); } } xmlString += "<InvoiceLineAdd><ItemRef><FullName>SHIPPING</FullName></ItemRef><Desc>P" + station.PriorityId.ToString() + " " + weight.ToString() + "LB SHIPPING CHARGE</Desc><Quantity>1</Quantity><Rate>" + shippingPrice + "</Rate></InvoiceLineAdd>"; } } } } } } } xmlString += "</InvoiceAdd></InvoiceAddRq>"; //xmlString += ""; } xmlString += "</QBXMLMsgsRq></QBXML>"; req = xmlString; //} } return(req); }