Esempio n. 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                //權限檢查
                using (var form = new FormConfirm("是否儲存變更?"))
                {
                    var result = form.ShowDialog();
                    if (result != DialogResult.OK)
                    {
                        MessageBox.Show("Cancel.", "Notice");
                        return;
                    }
                }

                SCB = new MySqlCommandBuilder(sda);
                sda.Update(ds);
                SCB.RefreshSchema();
                SCB.Dispose();
                MessageBox.Show("Update 成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //權限檢查
            using (var form = new FormConfirm("是否儲存變更?"))
            {
                var result = form.ShowDialog();
                if (result != DialogResult.OK)
                {
                    MessageBox.Show("Cancel.", "Notice");
                    return;
                }
            }

            SystemConfig config = SystemConfig.Get();

            //目前只開放查詢以下資料
            config.EquipmentID      = tbEqpId.Text;
            config.OCR1ImgToJpgPath = tbOcr1ImgBak.Text;
            config.FoupTxfLogPath   = tbTxfLogPath.Text;
            config.CurrentRecipe    = cbRecipe.SelectedItem.ToString();

            config.Save();
            MessageBox.Show("Update Completed.", "Success");
            FormMainUpdate.UpdateRecipe(config.CurrentRecipe);
        }
Esempio n. 3
0
        private void btnClose_Click(object sender, EventArgs e)
        {
            FormConfirm form = new FormConfirm();

            if (form.ShowDialog() == DialogResult.Yes)
            {
                this.ParentForm.Close();
            }

            form.Dispose();
        }
