protected void dgvOrganisations_OnRowEditing(object sender, GridViewEditEventArgs e) { Utilities.editId = int.Parse(dgvOrganisations.DataKeys[e.NewEditIndex].Value.ToString()); OrganisationDataSet orgDS = dataProvider.GetOwnerOrganisationByID(Utilities.userToken, Utilities.editId); Session.RemoveAll(); e.Cancel = true; txtOrgName.Text = orgDS.Organisation[0].Name; //get text from selected row txtOrgCode.Text = orgDS.Organisation[0].SMSName; txtOrgAddress1.Text = orgDS.Organisation[0].OfficeAddress1; txtOrgAddress2.Text = orgDS.Organisation[0].OfficeAddress2; txtOrgAddress3.Text = orgDS.Organisation[0].OfficeAddress3; txtOrgPOBox1.Text = orgDS.Organisation[0].PostAddress1; txtOrgPOBox2.Text = orgDS.Organisation[0].PostAddress2; txtOrgPOBox3.Text = orgDS.Organisation[0].PostAddress3; txtOrgTelephone.Text = orgDS.Organisation[0].Telephone; txtOrgFax.Text = orgDS.Organisation[0].Fax; txtOrgEmail.Text = orgDS.Organisation[0].Email; txtOrgFacebook.Text = orgDS.Organisation[0].Facebook; txtOrgTwitter.Text = orgDS.Organisation[0].Twitter; txtOrgGoogle.Text = orgDS.Organisation[0].Google; chkOrgActive.Checked = orgDS.Organisation[0].Active; chkOrgActive.Enabled = true; var jsHelper = (Label)Master.Master.FindControl("LblJsHelper"); //get label in master page if (jsHelper != null) { jsHelper.Text = "<script>$('#myModal').modal('show')</script>"; //if not null inject js to show modal } }
protected void Page_Load(object sender, EventArgs e) { Utilities.pageName = "btnManageOrganisations"; removeInjectedScript(); if (Session["orgParams"] == null) { Response.Redirect("/LandingPage.aspx"); } else { catDS = (OrganisationDataSet)Session["orgParams"]; } if (!IsPostBack) { LoadCategoriesCB(); } DisplayCategoriesInGrid(true); }
private void btnAddNewEmployee_Click(object sender, EventArgs e) { OrganisationDataSet ds = new OrganisationDataSet(); departmentTableAdapter1.Fill(ds.Department); employeeTableAdapter1.Fill(ds.Employee); string str = string.Empty; foreach (OrganisationDataSet.EmployeeRow drEmp in ds.Employee.Rows) { str += drEmp.EmpId + "\t" + drEmp.EmpName + "\t" + drEmp.Salary + "\n"; } MessageBox.Show(str); OrganisationDataSet.EmployeeRow dr = ds.Employee.NewEmployeeRow(); dr.EmpName = "Jat"; dr.Salary = 2300; dr.DeptId = 1; ds.Employee.AddEmployeeRow(dr); employeeTableAdapter1.Update(ds); }
protected void btnSaveAlertSMS_OnClick(object sender, EventArgs e) { if (Session["placeholderLength"] == null) { Session["placeholderLength"] = "0"; } if ((txtSMS.Text.Length - int.Parse(Session["placeholderLength"].ToString())) > 160) { smsOverflow.Visible = true; return; } DateTime _sendDate; int _msgType; if (txtDaysBeforeAfterSMS.Text == "") { txtDaysBeforeAfterSMS.Text = "0"; } if (emailId.Value == "") { emailId.Value = "0"; } if (smsId.Value == "") { smsId.Value = "0"; } if (messagetypes.SelectedValue == "1") { TimeSpan sub = new TimeSpan(int.Parse(txtDaysBeforeAfterSMS.Text), 0, 0, 0); _sendDate = DateTime.Parse(Session["beginDate"].ToString()).Subtract(sub); _msgType = 1; } else if (messagetypes.SelectedValue == "2") { _sendDate = DateTime.Parse(Session["beginDate"].ToString()); _msgType = 2; } else if (messagetypes.SelectedValue == "3") { TimeSpan add = new TimeSpan(int.Parse(txtDaysBeforeAfterSMS.Text), 0, 0, 0); _sendDate = DateTime.Parse(Session["endDate"].ToString()).Add(add); _msgType = 3; } else { SetToast("error", "Select a message type!"); return; } bool _isUser; if (recipients.SelectedValue == "True") { _isUser = true; } else if (recipients.SelectedValue == "False") { _isUser = false; } else { SetToast("error", "Select a recipient!"); return; } var orgDs = new OrganisationDataSet(); orgDs = dataProvider.GetOwnerOrganisationByID(userToken, Utilities.companyId); var smsDS = new SMSDataSet(); smsDS.SMS.AddSMSRow(int.Parse(smsId.Value), eventId, txtSMS.Text, orgDs.Organisation[0].SMSName, _sendDate, _isUser, false, _msgType, eventNameParam); if (Utilities.editId == 2 || Utilities.editId == 4) { int result = dataProvider.UpdateEventAlertSMS(userToken, smsDS); if (result != -1) { SetToast("success", "Event Alert SMS updated"); } else { SetToast("error", "Event Alert SMS type exists already."); } } else { int result = dataProvider.AddEventAlertSMS(userToken, smsDS); if (result != -1) { SetToast("success", "Event Alert SMS added"); } else { SetToast("error", "Event Alert SMS type exists already."); } } smsOverflow.Visible = false; initFields(); }
protected void btnsavefacility_OnClick(object sender, EventArgs e) { if (Utilities.editId == -1) { var orgDS = new OrganisationDataSet(); orgDS.Organisation.AddOrganisationRow(Utilities.editId, txtOrgName.Text, "", txtOrgAddress1.Text, txtOrgAddress2.Text, txtOrgAddress3.Text, txtOrgAddress1.Text + "," + txtOrgAddress2.Text + "," + txtOrgAddress3.Text, txtOrgPOBox1.Text, txtOrgPOBox2.Text, txtOrgPOBox3.Text, txtOrgPOBox1.Text + "," + txtOrgPOBox2.Text + "," + txtOrgPOBox3.Text, txtOrgTelephone.Text, txtOrgFax.Text, txtOrgEmail.Text, chkOrgActive.Checked, txtOrgFacebook.Text, txtOrgTwitter.Text, txtOrgGoogle.Text, txtOrgCode.Text); if (Utilities.CheckGridForText(dgvOrganisations, txtOrgName.Text)) { SetToast("info", "Organisation exists already."); return; } else { Utilities.editId = dataProvider.AddOwnerOrganiasation(Utilities.userToken, orgDS); } } var orgDS2 = new OrganisationDataSet(); orgDS2.Organisation.AddOrganisationRow(Utilities.editId, txtOrgName.Text, "", txtOrgAddress1.Text, txtOrgAddress2.Text, txtOrgAddress3.Text, txtOrgAddress1.Text + "," + txtOrgAddress2.Text + "," + txtOrgAddress3.Text, txtOrgPOBox1.Text, txtOrgPOBox2.Text, txtOrgPOBox3.Text, txtOrgPOBox1.Text + "," + txtOrgPOBox2.Text + "," + txtOrgPOBox3.Text, txtOrgTelephone.Text, txtOrgFax.Text, txtOrgEmail.Text, chkOrgActive.Checked, txtOrgFacebook.Text, txtOrgTwitter.Text, txtOrgGoogle.Text, txtOrgCode.Text); Session["orgParams"] = orgDS2; Session["catType"] = true; Utilities.pageName = "btnManageOrganisations"; Utilities.editId = -1; Response.Redirect("/Admin/OrganisationCategories.aspx"); /*if (Utilities.editId != -1) { int result = dataProvider.UpdateOwnerOrganiasations(Utilities.userToken,orgDS); if (result != -1) { SetToast("success","The Organisation has been succesfully updated!"); Utilities.editId = -1; btnCloseModal_OnClick(sender,e); } else { SetToast("error","An error has occured, please try again."); } } else { if (!Utilities.CheckGridForText(dgvOrganisations, txtOrgName.Text)) { int result = dataProvider.AddOwnerOrganiasation(Utilities.userToken, orgDS); if (result != -1) { Utilities.editId = -1; SetToast("success","Organisation has been created succesfully."); } else { SetToast("error","An error has occurred, please try again."); } } else { SetToast("info","Organisation already exists!"); } DisplayOrganisationsInGrid(); } DisplayOrganisationsInGrid();*/ }
public OrganisationDataSet GetOwnerOrganisationByID(string userToken,int orgId) { var retDataset = new OrganisationDataSet(); if(IsUserTokenValid(userToken)){ try { conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "spGetOwnerOrgById"; var p = new SqlParameter("id", orgId); cmd.Parameters.Add(p); SqlDataReader reader = cmd.ExecuteReader(); if (reader != null) { while (reader.Read()) { var orgDS = retDataset.Organisation.NewOrganisationRow(); orgDS.Id = int.Parse(reader["Id"].ToString()); orgDS.Name = reader["Name"].ToString(); orgDS.SMSName = reader["SMSName"].ToString(); orgDS.Code = reader["Code"].ToString(); orgDS.OfficeAddress1 = reader["OfficeAddress1"].ToString(); orgDS.OfficeAddress2 = reader["OfficeAddress2"].ToString(); orgDS.OfficeAddress3 = reader["OfficeAddress3"].ToString(); orgDS.OfficeAddress = reader["OfficeAddress"].ToString(); orgDS.PostAddress1 = reader["PostAddress1"].ToString(); orgDS.PostAddress2 = reader["PostAddress2"].ToString(); orgDS.PostAddress3 = reader["PostAddress3"].ToString(); orgDS.PostAddress = reader["PostAddress"].ToString(); orgDS.Telephone = reader["Telephone"].ToString(); orgDS.Fax = reader["Fax"].ToString(); orgDS.Email = reader["Email"].ToString(); orgDS.Facebook = reader["Facebook"].ToString(); orgDS.Twitter = reader["Twitter"].ToString(); orgDS.Google = reader["Google"].ToString(); orgDS.Active = bool.Parse(reader["Active"].ToString()); retDataset.Organisation.AddOrganisationRow(orgDS); } reader.Close(); } } catch (Exception ex) { throw new OperationFailedException(ex.Message, ex); } finally { if (conn.State != System.Data.ConnectionState.Closed) { conn.Close(); } } } return retDataset; }
public int AddOwnerOrganiasation(string userToken, OrganisationDataSet OrganisationDS) { int newId = -1; if (IsUserTokenValid(userToken)) { try { conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "spAddOwnerOrg"; var p2 = new SqlParameter[16]; for (int i = 0; i < 16; i++) p2[i] = new SqlParameter(); p2[0] = new SqlParameter("name", OrganisationDS.Organisation[0].Name); p2[1] = new SqlParameter("code", OrganisationDS.Organisation[0].Code); p2[2] = new SqlParameter("offAddress1", OrganisationDS.Organisation[0].OfficeAddress1); p2[3] = new SqlParameter("offAddress2", OrganisationDS.Organisation[0].OfficeAddress2); p2[4] = new SqlParameter("offAddress3", OrganisationDS.Organisation[0].OfficeAddress3); p2[5] = new SqlParameter("postAddress1", OrganisationDS.Organisation[0].PostAddress1); p2[6] = new SqlParameter("postAddress2", OrganisationDS.Organisation[0].PostAddress2); p2[7] = new SqlParameter("postAddress3", OrganisationDS.Organisation[0].PostAddress3); p2[8] = new SqlParameter("telephone", OrganisationDS.Organisation[0].Telephone); p2[9] = new SqlParameter("fax", OrganisationDS.Organisation[0].Fax); p2[10] = new SqlParameter("email", OrganisationDS.Organisation[0].Email); p2[11] = new SqlParameter("facebook", OrganisationDS.Organisation[0].Facebook); p2[12] = new SqlParameter("twitter", OrganisationDS.Organisation[0].Twitter); p2[13] = new SqlParameter("google", OrganisationDS.Organisation[0].Google); p2[14] = new SqlParameter("updateUser", _userId); p2[15] = new SqlParameter("smsName", OrganisationDS.Organisation[0].SMSName); cmd.Parameters.AddRange(p2); newId = int.Parse(cmd.ExecuteScalar().ToString()); if (conn.State != System.Data.ConnectionState.Closed) { conn.Close(); } //SetCategoriesForOrganisation(newId, categories); } catch (Exception ex) { throw new OperationFailedException(ex.Message, ex); } finally { if (conn.State != ConnectionState.Closed) { conn.Close(); } } } return newId; }
protected void btnSaveAlertSMS_OnClick(object sender, EventArgs e) { if (Session["placeholderLength"] == null) Session["placeholderLength"] = "0"; if ((txtSMS.Text.Length - int.Parse(Session["placeholderLength"].ToString())) > 160) { smsOverflow.Visible = true; return; } DateTime _sendDate; int _msgType; if (txtDaysBeforeAfterSMS.Text == "") txtDaysBeforeAfterSMS.Text = "0"; if (emailId.Value == "") emailId.Value = "0"; if (smsId.Value == "") smsId.Value = "0"; if (messagetypes.SelectedValue == "1") { TimeSpan sub = new TimeSpan(int.Parse(txtDaysBeforeAfterSMS.Text), 0, 0, 0); _sendDate = DateTime.Parse(Session["beginDate"].ToString()).Subtract(sub); _msgType = 1; } else if (messagetypes.SelectedValue == "2") { _sendDate = DateTime.Parse(Session["beginDate"].ToString()); _msgType = 2; } else if (messagetypes.SelectedValue == "3") { TimeSpan add = new TimeSpan(int.Parse(txtDaysBeforeAfterSMS.Text), 0, 0, 0); _sendDate = DateTime.Parse(Session["endDate"].ToString()).Add(add); _msgType = 3; } else { SetToast("error", "Select a message type!"); return; } bool _isUser; if (recipients.SelectedValue == "True") { _isUser = true; } else if (recipients.SelectedValue == "False") { _isUser = false; } else { SetToast("error", "Select a recipient!"); return; } var orgDs = new OrganisationDataSet(); orgDs = dataProvider.GetOwnerOrganisationByID(userToken, Utilities.companyId); var smsDS = new SMSDataSet(); smsDS.SMS.AddSMSRow(int.Parse(smsId.Value), eventId, txtSMS.Text, orgDs.Organisation[0].SMSName, _sendDate, _isUser, false, _msgType, eventNameParam); if (Utilities.editId == 2 || Utilities.editId == 4) { int result = dataProvider.UpdateEventAlertSMS(userToken, smsDS); if (result != -1) { SetToast("success", "Event Alert SMS updated"); } else { SetToast("error", "Event Alert SMS type exists already."); } } else { int result = dataProvider.AddEventAlertSMS(userToken, smsDS); if (result != -1) { SetToast("success", "Event Alert SMS added"); } else { SetToast("error", "Event Alert SMS type exists already."); } } smsOverflow.Visible = false; initFields(); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); OrganisationDataSet ds = new OrganisationDataSet(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "OrganisationDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { OrganisationDataSet ds = new OrganisationDataSet(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
protected void btnsavefacility_OnClick(object sender, EventArgs e) { if (Utilities.editId == -1) { var orgDS = new OrganisationDataSet(); orgDS.Organisation.AddOrganisationRow(Utilities.editId, txtOrgName.Text, "", txtOrgAddress1.Text, txtOrgAddress2.Text, txtOrgAddress3.Text, txtOrgAddress1.Text + "," + txtOrgAddress2.Text + "," + txtOrgAddress3.Text, txtOrgPOBox1.Text, txtOrgPOBox2.Text, txtOrgPOBox3.Text, txtOrgPOBox1.Text + "," + txtOrgPOBox2.Text + "," + txtOrgPOBox3.Text, txtOrgTelephone.Text, txtOrgFax.Text, txtOrgEmail.Text, chkOrgActive.Checked, txtOrgFacebook.Text, txtOrgTwitter.Text, txtOrgGoogle.Text, txtOrgCode.Text); if (Utilities.CheckGridForText(dgvOrganisations, txtOrgName.Text)) { SetToast("info", "Organisation exists already."); return; } else { Utilities.editId = dataProvider.AddOwnerOrganiasation(Utilities.userToken, orgDS); } } var orgDS2 = new OrganisationDataSet(); orgDS2.Organisation.AddOrganisationRow(Utilities.editId, txtOrgName.Text, "", txtOrgAddress1.Text, txtOrgAddress2.Text, txtOrgAddress3.Text, txtOrgAddress1.Text + "," + txtOrgAddress2.Text + "," + txtOrgAddress3.Text, txtOrgPOBox1.Text, txtOrgPOBox2.Text, txtOrgPOBox3.Text, txtOrgPOBox1.Text + "," + txtOrgPOBox2.Text + "," + txtOrgPOBox3.Text, txtOrgTelephone.Text, txtOrgFax.Text, txtOrgEmail.Text, chkOrgActive.Checked, txtOrgFacebook.Text, txtOrgTwitter.Text, txtOrgGoogle.Text, txtOrgCode.Text); Session["orgParams"] = orgDS2; Session["catType"] = true; Utilities.pageName = "btnManageOrganisations"; Utilities.editId = -1; Response.Redirect("/Admin/OrganisationCategories.aspx"); /*if (Utilities.editId != -1) * { * int result = dataProvider.UpdateOwnerOrganiasations(Utilities.userToken,orgDS); * * if (result != -1) * { * SetToast("success","The Organisation has been succesfully updated!"); * Utilities.editId = -1; * btnCloseModal_OnClick(sender,e); * } * else * { * SetToast("error","An error has occured, please try again."); * } * } * else * { * if (!Utilities.CheckGridForText(dgvOrganisations, txtOrgName.Text)) * { * int result = dataProvider.AddOwnerOrganiasation(Utilities.userToken, orgDS); * * if (result != -1) * { * Utilities.editId = -1; * SetToast("success","Organisation has been created succesfully."); * } * else * { * SetToast("error","An error has occurred, please try again."); * } * * } * else * { * SetToast("info","Organisation already exists!"); * } * * DisplayOrganisationsInGrid(); * } * * * DisplayOrganisationsInGrid();*/ }