Example #1
0
 private void simpleButton8_Click(object sender, EventArgs e)
 {
     if (gridView2.FocusedRowHandle > -1)
     {
         FrmRemoteAddOrEdit frm = new FrmRemoteAddOrEdit(gridView2.GetFocusedRowCellValue("Name").ToString(),
                                                         gridView2.GetFocusedRowCellValue("ServerIP").ToString(),
                                                         gridView2.GetFocusedRowCellValue("ServerPort").ToString(),
                                                         gridView2.GetFocusedRowCellValue("ServerUserName").ToString(),
                                                         gridView2.GetFocusedRowCellValue("ServerPwd").ToString(),
                                                         gridView2.GetFocusedRowCellValue("ServerRemark").ToString());
         if (frm.ShowDialog() == DialogResult.OK)
         {
             if (File.Exists(remotefile))
             {
                 DataSet ds = new DataSet();
                 ds.ReadXml(remotefile, XmlReadMode.ReadSchema);
                 for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                 {
                     if (ds.Tables[0].Rows[i]["Id"].ToString() == gridView2.GetFocusedRowCellValue("Id").ToString())
                     {
                         ds.Tables[0].Rows[i]["Name"]           = frm.sName;
                         ds.Tables[0].Rows[i]["ServerIP"]       = frm.sServerIP;
                         ds.Tables[0].Rows[i]["ServerPort"]     = frm.sServerPort;
                         ds.Tables[0].Rows[i]["ServerUserName"] = frm.sServerUserName;
                         ds.Tables[0].Rows[i]["ServerPwd"]      = frm.sServerPwd;
                         ds.Tables[0].Rows[i]["ServerRemark"]   = frm.sServerRemark;
                         ds.WriteXml(remotefile, XmlWriteMode.WriteSchema);
                         LoadDataRemote();
                         break;
                     }
                 }
             }
         }
     }
 }
Example #2
0
        private void simpleButton7_Click(object sender, EventArgs e)
        {
            FrmRemoteAddOrEdit frm = new FrmRemoteAddOrEdit();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (File.Exists(remotefile))
                {
                    DataSet ds = new DataSet();
                    ds.ReadXml(remotefile, XmlReadMode.ReadSchema);
                    DataRow row = ds.Tables[0].NewRow();
                    row["Id"]             = Guid.NewGuid().ToString();
                    row["Name"]           = frm.sName;
                    row["ServerIP"]       = frm.sServerIP;
                    row["ServerPort"]     = frm.sServerPort;
                    row["ServerUserName"] = frm.sServerUserName;
                    row["ServerPwd"]      = frm.sServerPwd;
                    row["ServerRemark"]   = frm.sServerRemark;
                    ds.Tables[0].Rows.Add(row);
                    ds.WriteXml(remotefile, XmlWriteMode.WriteSchema);
                    LoadDataRemote();
                }
                else
                {
                    DataSet   ds    = new DataSet();
                    DataTable table = new DataTable();
                    table.Columns.Add("Id");
                    table.Columns.Add("Name");
                    table.Columns.Add("ServerIP");
                    table.Columns.Add("ServerPort");
                    table.Columns.Add("ServerUserName");
                    table.Columns.Add("ServerPwd");
                    table.Columns.Add("ServerRemark");

                    DataRow row = table.NewRow();
                    row["Id"]             = Guid.NewGuid().ToString();
                    row["Name"]           = frm.sName;
                    row["ServerIP"]       = frm.sServerIP;
                    row["ServerPort"]     = frm.sServerPort;
                    row["ServerUserName"] = frm.sServerUserName;
                    row["ServerPwd"]      = frm.sServerPwd;
                    row["ServerRemark"]   = frm.sServerRemark;
                    table.Rows.Add(row);
                    ds.Tables.Add(table);
                    ds.WriteXml(remotefile, XmlWriteMode.WriteSchema);
                    LoadDataRemote();
                }
            }
        }