Exemple #1
0
 private void Reload_btn_Click(object sender, EventArgs e)
 {
     Reload_btn.Enabled = false;
     OCRUpdate.AssignForm();
 }
Exemple #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string        strSql                  = string.Empty;
            StringBuilder sbErrorMessage          = new StringBuilder();
            Dictionary <string, object> keyValues = new Dictionary <string, object>();
            DBUtil    dBUtil = new DBUtil();
            DataTable dtTemp = new DataTable();

            DataRow[] drsTemp;

            try
            {
                if (txbDeviceNodeName.Text.Trim().Equals(string.Empty) &&
                    cmbDeviceNodeType.SelectedIndex == -1 &&
                    nudSerialNo.Value == 0 &&
                    cmbVendor.SelectedIndex == -1 &&
                    txbModel.Text.Trim().Equals(string.Empty) &&
                    txbFirmwareVersion.Text.Trim().Equals(string.Empty) &&
                    txbAddress.Text.Trim().Equals(string.Empty) &&
                    txbControllerID.Text.Trim().Equals(string.Empty)
                    )
                {
                    MessageBox.Show("Miss input data in the form.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                    return;
                }

                if (txbDeviceNodeName.Text.Trim().Equals(string.Empty) ||
                    cmbDeviceNodeType.SelectedIndex == -1 || cmbVendor.SelectedIndex == -1)
                {
                    MessageBox.Show("Miss input data in the form.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                    return;
                }

                strSql = "select * from config_node where equipment_model_id = @equipment_model_id and node_type = @node_type order by node_id, sn_no";
                keyValues.Add("@equipment_model_id", SANWA.Utility.Config.SystemConfig.Get().SystemMode);
                keyValues.Add("@node_type", cmbDeviceNodeType.SelectedValue.ToString());
                dtTemp = dBUtil.GetDataTable(strSql, keyValues);

                if (dtTemp.Rows.Count > 0)
                {
                    if (dtTemp.Select("node_id in ('" + txbDeviceNodeName.Tag + "','" + cmbDeviceNodeType.Text + Convert.ToInt32(nudSerialNo.Value).ToString("D2") + "')").Length > 0)
                    {
                        sbErrorMessage.Append("Node ID exist.");
                        sbErrorMessage.AppendLine();
                    }

                    if (dtTemp.Select("sn_no = " + Convert.ToInt32(nudSerialNo.Value).ToString()).Length > 0)
                    {
                        sbErrorMessage.Append("Serial No exist.");
                        sbErrorMessage.AppendLine();
                    }

                    if (dtTemp.Select("controller_id = '" + txbControllerID.Text + "'").Length > 0)
                    {
                        sbErrorMessage.Append("Controller ID exist.");
                        sbErrorMessage.AppendLine();
                    }
                }

                if (sbErrorMessage.ToString().Length > 0)
                {
                    if (MessageBox.Show(sbErrorMessage.ToString() + "\r\n Do you want to overwrite???", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.No)
                    {
                        return;
                    }
                }

                keyValues.Clear();

                strSql = "REPLACE INTO config_node " +
                         "(equipment_model_id, node_id, node_type, sn_no, vendor, model_no, firmware_ver, conn_address, controller_id, bypass, default_aligner, alternative_aligner, route_table, enable_flg, create_user, create_timestamp, modify_user, modify_timestamp) " +
                         "VALUES " +
                         "(@equipment_model_id, @node_id, @node_type, @sn_no, @vendor, @model_no, @firmware_ver, @conn_address, @controller_id, @bypass, @default_aligner, @alternative_aligner, @route_table, @enable_flg, @create_user, @create_timestamp, @modify_user, NOW())";

                keyValues.Add("@equipment_model_id", equipment_Model.EquipmentModel.equipment_model_id);
                keyValues.Add("@node_id", txbDeviceNodeName.Text.Trim());
                keyValues.Add("@node_type", cmbDeviceNodeType.SelectedValue.ToString());
                keyValues.Add("@sn_no", nudSerialNo.Value);
                keyValues.Add("@vendor", cmbVendor.SelectedValue.ToString());
                keyValues.Add("@model_no", txbModel.Text.Trim());
                keyValues.Add("@firmware_ver", txbFirmwareVersion.Text.Trim());
                keyValues.Add("@conn_address", txbAddress.Text.Trim());
                keyValues.Add("@controller_id", txbControllerID.Text.Trim());
                keyValues.Add("@enable_flg", chbActive.Checked ? 1 : 0);
                keyValues.Add("@default_aligner", txbDefaultAligner.Text.Trim());
                keyValues.Add("@alternative_aligner", txbAlternativeAligner.Text.Trim());
                keyValues.Add("@route_table", JsonConvert.SerializeObject(dtRouteTable, Formatting.Indented).Replace("\r\n", string.Empty));
                keyValues.Add("@bypass", chbByPass.Checked ? 1 : 0);

                drsTemp = dtTemp.Select("node_id = '" + cmbDeviceNodeType.Text + Convert.ToInt32(nudSerialNo.Value).ToString("D2") + "'");
                Form  form   = Application.OpenForms["FormMain"];
                Label Signal = form.Controls.Find("lbl_login_id", true).FirstOrDefault() as Label;

                if (drsTemp.Length > 0)
                {
                    keyValues.Add("@create_user", drsTemp[0]["create_user"].ToString());
                    keyValues.Add("@create_timestamp", Convert.ToDateTime(drsTemp[0]["create_timestamp"].ToString()).ToString("yyyy-MM-dd HH:mm:ss"));
                }
                else
                {
                    keyValues.Add("@create_user", Signal.Text);
                    strSql = strSql.Replace("@create_timestamp", "NOW()");
                }

                keyValues.Add("@modify_user", Signal.Text);

                dBUtil.ExecuteNonQuery(strSql, keyValues);
                MessageBox.Show("Done it.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                Adam.Util.SanwaUtil.addActionLog("Adam.Menu.SystemSetting", "FormCpmmandScript", Signal.Text);

                UpdateNodeList();
                ClearUI();

                //改設定後套用
                NodeManagement.LoadConfig();
                if (cmbDeviceNodeType.Text.Equals("OCR"))
                {
                    OCRUpdate.AssignForm();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Exemple #3
0
 private void FormOCR_Load(object sender, EventArgs e)
 {
     OCRUpdate.AssignForm();
 }