2

WinForm C# Application working good with ZK sdk but now need to connect from XAF Cross Platfor App with zk device or other sdk suitable device data received. Thank you in advanced.

Connect ZK Device on C# WinForm >

private void buttonGetNetworkDeviceOne_Click(object sender, EventArgs e)
{
    Cursor = Cursors.WaitCursor;
    int ret = sta_ConnectTCP(lbSysOutputInfo, comboBoxIpDeviceOne.Text.Trim(), textBoxPortDeviceOne.Text.Trim(), textBoxCommKeyDeviceOne.Text.Trim());
    if (GetConnectState())
    {
        sta_getBiometricType();
    }
    if (ret == 1)
    {
        this.textBoxIpDeviceOne.ReadOnly = true;
        this.textBoxPortDeviceOne.ReadOnly = true;
        this.textBoxCommKeyDeviceOne.ReadOnly = true;
        this.comboBoxIpDeviceOne.Enabled = false;
        
        labelStatusDeviceOne.Text = "Established Device/Network ✔";
        labelStatusDeviceOne.ForeColor = Color.Green;

        getDeviceInfo();

        buttonGetNetworkDeviceOne.Text = "Network Established ";
        buttonConnectDeviceOne.Refresh();

    }
    else if (ret == -2)
    {
        labelStatusDeviceOne.Text = "Not Established ";
        labelStatusDeviceOne.ForeColor = Color.Red;

        buttonGetNetworkDeviceOne.Text = " Get Network";

        buttonConnectDeviceOne.Refresh();
        this.textBoxIpDeviceOne.ReadOnly = false;
        this.textBoxPortDeviceOne.ReadOnly = false;
        this.textBoxCommKeyDeviceOne.ReadOnly = false;


        this.comboBoxIpDeviceOne.Enabled = true;

    }
    Cursor = Cursors.Default;
}

Retrieve Data From ZK Device (Live) -> These C# WinForm code is working good >> and need to start XAF Devexpress(XAF) cross platform software.

private void buttonSaveAttendanceDeviceOne_Click(object sender, EventArgs e)
{

    if ((textBoxDeviceOneMac.Text == "00:17:61:12:XX:XX") || (textBoxDeviceOneMac.Text == "00:17:61:10:XX:XX")) // Device One MAC
    {

        if (textBoxConnStringDeviceOne.Text == "")
        {
            MessageBox.Show("Please gain data server details~!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
        else
        {
            try
            {
                SqlConnection con = new SqlConnection(textBoxConnStringDeviceOne.Text);

                if (MessageBox.Show("Capture Data Saved", "Capture Window", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    for (int i = 0; i < dataGridViewDeviceOne.Rows.Count; i++)
                    {
                        SqlCommand cmd = new SqlCommand(textBoxSqlCommandExecuteDeviceOne.Text.ToString(), con);

                        cmd.Parameters.AddWithValue("@mrid", dataGridViewDeviceOne.Rows[i].Cells[0].Value.ToString()); // MachineRegisteredId
                        cmd.Parameters.AddWithValue("@vdt", dataGridViewDeviceOne.Rows[i].Cells[1].Value.ToString());
                        cmd.Parameters.AddWithValue("@vt", dataGridViewDeviceOne.Rows[i].Cells[2].Value.ToString());
                        cmd.Parameters.AddWithValue("@vs", dataGridViewDeviceOne.Rows[i].Cells[3].Value.ToString());
                        //cmd.Parameters.AddWithValue("@iTime", Convert.ToDateTime(dataGridViewDeviceOne.Rows[i].Cells[5].Value.ToString()).ToString("dd/mm/yyyy"));
                        cmd.Parameters.AddWithValue("@idt", dataGridViewDeviceOne.Rows[i].Cells[4].Value.ToString());
                        cmd.Parameters.AddWithValue("@odt", dataGridViewDeviceOne.Rows[i].Cells[5].Value.ToString());

                        cmd.Parameters.AddWithValue("@it", dataGridViewDeviceOne.Rows[i].Cells[6].Value);
                        cmd.Parameters.AddWithValue("@ot", dataGridViewDeviceOne.Rows[i].Cells[7].Value);

                        cmd.Parameters.AddWithValue("@wc", dataGridViewDeviceOne.Rows[i].Cells[8].Value.ToString());

                        cmd.Parameters.AddWithValue("@im", dataGridViewDeviceOne.Rows[i].Cells[9].Value.ToString());
                        cmd.Parameters.AddWithValue("@om", dataGridViewDeviceOne.Rows[i].Cells[10].Value.ToString());

                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();


                    }
                    MessageBox.Show("Data Saved", "Data", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No Data!", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
    else
    {
        MessageBox.Show("Network/Device Program Not Valid \nCheck programable device/network", "Network/Device Validation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    }

}

C# DataGridView data to show DevExpress (XAF) ListView Request for help please. How may I connect device from XAF.

IT_
  • 21
  • 3

0 Answers0