-
Notifications
You must be signed in to change notification settings - Fork 1
/
CompanyListing.aspx.cs
69 lines (61 loc) · 2.48 KB
/
CompanyListing.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using MYOB.AccountRight.SDK;
using MYOB.AccountRight.SDK.Contracts;
using MYOB.AccountRight.SDK.Services;
using Web.Helpers;
namespace Web
{
public partial class Contact : Page
{
private static IApiConfiguration _configurationCloud;
private static IOAuthKeyService _oAuthKeyService;
private CompanyFile[] CompanyFiles;
protected void Page_Load(object sender, EventArgs e)
{
// Load all files from cloud and local simultaneously
lblCode.Text = SessionManager.Code;
var cfsCloud = new CompanyFileService(SessionManager.MyConfiguration, null, SessionManager.MyOAuthKeyService);
CompanyFile[] a = cfsCloud.GetRange();
CompanyFiles = a;
GridView1.DataSource = a;
GridView1.DataBind();
}
protected void GridViewData_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ShowPopup")
{
LinkButton btndetails = (LinkButton)e.CommandSource;
GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer;
lblID.Text = GridView1.DataKeys[gvrow.RowIndex].Value.ToString();
Popup(true);
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
CompanyFile companyFile = (CompanyFile)CompanyFiles.FirstOrDefault(a => a.Id == Guid.Parse(lblID.Text));//[e.RowIndex];
ICompanyFileCredentials credentials = new CompanyFileCredentials(txtUserName.Text, txtPassword.Text);
SessionManager.SelectedCompanyFile = companyFile;
SessionManager.MyCredentials = credentials;
Response.Redirect("SearchPage.aspx");
}
//To show message after performing operations
void Popup(bool isDisplay)
{
StringBuilder builder = new StringBuilder();
if (isDisplay)
{
builder.Append("<script language=JavaScript> ShowPopup(); </script>\n");
Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowPopup", builder.ToString());
}
else
{
builder.Append("<script language=JavaScript> HidePopup(); </script>\n");
Page.ClientScript.RegisterStartupScript(this.GetType(), "HidePopup", builder.ToString());
}
}
}
}