Passing values between windows (defining common variables)

Source: Internet
Author: User

Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Linq;
Using System.Text;
Using System.Windows.Forms;

Namespace Yxsetingsystem
{
Public partial class form Rights Management Add Group : Form
{
public bool IsOK = FALSE;
public string Title = "";

Define public variables pno and pname

Public string pno = "";
public string pname = "";

public string PNO {get {return pname;} set {pname = value;}}

private void Button1_Click (object sender, EventArgs e)
{
This. Title = This.textBox1.Text.Trim ();

Assigning a value to pname equals this.textBox1.Text
This.pname = This.textBox1.Text;
This. IsOK = true;
Form Rights Management F = new form rights Management ();

Using the pname value in form Rights Management for forms
F.pname = This.pname;
This. Close ();
}

}
}

Pass the value of form Rights Management Add group to forms Rights Management

Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Linq;
Using System.Text;
Using System.Windows.Forms;
Using Yxtoolsystem;
Using Datasystem;

Namespace Yxsetingsystem
{
public partial class FORMF Rights Management : Form
{
Public string pno = "";
public string pname = "";

public bool IsOK = FALSE;
public string Pglno = "0";

void Save ()
{
String sql = "Delete from Powergroup where pgtitleno= '" + pno + "'";

for (int i = 0; i < THIS.CDGV permissions list. Rows.Count; i++)
{
list<yxtoolsystem.sqlstruct> col = new List<yxtoolsystem.sqlstruct> ();
Col. ADD (New Sqlstruct ("Pgtitleno",pno));
Col. ADD (New Sqlstruct ("Pgtitlename",pname));
Col. ADD (New Sqlstruct ("Pgpbno", THIS.CDGV permissions list. rows[i]. cells["Number"]. Value));
Col. ADD (New Sqlstruct ("Pgpbadd", (THIS.CDGV permission list. rows[i]. cells["Add"]. value.tostring () = = "√")));
Col. ADD (New Sqlstruct ("Pgpbame", (THIS.CDGV permission list. rows[i]. cells["Modify"]. value.tostring () = = "√")));
Col. ADD (New Sqlstruct ("Pgpbdel", (THIS.CDGV permission list. rows[i]. cells["Delete"]. value.tostring () = = "√")));
Col. ADD (New Sqlstruct ("Pgpbseeone", (THIS.CDGV permission list. rows[i]. cells["View Personal"]. value.tostring () = = "√")));
Col. ADD (New Sqlstruct ("Pgpbseedepartment", (THIS.CDGV permission list. rows[i]. cells["View Department"]. value.tostring () = = "√")));
Col. ADD (New Sqlstruct ("Pgpbseecompany", (THIS.CDGV permission list. rows[i]. cells["View Company"]. value.tostring () = = "√")));
Col. ADD (New Sqlstruct ("Pgpbseeall", (THIS.CDGV permission list. rows[i]. cells["View All"]. value.tostring () = = "√")));
SQL + = Sqlget.add (col, "Powergroup");
}
if (classdata.update (SQL) > 0)
{
MessageBox.Show ("Setup succeeded! ");
This. Close ();
}
Else
{
MessageBox.Show ("Setup failed! ");
}
}

}

}

Passing values between windows (defining common variables)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.