Esempio n. 4
0
        private void Execute()
        {
            var shutdownDate  = ComputeShutdownDate();
            var remainingTime = shutdownDate - DateTime.Now;

            if (remainingTime.TotalMinutes <= 0)
            {
                MessageBox.Show(this, $"La date ne doit pas être antérieure à la date actuelle.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string       mode;
            Action <int> action;

            // Détermination Arret ou Veille
            if (radioShutdown.Checked)
            {
                mode   = "l'arrêt";
                action = Utils.ScheduleShutdown;
            }
            else
            {
                mode   = "la veille prolongée";
                action = Utils.ScheduleHibernation;
            }

            var message = $"Programmer {mode} le {shutdownDate.ToString("dddd dd MMMM' à 'HH\\:mm")} ?\n" +
                          $"({remainingTime:%d' jours et 'hh\\:mm\\:ss} restant)";

            var autoClosePreference = Settings.Default.autoClose;

            var confirmForm = new FormConfirm(message, autoClosePreference);

            confirmForm.ShowDialog();

            if (confirmForm.DialogResult == DialogResult.Yes)
            {
                action.Invoke((int)Math.Round(remainingTime.TotalSeconds));

                Settings.Default.autoClose = confirmForm.isCheckboxChecked();
                Settings.Default.Save();

                if (confirmForm.isCheckboxChecked())
                {
                    Close();
                }
            }
        }
Esempio n. 5
0
        private void btnDeleteRecipe_Click(object sender, EventArgs e)
        {
            if (trvRecipe.SelectedNode == null)
            {
                MessageBox.Show("Please select a recipe first.", "Notice");
                return;
            }
            Recipe recipe = Recipe.Get(trvRecipe.SelectedNode.Text);

            if (recipe.recipe_id.Equals("default"))
            {
                MessageBox.Show("default recipe 不得刪除.", "Notice");
                return;
            }
            else if (SystemConfig.Get().CurrentRecipe.Equals(recipe.recipe_id))
            {
                MessageBox.Show("Recipe 使用中,請先切換 recipe 後再刪除.", "Notice");
                return;
            }
            using (var form = new FormConfirm("確認是否刪除 Recipe:" + recipe.recipe_id))
            {
                var result = form.ShowDialog();
                if (result == DialogResult.OK)
                {
                    if (Recipe.Delete(recipe.recipe_id))
                    {
                        refreshList();
                        Util.SanwaUtil.addActionLog("Recipe", "Delete", Global.currentUser, "刪除 Recipe:" + recipe.recipe_id);
                        MessageBox.Show("Delete completed.", "Success");
                    }
                    else
                    {
                        MessageBox.Show("Delete fail.", "Error");
                    }
                }
                else
                {
                    MessageBox.Show("Cancel.", "Notice");
                }
            }
        }
Esempio n. 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string strSql = string.Empty;
            Dictionary <string, object> keyValues = new Dictionary <string, object>();

            try
            {
                //權限檢查
                using (var form = new FormConfirm("是否儲存變更?"))
                {
                    var result = form.ShowDialog();
                    if (result != DialogResult.OK)
                    {
                        MessageBox.Show("Cancel.", "Notice");
                        return;
                    }
                }

                if (btnCreateUser.BackColor == Color.RoyalBlue)
                {
                    if (txbUserID.Text.Trim().Equals(string.Empty) || txbUserName.Text.Trim().Equals(string.Empty) ||
                        txbPassword.Text.Trim().Equals(string.Empty) || cmbGroup.SelectedIndex == -1)
                    {
                        MessageBox.Show("Missing the data.", "Account Setting", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                        return;
                    }

                    strSql = "INSERT INTO account " +
                             "(user_id, user_name, password, user_group_id, active, create_user, create_timestamp, modify_user, modify_timestamp) " +
                             "VALUES(@user_id, @user_name, MD5(@password), @user_group_id, @active, @create_user, NOW(), @modify_user, NOW())";

                    keyValues.Add("@user_id", txbUserID.Text.Trim());
                    keyValues.Add("@user_name", txbUserName.Text.Trim());
                    keyValues.Add("@password", txbPassword.Text.Trim());
                    keyValues.Add("@user_group_id", cmbGroup.SelectedValue.ToString());
                    keyValues.Add("@active", chbActive.Checked == true ? "Y" : "N");
                    keyValues.Add("@create_user", strUserID);
                    keyValues.Add("@modify_user", strUserID);
                }
                else if (btnModifyUser.BackColor == Color.RoyalBlue)
                {
                    if (txbUserID.Text.Trim().Equals(string.Empty) || txbUserName.Text.Trim().Equals(string.Empty) ||
                        txbPassword.Text.Trim().Equals(string.Empty) || cmbGroup.SelectedIndex == -1)
                    {
                        MessageBox.Show("Missing the data.", "Account Setting", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                        return;
                    }

                    strSql = "UPDATE account SET user_name = @user_name, " +
                             "user_group_id = @user_group_id," +
                             "active = @active, " +
                             "modify_user = @modify_user, " +
                             "modify_timestamp = NOW() " +
                             "WHERE user_id = @user_id ";

                    keyValues.Add("@user_id", txbUserID.Text.Trim());
                    keyValues.Add("@user_name", txbUserName.Text.Trim());
                    keyValues.Add("@user_group_id", cmbGroup.SelectedValue.ToString());
                    keyValues.Add("@active", chbActive.Checked == true ? "Y" : "N");
                    keyValues.Add("@modify_user", strUserID);
                }
                else if (btnChangePassword.BackColor == Color.RoyalBlue)
                {
                    if (txbUserID.Text.Trim().Equals(string.Empty) || txbUserName.Text.Trim().Equals(string.Empty) ||
                        txbPassword.Text.Trim().Equals(string.Empty) || cmbGroup.SelectedIndex == -1 || txbPasswordNew.Text.Trim().Equals(string.Empty) ||
                        txbPasswordNewAgain.Text.Trim().Equals(string.Empty))
                    {
                        MessageBox.Show("Missing the data.", "Account Setting", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                        return;
                    }

                    if (txbPasswordNew.Text.Trim().Equals(string.Empty) || txbPasswordNewAgain.Text.Trim().Equals(string.Empty))
                    {
                        MessageBox.Show("Missing the data.", "Account Setting", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                        return;
                    }

                    if (!txbPasswordNew.Text.Trim().Equals(txbPasswordNewAgain.Text.Trim()))
                    {
                        MessageBox.Show("New password are different.", "Account Setting", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                        return;
                    }

                    strSql = "UPDATE account SET PASSWORD = MD5(@password), " +
                             "modify_user = @modify_user, " +
                             "modify_timestamp = NOW() " +
                             "WHERE user_id = @user_id ";

                    keyValues.Add("@user_id", txbUserID.Text.Trim());
                    keyValues.Add("@password", txbPasswordNew.Text.Trim());
                    keyValues.Add("@modify_user", strUserID);
                }

                dBUtil.ExecuteNonQuery(strSql, keyValues);
                Adam.Util.SanwaUtil.addActionLog("Adam.Menu.SystemSetting", "FormAccountSetting", strUserID);
                MessageBox.Show("Done it.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                FormAccountSetting_Load(sender, e);

                gbAccount.Enabled             = false;
                txbUserID.Text                = string.Empty;
                txbUserID.BackColor           = Color.White;
                txbUserName.Text              = string.Empty;
                txbUserName.BackColor         = Color.White;
                cmbGroup.SelectedIndex        = -1;
                cmbGroup.BackColor            = Color.White;
                txbPassword.Text              = string.Empty;
                txbPassword.BackColor         = Color.White;
                txbPasswordNew.Text           = string.Empty;
                txbPasswordNew.BackColor      = Color.White;
                txbPasswordNewAgain.Text      = string.Empty;
                txbPasswordNewAgain.BackColor = Color.White;
                chbActive.Checked             = false;
                chbActive.BackColor           = SystemColors.Control;
                btnCreateUser.BackColor       = Color.Silver;
                btnModifyUser.BackColor       = Color.Silver;
                btnChangePassword.BackColor   = Color.Silver;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Esempio n. 7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if ((DataTable)lsbCondition.DataSource == null || ((DataTable)lsbCondition.DataSource).Rows.Count == 0)
            {
                MessageBox.Show("The grid data does not exist.", this.Name, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;
            }

            if (lsbCondition.SelectedIndex < 0)
            {
                MessageBox.Show("Choose the condition.", this.Name, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;
            }

            //權限檢查
            using (var form = new FormConfirm("是否儲存變更?"))
            {
                var result = form.ShowDialog();
                if (result != DialogResult.OK)
                {
                    MessageBox.Show("Cancel.", "Notice");
                    return;
                }
            }

            string strSql = string.Empty;
            Dictionary <string, object> keyValues = new Dictionary <string, object>();

            try
            {
                strSql = "UPDATE config_signal_tower " +
                         "SET red = @red, " +
                         "orange = @orange, " +
                         "green = @green, " +
                         "blue = @blue, " +
                         "buzzer1 = @buzzer1, " +
                         "buzzer2 = @buzzer2, " +
                         "update_user = @update_user, " +
                         "update_time = NOW() " +
                         "WHERE eqp_status  =  @eqp_status " +
                         "AND is_alarm = @is_alarm ";

                Form  form   = Application.OpenForms["FormMain"];
                Label Signal = form.Controls.Find("lbl_login_id", true).FirstOrDefault() as Label;

                keyValues.Add("@red", cmbRad.Text.ToString());
                keyValues.Add("@orange", cmbYellow.Text.ToString());
                keyValues.Add("@green", cmbGreen.Text.ToString());
                keyValues.Add("@blue", cmbBlue.Text.ToString());
                keyValues.Add("@buzzer1", cmbBuzzer1.Text.ToString());
                keyValues.Add("@buzzer2", cmbBuzzer2.Text.ToString());
                keyValues.Add("@update_user", Signal.Text);
                keyValues.Add("@eqp_status", lsbCondition.Text.Split('-')[0].ToString());
                keyValues.Add("@is_alarm", Convert.ToUInt64(lsbCondition.SelectedValue.ToString()));

                dBUtil.ExecuteNonQuery(strSql, keyValues);

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

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

                UpdateList();

                txbEqpStatus.Text          = string.Empty;
                txbIsAlarm.Text            = string.Empty;
                cmbBlue.SelectedIndex      = -1;
                cmbGreen.SelectedIndex     = -1;
                cmbRad.SelectedIndex       = -1;
                cmbYellow.SelectedIndex    = -1;
                cmbBuzzer1.SelectedIndex   = -1;
                cmbBuzzer2.SelectedIndex   = -1;
                lsbCondition.SelectedIndex = -1;
                //改設定後套用
                NodeStatusUpdate.InitialSetting();
                NodeStatusUpdate.UpdateCurrentState(FormMain.RouteCtrl.EqpState);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Esempio n. 8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //檢查資料
            if (tbRecipeID.Text.Trim().Equals("") || tbRecipeName.Text.Trim().Equals(""))
            {
                MessageBox.Show("Recipe Name or recipe id should not be empty.", "Data check error");
                return;
            }
            //權限檢查
            using (var form = new FormConfirm("確認是否儲存 Recipe:" + tbRecipeID.Text))
            {
                var result = form.ShowDialog();
                if (result != DialogResult.OK)
                {
                    MessageBox.Show("Cancel.", "Notice");
                    return;
                }
            }
            //GUI 處理
            //gbRecipe.Enabled = false;
            btnCreateRecipe.Enabled = true;
            btnModifyRecipe.Enabled = true;
            btnCancel.Enabled       = false;
            btnSave.Enabled         = false;
            tbRecipeName.ReadOnly   = true;
            tbRecipeID.ReadOnly     = true;
            trvRecipe.Enabled       = true;
            //Recipe 存檔
            Recipe recipe = new Recipe();

            recipe.aligner1_angle = tbA1_angle.Text.Equals("") ? "0" : Int32.Parse(tbA1_angle.Text).ToString();
            recipe.aligner1_speed = tbA1_speed.Text.Equals("") ? "20" : Int32.Parse(tbA1_speed.Text).ToString();
            recipe.aligner2_angle = tbA2_angle.Text.Equals("") ? "0" : Int32.Parse(tbA2_angle.Text).ToString();
            recipe.aligner2_speed = tbA2_speed.Text.Equals("") ? "20" : Int32.Parse(tbA2_speed.Text).ToString();

            recipe.is_use_aligner1 = cbUseA1.Checked;
            recipe.is_use_aligner2 = cbUseA2.Checked;


            recipe.auto_fin_unclamp = "Y";//固定Y

            recipe.auto_get_constrict = cbAutoGetRule.Text;
            recipe.auto_put_constrict = cbAutoPutRule.Text;
            //recipe.equip_id = tbEqpID.Text;
            recipe.ffu_rpm_close = tbFFUCloseRpm.Text;
            recipe.ffu_rpm_open  = tbFFUOpenRpm.Text;

            recipe.manual_fin_unclamp = "Y";//固定Y

            recipe.manual_get_constrict = cbManualGetRule.Text;
            recipe.manual_put_constrict = cbManualPutRule.Text;

            recipe.port1_carrier_type = cbP1CstType.Text;
            recipe.port1_priority     = Int32.Parse(cbP1Seq.Text);
            recipe.port1_type         = cbP1LoadType.Text;

            recipe.port2_carrier_type = cbP2CstType.Text;
            recipe.port2_priority     = Int32.Parse(cbP2Seq.Text);
            recipe.port2_type         = cbP2LoadType.Text;

            recipe.port3_carrier_type = cbP3CstType.Text;
            recipe.port3_priority     = Int32.Parse(cbP3Seq.Text);
            recipe.port3_type         = cbP3LoadType.Text;

            recipe.port4_carrier_type = cbP4CstType.Text;
            recipe.port4_priority     = Int32.Parse(cbP4Seq.Text);
            recipe.port4_type         = cbP4LoadType.Text;

            recipe.recipe_id    = tbRecipeID.Text.Trim();
            recipe.recipe_name  = tbRecipeName.Text;
            recipe.robot1_speed = tbR1Speed.Text.Equals("") ? "20" : Int32.Parse(tbR1Speed.Text).ToString();
            recipe.robot2_speed = "20";//default tbR2Speed.Text.Equals("") ? "20" : Int32.Parse(tbR2Speed.Text).ToString();

            recipe.notch_angle = tbNotch_angle.Text.Equals("") ? "0" : Int32.Parse(tbNotch_angle.Text).ToString();

            recipe.is_use_l_arm      = cbUseLArm.Checked;
            recipe.is_use_r_arm      = cbUseRArm.Checked;
            recipe.is_use_double_arm = cbUserBothArm.Checked;
            recipe.get_slot_order    = cbGetSlotOrder.Text;
            recipe.put_slot_order    = cbPutSlotOrder.Text;

            Recipe.Set(recipe.recipe_id, recipe);

            string CurrentRecipe = SystemConfig.Get().CurrentRecipe;

            if (cbActive.Checked)//設定生效
            {
                SystemConfig config = SystemConfig.Get();
                config.CurrentRecipe = tbRecipeID.Text;
                config.Save();
                FormMainUpdate.UpdateRecipe(tbRecipeID.Text);
            }
            else if (CurrentRecipe.Equals(tbRecipeID.Text))//取消生效
            {
                SystemConfig config = SystemConfig.Get();
                config.CurrentRecipe = "default";
                config.Save();
                //update node config
                FormMainUpdate.UpdateRecipe("default");
            }
            //紀錄修改Log
            if (tbRecipeID.Enabled)
            {
                Util.SanwaUtil.addActionLog("Recipe", "Create", Global.currentUser, "建立 Recipe:" + recipe.recipe_id);
            }
            if (tbRecipeID.Enabled)
            {
                Util.SanwaUtil.addActionLog("Recipe", "Modify", Global.currentUser, "修改 Recipe:" + recipe.recipe_id);
            }

            refreshList();
            MessageBox.Show("Execute successfully.", "Success");
        }
Esempio n. 9
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();


            try
            {
                Node currentNode = NodeManagement.Get(Setting_NodeName_lb.Text);

                if (currentNode == null)
                {
                    MessageBox.Show("Node " + Setting_NodeName_lb.Text + " is not exist!");
                    return;
                }
                IController currentController = ControllerManagement.Get(currentNode.Controller);
                if (currentController == null)
                {
                    MessageBox.Show("Controller " + currentNode.Controller + " is not exist!");
                    return;
                }
                //權限檢查
                using (var form = new FormConfirm("是否儲存變更?"))
                {
                    var result = form.ShowDialog();
                    if (result != DialogResult.OK)
                    {
                        MessageBox.Show("Cancel.", "Notice");
                        return;
                    }
                }
                currentNode.Enable      = Setting_NodeEnable_rb.Checked;
                currentNode.CarrierType = Setting_CarrierType_cb.Text;
                currentNode.Mode        = Setting_Mode_cb.Text;
                strSql = @"UPDATE config_node SET enable_flg = @enable_flg ,carrier_type = @carrier_type, mode = @mode WHERE equipment_model_id = @equipment_model_id AND node_id = @node_id";

                keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
                keyValues.Add("@node_id", currentNode.Name);
                keyValues.Add("@enable_flg", currentNode.Enable ? 1 : 0);
                keyValues.Add("@carrier_type", currentNode.CarrierType);
                keyValues.Add("@mode", currentNode.Mode);

                dBUtil.ExecuteNonQuery(strSql, keyValues);

                keyValues.Clear();

                strSql = "UPDATE config_controller_setting SET conn_type = @conn_type, conn_address = @conn_address , conn_port = @conn_port WHERE equipment_model_id = @equipment_model_id AND device_name = @device_name";

                keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
                keyValues.Add("@device_name", currentNode.Controller);
                keyValues.Add("@conn_type", Setting_connectType_cb.Text);
                keyValues.Add("@conn_address", Setting_Address_tb.Text);
                keyValues.Add("@conn_port", Setting_Port_tb.Text);
                dBUtil.ExecuteNonQuery(strSql, keyValues);



                MessageBox.Show("連線相關設定值,將於重啟程式後生效.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }