using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ncLegalTrack;
using Telerik.Web.UI;
public partial class MailLog_Default2 : System.Web.UI.Page
{
private ncAuthentication oAuth = new ncAuthentication();
private udfTools oObj1 = new udfTools();
private oMailLog oLog = new oMailLog();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
TurnMasterPanelOFF(false);
LogDailyLogDataListing();
}
}
protected void btnAddNew_Click(object sender, EventArgs e)
{
//-this.lit_content.Text = "Adding New Record";
TurnMasterPanelOFF(true);
}
protected void btnCancel_Click(object sender, EventArgs e)
{
//LogDailyLogDataListing();
TurnMasterPanelOFF(false);
Response.Redirect("Default2.aspx");
}
protected void LogDailyLogDataListing()
{
string sDataFilter = "";
if (hdnFilter.Value != "") { sDataFilter = hdnFilter.Value; }
//- 20160827 - Validate Facility
int iFacilityId = oAuth.AuthenticatedFacilityId;
if (oAuth.IsAdministratorUser())
{
iFacilityId = 0;
}
SqlDataSource2.ConnectionString = oLog.oDbConnectionString;
SqlDataSource2.SelectCommand = oLog.GetSqlCommadStr(0, iFacilityId, sDataFilter);
this.RadGrid1.DataBind();
}
/*
protected void RadGrid_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
if (e.Column.HeaderText == "ID" || e.Column.HeaderText == "Date")
{
e.Column.FilterControlWidth = Unit.Pixel(40);
e.Column.HeaderStyle.Width = Unit.Pixel(90);
}
else if (e.Column is GridBoundColumn)
{
e.Column.FilterControlWidth = Unit.Pixel(120);
}
}
*/
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
/*
var products = Cache["products"] as DataTable;
if (products == null)
{
products = obj_Dataset.Tables["Products"];
Cache.Insert("products", products, null, DateTime.Now.AddHours(6), TimeSpan.Zero);
}
RadGrid1.DataSource = products;
*/
//string sDataFilter = "";
//if (hdnFilter.Value != "") { sDataFilter = hdnFilter.Value; }
//SqlDataSource2.ConnectionString = oLog.oDbConnectionString;
//SqlDataSource2.SelectCommand = oLog.GetSqlCommadStr(0, 0, sDataFilter);
//-this.RadGrid1.DataSource = GetDataTable();
//this.RadGrid1.DataBind();
}
protected void useLinkButton_Command(object sender, CommandEventArgs e)
{
int iLogId = oObj1.CTOI((String)(e.CommandArgument));
//TurnMasterPanelOFF(true);
/*
hdnId.Value = iLogId.ToString();
PopulateAllDropDownListingOnThisCurrentForm(sender, e);
oLog.LoadDailyLogDataFor(iLogId, 0, "");
this.lblDateEntered.Text = oLog.Date_Entered.ToShortDateString();
this.txtLogDate.Text = oLog.Log_Date;
this.ddlLogType.SelectedValue = oLog.Log_type;
if (oLog.Delivery_Method.Trim() != "")
{
this.ddlMethod.SelectedValue = oLog.Delivery_Method.Trim();
}
this.ddlClientName.SelectedValue = oLog.Client_Name;
this.ddlFacility.Text = oLog.Facility_Location.Trim();
this.txtLogNote.Text = oLog.Log_Note;
this.txtTrackingNumber.Text = oLog.Tracking_Number.Trim();
this.ddlLogStatus.SelectedValue = oLog.Log_Status;
Delivery_Tracking(oLog.Tracking_Number.Trim());
panel1.Visible = false;
panel2.Visible = true;
*/
}
protected void useDeleteLinkButton_Command(object sender, GridSelectCommandEventArgs e)
{
int iLogId = oObj1.CTOI((String)(e.CommandArgument));
oLog.DeleteMailLogData(iLogId);
LogDailyLogDataListing();
}
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.SelectCommandName)
{
string sSelectedRowValue = "Primary key for the clicked item from ItemCommand: " + (e.Item as GridDataItem).GetDataKeyValue("logId").ToString();
//oObj1.PopAlert(sSelectedRowValue, source);
}
if (e.CommandName == "InitInsert")
{
//- Add a new record
btnAddNew_Click(source, e);
}
if (e.CommandName == "RebindGrid")
{
//-LogDailyLogDataListing();
//-this.RadGrid1.DataBind();
Response.Redirect("Default2.aspx");
}
if (e.CommandName == "Cancel")
{
btnCancel_Click(source, e);
}
}
protected void RadGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
//-Response.Write("Primary key for the clicked item from SelectedIndexChanged: "
string sSelectedValue = "Primary key for the clicked item from SelectedIndexChanged: "
+ (RadGrid1.SelectedItems[0] as GridDataItem).GetDataKeyValue("logId").ToString();
string sSelectedRowId = (RadGrid1.SelectedItems[0] as GridDataItem).GetDataKeyValue("logId").ToString();
int iLogId = oObj1.CTOI(sSelectedRowId);
//-oObj1.PopAlert(sSelectedValue, sender);
hdnId.Value = iLogId.ToString();
oLog.LoadDailyLogDataFor(iLogId, 0, "");
hdnId.Value = iLogId.ToString();
PopulateAllDropDownListingOnThisCurrentForm(sender, e);
oLog.LoadDailyLogDataFor(iLogId, 0, "");
this.lblDateEntered.Text = oLog.Date_Entered.ToShortDateString();
this.txtLogDate.Text = oLog.Log_Date;
this.ddlLogType.SelectedValue = oLog.Log_type;
if (oLog.Delivery_Method.Trim() != "")
{
this.ddlMethod.SelectedValue = oLog.Delivery_Method.Trim();
}
this.ddlClientName.SelectedValue = oLog.Client_Name;
this.ddlFacility.Text = oLog.Facility_Location.Trim();
this.txtLogNote.Text = oLog.Log_Note;
this.txtTrackingNumber.Text = oLog.Tracking_Number.Trim();
this.ddlLogStatus.SelectedValue = oLog.Log_Status;
Delivery_Tracking(oLog.Tracking_Number.Trim());
TurnMasterPanelOFF(true);
}
protected void RadGrid1_OnDeleteCommand(object sender, GridCommandEventArgs e)
{
string sSelectedRowValueToDelete = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["logId"].ToString();
int iDeleteLogId = oObj1.CTOI(sSelectedRowValueToDelete);
if (iDeleteLogId > 0)
{
oLog.LoadDailyLogDataFor(iDeleteLogId, 0, "");
//lit_content.Text = oLog.Client_Name + " - " + iDeleteLogId.ToString() + " Deleted";
//-TurnMasterPanelOFF(true);
oObj1.PopAlert(oLog.Client_Name + " - " + iDeleteLogId.ToString() + " Deleted", sender);
btnCancel_Click(sender, e);
}
}
protected void RadGrid1_PageSizeChanged(object sender, GridPageSizeChangedEventArgs e)
{
LogDailyLogDataListing();
}
protected void RadGrid1_PageIndexChanged(object sender, Telerik.Web.UI.GridPageChangedEventArgs e)
{
LogDailyLogDataListing();
}
protected void RadGrid1_SortCommand(object sender, Telerik.Web.UI.GridSortCommandEventArgs e)
{
LogDailyLogDataListing();
}
private void DisplayMessage(bool isError, string text)
{
if (isError)
{
//this.Label1.Text = text;
this.Label3.Text = text;
}
else
{
//this.Label2.Text = text;
this.Label4.Text = text;
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
int iLogId = oObj1.CTOI(hdnId.Value);
//- int iFacilityId = oObj1.CTOI(this.ddlFacility.Text.Trim());
oLog.Log_Date = this.txtLogDate.Text.Trim();
oLog.Log_type = this.ddlLogType.Text.Trim();
oLog.Client_Name = this.ddlClientName.Text.Trim();
oLog.Delivery_Method = this.ddlMethod.Text.Trim();
oLog.FollowUp_Date = this.txtFollowUpDate.Text.Trim();
oLog.FollowUp_Name = this.ddlFollowUpName.SelectedItem.Text.Trim();
oLog.Facility_Location = this.ddlFacility.SelectedItem.Text.Trim();
oLog.Log_Note = this.txtLogNote.Text.Trim().Replace("'", "");
oLog.Tracking_Number = this.txtTrackingNumber.Text.Trim().Replace("'", "");
oLog.Entered_By = oAuth.AuthenticatedUserName.Trim();
oLog.Log_Status = this.ddlLogStatus.Text.Trim();
oLog.SaveDailyLogData(iLogId);
if (oLog.Record_Affected > 0)
{
this.msgBox1.ContentMessageText = "Successfully Saved";
if (iLogId == 0)
{
hdnId.Value = oLog.GetTheLastLogEntered(this.ddlFacility.SelectedItem.Text.Trim()).ToString();
}
LogDailyLogDataListing();
}
else
{
this.msgBox1.ContentMessageText = "Sorry, could not save your entry at this time, please try again later.";
}
}
protected void btnDiscard_Click(object sender, EventArgs e)
{
ResetAllControlOnThisCurrentForm(true);
PopulateAllDropDownListingOnThisCurrentForm(sender, e);
LogDailyLogDataListing();
hdnFilter.Value = "";
TurnMasterPanelOFF(false);
Response.Redirect("Default2.aspx");
}
protected void ResetAllControlOnThisCurrentForm(bool bNew)
{
oObj1.ResetAllControlOnForm(this);
hdnId.Value = "";
if (bNew)
{
this.txtLogDate.Text = DateTime.Now.ToShortDateString();
this.lblDateEntered.Text = DateTime.Now.ToShortDateString();
}
this.ddlLogStatus.SelectedValue = "SELECT";
this.ddlFacility.SelectedIndex = oObj1.GetSelectedItemIndex(ddlFacility, oAuth.AuthenticatedLocation, false);
}
protected void Delivery_Tracking(string pTrackingNumber)
{
this.imgbDelivery.Visible = false;
if (pTrackingNumber.Trim().Length > 0) //- https://
{
if (pTrackingNumber.Trim().ToUpper() != "NA" & pTrackingNumber.Trim().ToUpper() != "N/A")
{
this.imgbDelivery.Visible = true;
}
}
ncTrackingDelivery oTrack = new ncTrackingDelivery();
oTrack.GetTrackingInformation(pTrackingNumber);
this.imgbDelivery.ImageUrl = "~/images/icons/shipping_icon.png";
this.imgbDelivery.OnClientClick = oTrack.Window_Url;
//-this.imgbDelivery.PostBackUrl = oTrack.PostBackUrl;
oTrack.Dispose();
}
protected void PopulateAllDropDownListingOnThisCurrentForm(object sender, EventArgs e)
{
oFacilities oFacil = new oFacilities();
oFacil.StoreLocationDropDownListing(ddlFacility);
this.ddlFacility.SelectedIndex = oObj1.GetSelectedItemIndex(ddlFacility, oAuth.AuthenticatedLocation.Trim(), false);
//-this.ddlFacility.Items.Clear();
//-this.ddlFacility.Items.Add("--- SELECT ---");
//-this.ddlFacility.Items.Add("Orlando");
//-this.ddlFacility.Items.Add("Tampa");
//- IN OR OUT Bound mail
this.ddlLogType.Items.Clear();
this.ddlLogType.Items.Add("SELECT");
this.ddlLogType.Items.Add("Inbound");
this.ddlLogType.Items.Add("Outbound");
//- Method
this.ddlMethod.Items.Clear();
this.ddlMethod.Items.Add("--- SELECT ---");
this.ddlMethod.Items.Add("DHL Regular");
this.ddlMethod.Items.Add("FedEx Ground");
this.ddlMethod.Items.Add("FedEx Overnight");
this.ddlMethod.Items.Add("UPS Regular");
this.ddlMethod.Items.Add("UPS Overnight");
this.ddlMethod.Items.Add("Other");
this.ddlMethod.Items.Add("USPS Regular");
this.ddlMethod.Items.Add("USPS Priority");
this.ddlMethod.Items.Add("USPS Overnight");
//- Clients
oLog.DropDownCustomerListing(this.ddlClientName);
//- Staff
oEmployee oEmp = new oEmployee();
oEmp.EmployeeDropDownListing(ddlFollowUpName, 0);
}
protected void TurnMasterPanelOFF(bool pTurnOFF)
{
if (pTurnOFF)
{
panel1.Visible = false;
panel2.Visible = true;
}
else
{
panel2.Visible = false;
panel1.Visible = true;
}
}
}