Ejemplo n.º 1
0
        /// <summary>
        /// RunButton Click
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">EventArgs</param>
        private void RunButton_Click(object sender, EventArgs e)
        {
            try
            {
                string   formFile          = string.Empty;
                string   visibleName       = string.Empty;
                FormInfo getPermissionForm = new FormInfo();
                bool     isSlice;
                bool     isRoverFormShow = true;
                if (this.FormIDTextBox.Text.Trim() == "3230" && !TerraScanCommon.IsFieldUser)
                {
                    isRoverFormShow = false;
                }
                if (isRoverFormShow && !string.IsNullOrEmpty(this.FormIDTextBox.Text.Trim()))
                {
                    if (this.UserListCombo.SelectedIndex > 0)
                    {
                        #region Debug Mode Code //Added by Jyothi

                        if (TerraScanCommon.activateDebugMode.Equals(true) && TerraScanCommon.debugConfiguration.Equals(true))
                        {
                            SupportFormData.GetFormManagementDetailsDataTable getFormSlicesDetails = new SupportFormData.GetFormManagementDetailsDataTable();
                            FormInfo         getSliceFormPermission = new FormInfo();
                            string           optionalValues         = "";
                            string           formFileSlice          = string.Empty;
                            PermissionFields permissions1;

                            getFormSlicesDetails = F9017Controll.WorkItem.F9002_GetFormManagementDetails(Convert.ToInt32(FormIDTextBox.Text.Trim()), Convert.ToInt32(UserListCombo.SelectedValue.ToString()));

                            ////if (getFormSlicesDetails.Rows.Count == 3)
                            ////{
                            for (int count = 0; count < getFormSlicesDetails.Rows.Count; count++)
                            {
                                permissions1.newPermission           = Convert.ToBoolean(getFormSlicesDetails.Rows[count][getFormSlicesDetails.IsPermissionAddColumn.ColumnName].ToString());
                                getSliceFormPermission.addPermission = Convert.ToInt32(Convert.ToBoolean(getFormSlicesDetails.Rows[count][getFormSlicesDetails.IsPermissionAddColumn.ColumnName]));

                                permissions1.openPermission           = Convert.ToBoolean(getFormSlicesDetails.Rows[count][getFormSlicesDetails.IsPermissionOpenColumn.ColumnName].ToString());
                                getSliceFormPermission.openPermission = Convert.ToInt32(Convert.ToBoolean(getFormSlicesDetails.Rows[count][getFormSlicesDetails.IsPermissionOpenColumn.ColumnName]));

                                permissions1.editPermission           = Convert.ToBoolean(getFormSlicesDetails.Rows[count][getFormSlicesDetails.IsPermissionEditColumn.ColumnName].ToString());
                                getSliceFormPermission.editPermission = Convert.ToInt32(Convert.ToBoolean(getFormSlicesDetails.Rows[count][getFormSlicesDetails.IsPermissionEditColumn.ColumnName]));

                                permissions1.deletePermission           = Convert.ToBoolean(getFormSlicesDetails.Rows[count][getFormSlicesDetails.IsPermissionDeleteColumn.ColumnName].ToString());
                                getSliceFormPermission.deletePermission = Convert.ToInt32(Convert.ToBoolean(getFormSlicesDetails.Rows[count][getFormSlicesDetails.IsPermissionDeleteColumn.ColumnName]));

                                formFileSlice = getFormSlicesDetails.Rows[count][getFormSlicesDetails.FormFileColumn.ColumnName].ToString();
                                getSliceFormPermission.formFile = formFileSlice;

                                getSliceFormPermission.form = Convert.ToInt32(FormIDTextBox.Text.Trim());

                                if (getSliceFormPermission.optionalParameters != null)
                                {
                                    if (getSliceFormPermission.optionalParameters[0] != null)
                                    {
                                        optionalValues = optionalValues + "Key ID = " + getSliceFormPermission.optionalParameters[0] + "\n";
                                    }

                                    for (int iCount = 0; count < 3; iCount++)
                                    {
                                        if (getSliceFormPermission.optionalParameters[iCount] != null)
                                        {
                                            optionalValues = optionalValues + "Other Parameter " + iCount + " = " + getSliceFormPermission.optionalParameters[iCount] + "\n";
                                        }
                                    }
                                }

                                MessageBox.Show("Form: " + getSliceFormPermission.form + "\n" + "FormFile: " + getSliceFormPermission.formFile + "\n" + "Open Permission: " + Convert.ToBoolean(getSliceFormPermission.openPermission) + "\n" + "Add Permission: " + Convert.ToBoolean(getSliceFormPermission.addPermission) + "\n" + "Edit Permission: " + Convert.ToBoolean(getSliceFormPermission.editPermission) + "\n" + "Delete Permission: " + Convert.ToBoolean(getSliceFormPermission.deletePermission) + "\n" + optionalValues, ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }

                            TerraScanCommon.debugSliceConfiguration = true;
                            ////}
                        }

                        #endregion Debug Mode Code ////Ended by Jyothi

                        this.getFormDetailsDataDetails = this.F9017Controll.WorkItem.GetFormDetails(Convert.ToInt32(FormIDTextBox.Text.Trim()), Convert.ToInt32(UserListCombo.SelectedValue.ToString()));
                        if (this.getFormDetailsDataDetails.Rows.Count > 0)
                        {
                            this.permissions.newPermission  = Convert.ToBoolean(this.getFormDetailsDataDetails.Rows[0][this.getFormDetailsDataDetails.IsPermissionAddColumn.ColumnName].ToString());
                            getPermissionForm.addPermission = Convert.ToInt32(Convert.ToBoolean(this.getFormDetailsDataDetails.Rows[0][this.getFormDetailsDataDetails.IsPermissionAddColumn.ColumnName]));

                            this.permissions.openPermission  = Convert.ToBoolean(this.getFormDetailsDataDetails.Rows[0][this.getFormDetailsDataDetails.IsPermissionOpenColumn.ColumnName].ToString());
                            getPermissionForm.openPermission = Convert.ToInt32(Convert.ToBoolean(this.getFormDetailsDataDetails.Rows[0][this.getFormDetailsDataDetails.IsPermissionOpenColumn.ColumnName]));

                            this.permissions.editPermission  = Convert.ToBoolean(this.getFormDetailsDataDetails.Rows[0][this.getFormDetailsDataDetails.IsPermissionEditColumn.ColumnName].ToString());
                            getPermissionForm.editPermission = Convert.ToInt32(Convert.ToBoolean(this.getFormDetailsDataDetails.Rows[0][this.getFormDetailsDataDetails.IsPermissionEditColumn.ColumnName]));

                            this.permissions.deletePermission  = Convert.ToBoolean(this.getFormDetailsDataDetails.Rows[0][this.getFormDetailsDataDetails.IsPermissionDeleteColumn.ColumnName].ToString());
                            getPermissionForm.deletePermission = Convert.ToInt32(Convert.ToBoolean(this.getFormDetailsDataDetails.Rows[0][this.getFormDetailsDataDetails.IsPermissionDeleteColumn.ColumnName]));

                            formFile = this.getFormDetailsDataDetails.Rows[0][getFormDetailsDataDetails.FormFileColumn.ColumnName].ToString();
                            getPermissionForm.formFile = formFile;

                            visibleName = this.getFormDetailsDataDetails.Rows[0][getFormDetailsDataDetails.MenuNameColumn.ColumnName].ToString();
                            getPermissionForm.visibleName = visibleName;
                            getPermissionForm.form        = Convert.ToInt32(FormIDTextBox.Text.Trim());

                            isSlice = Convert.ToBoolean(this.getFormDetailsDataDetails.Rows[0][getFormDetailsDataDetails.IsSliceColumn.ColumnName].ToString());

                            if (!isSlice)
                            {
                                if (this.permissions.openPermission && Convert.ToBoolean(this.getFormDetailsDataDetails.Rows[0][getFormDetailsDataDetails.IsPermissionMenuColumn.ColumnName].ToString()))
                                {
                                    ////FormInfo getPermissionForm = TerraScan.Common.TerraScanCommon.GetFormInfo(Convert.ToInt32(FormIDTextBox.Text.Trim())); ////.GetForm(9002, optionalParameter, this.form9016Control.WorkItem);
                                    getPermissionForm.optionalParameters = new object[6];
                                    ////getPermissionForm.optionalParameters[0] = Convert.ToInt32(this.FormIDTextBox.Text.Trim());
                                    if (!string.IsNullOrEmpty(this.Parameter1TextBox.Text.Trim()))
                                    {
                                        ////string str1 = (str.Trim() = string.Empty ? "Hi" : "Bye");
                                        getPermissionForm.optionalParameters[0] = this.Parameter1TextBox.Text.Trim();

                                        if (!string.IsNullOrEmpty(this.Parameter2TextBox.Text.Trim()))
                                        {
                                            if (!string.IsNullOrEmpty(this.Parameter1TextBox.Text.Trim()))
                                            {
                                                getPermissionForm.optionalParameters[1] = this.Parameter2TextBox.Text.Trim();
                                            }
                                            else
                                            {
                                                MessageBox.Show(SharedFunctions.GetResourceString("InvalidKey"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                this.Parameter1TextBox.Focus();
                                                return;
                                            }
                                        }

                                        if (!string.IsNullOrEmpty(this.Parameter3TextBox.Text.Trim()))
                                        {
                                            if (!string.IsNullOrEmpty(this.Parameter1TextBox.Text.Trim()))
                                            {
                                                getPermissionForm.optionalParameters[2] = this.Parameter3TextBox.Text.Trim();
                                            }
                                            else
                                            {
                                                MessageBox.Show(SharedFunctions.GetResourceString("InvalidKey"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                this.Parameter1TextBox.Focus();
                                                return;
                                            }
                                        }

                                        if (!string.IsNullOrEmpty(this.Parameter4Textbox.Text.Trim()))
                                        {
                                            if (!string.IsNullOrEmpty(this.Parameter1TextBox.Text.Trim()))
                                            {
                                                getPermissionForm.optionalParameters[3] = this.Parameter4Textbox.Text.Trim();
                                            }
                                            else
                                            {
                                                MessageBox.Show(SharedFunctions.GetResourceString("InvalidKey"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                this.Parameter1TextBox.Focus();
                                                return;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (!string.IsNullOrEmpty(this.Parameter2TextBox.Text.Trim()))
                                        {
                                            if (!string.IsNullOrEmpty(this.Parameter1TextBox.Text.Trim()))
                                            {
                                                getPermissionForm.optionalParameters[1] = this.Parameter2TextBox.Text.Trim();
                                            }
                                            else
                                            {
                                                MessageBox.Show(SharedFunctions.GetResourceString("InvalidKey"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                this.Parameter1TextBox.Focus();
                                                return;
                                            }
                                        }
                                        else if (!string.IsNullOrEmpty(this.Parameter3TextBox.Text.Trim()))
                                        {
                                            if (!string.IsNullOrEmpty(this.Parameter1TextBox.Text.Trim()))
                                            {
                                                getPermissionForm.optionalParameters[2] = this.Parameter3TextBox.Text.Trim();
                                            }
                                            else
                                            {
                                                MessageBox.Show(SharedFunctions.GetResourceString("InvalidKey"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                this.Parameter1TextBox.Focus();
                                                return;
                                            }
                                        }
                                        else if (!string.IsNullOrEmpty(this.Parameter4Textbox.Text.Trim()))
                                        {
                                            if (!string.IsNullOrEmpty(this.Parameter1TextBox.Text.Trim()))
                                            {
                                                getPermissionForm.optionalParameters[3] = this.Parameter4Textbox.Text.Trim();
                                            }
                                            else
                                            {
                                                MessageBox.Show(SharedFunctions.GetResourceString("InvalidKey"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                this.Parameter1TextBox.Focus();
                                                return;
                                            }
                                        }
                                    }

                                    getPermissionForm.optionalParameters[4] = this.permissions;
                                    getPermissionForm.optionalParameters[5] = this.UserListCombo.SelectedValue.ToString();
                                    ////getPermissionForm.formFile = formFile;
                                    ////getPermissionForm.visibleName = visibleName;
                                    ////getPermissionForm.openPermission = Convert.ToInt32(this.permissions.openPermission);
                                    TerraScanCommon.SupportFormUserId = Convert.ToInt32(this.UserListCombo.SelectedValue);

                                    /* Code For CAMA Sketh*/
                                    Boolean CAMAForm = false;
                                    int     objectID = 0;
                                    for (int CamaFormNo = 0; CamaFormNo < TerraScanCommon.CAMASketchFormDetails.Length; CamaFormNo++)
                                    {
                                        if (TerraScanCommon.CAMASketchFormDetails[CamaFormNo].Contains(FormIDTextBox.Text.Trim()))
                                        {
                                            CAMAForm = true;
                                        }
                                    }
                                    if (CAMAForm)
                                    {
                                        if (!String.IsNullOrEmpty(this.Parameter1TextBox.Text.Trim()))
                                        {
                                            Int32.TryParse(this.Parameter1TextBox.Text.Trim(), out objectID);
                                        }
                                        if (objectID > 0)
                                        {
                                            /* if (!formOpened)
                                             * {
                                             *   camaForm = new Form();
                                             *   camaForm = TerraScanCommon.ShowSketchForm(3200);
                                             *   Form mainFrm = new Form();
                                             *   mainFrm = (Form)((Form)this.ParentForm).ParentForm;
                                             *   foreach (Form f in mainFrm.MdiChildren)
                                             *   {
                                             *       if (f.Name == "CAMASketch")
                                             *       {
                                             *           f.Close();
                                             *           f.Dispose();
                                             *       }
                                             *   }
                                             * }
                                             * else
                                             * {
                                             *   if (formOpened)
                                             *   {
                                             *       //camaForm.Dispose();
                                             *       //camaForm.Close();
                                             *       camaForm = new Form();
                                             *       camaForm = TerraScanCommon.ShowSketchForm(3200);
                                             *       Form formAlreadyOpened = (Form)TerraScanCommon.GetObject(camaForm, "GetOpenedForm");
                                             *       formAlreadyOpened.Close();
                                             *       Boolean formClosed = (Boolean)TerraScanCommon.GetObject(camaForm, "FormOpened");
                                             *       formOpened = formClosed;
                                             *       if (!formClosed)
                                             *       {
                                             *           camaForm = TerraScanCommon.ShowSketchForm(3200);
                                             *       }
                                             *   }
                                             *   else
                                             *   {
                                             *       Form mainFrm = new Form();
                                             *       mainFrm = (Form)((Form)this.ParentForm).ParentForm;
                                             *       foreach (Form f in mainFrm.MdiChildren)
                                             *       {
                                             *           if (f.Name == "CAMASketch")
                                             *           {
                                             *               f.Dispose();
                                             *           }
                                             *
                                             *       }
                                             *   }
                                             * }*/

                                            this.camaForm = new Form();
                                            this.camaForm = TerraScanCommon.ShowSketchForm(3200);
                                            Form formAlreadyOpened = (Form)TerraScanCommon.GetObject(this.camaForm, "GetOpenedForm");
                                            if (formAlreadyOpened != null)
                                            {
                                                formAlreadyOpened.Close();
                                                Boolean formClosed = (Boolean)TerraScanCommon.GetObject(this.camaForm, "FormOpened");
                                                this.formOpened = formClosed;
                                                if (!formClosed)
                                                {
                                                    this.camaForm = TerraScanCommon.ShowSketchForm(3200);
                                                }
                                            }

                                            //if (!formOpened)
                                            //{
                                            TerraScanCommon.SetValue(camaForm, "SetObjectID", objectID);
                                            TerraScanCommon.SetValue(camaForm, "SetMDI", ((Form)((Form)this.ParentForm).ParentForm));
                                            //}
                                            formOpened = (Boolean)TerraScanCommon.GetObject(camaForm, "FormOpened");
                                        }
                                    }
                                    else
                                    {   ////Endshere
                                        this.ShowForm(this, new DataEventArgs <FormInfo>(getPermissionForm));
                                    }
                                }
                                else
                                {
                                    MessageBox.Show(SharedFunctions.GetResourceString("PermissionCheck"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    this.PreviewPanel.Visible = false;
                                    this.UserListCombo.Focus();
                                    ////this.FormIDTextBox.Text = string.Empty;
                                }
                            }
                            else
                            {
                                MessageBox.Show("Slice Form cannot be opened", ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.PreviewPanel.Visible = false;
                                this.FormIDTextBox.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show(SharedFunctions.GetResourceString("InvalidForm"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            this.PreviewPanel.Visible = false;
                            this.FormIDTextBox.Focus();
                            ////this.FormIDTextBox.Text = string.Empty;
                        }
                    }
                    else
                    {
                        MessageBox.Show(SharedFunctions.GetResourceString("InvalidUser"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.PreviewPanel.Visible = false;
                        this.UserListCombo.Focus();
                        ////this.UserListCombo.Focus();
                    }
                }
                else if (string.IsNullOrEmpty(this.FormIDTextBox.Text.Trim()))
                {
                    MessageBox.Show(SharedFunctions.GetResourceString("EmptyFormValue"), ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.PreviewPanel.Visible = false;
                    this.FormIDTextBox.Focus();
                    ////this.FormIDTextBox.Focus();
                }
                else
                {
                    MessageBox.Show("Current user do not have permission to acess this form.", ConfigurationWrapper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (SoapException ex)
            {
                ExceptionManager.ManageException(ex, ExceptionManager.ActionType.CloseCurrentForm, this.ParentForm);
            }
            catch (Exception ex)
            {
                ExceptionManager.ManageException(ex, ExceptionManager.ActionType.CloseCurrentForm, this.ParentForm);
            }
            finally
            {
                TerraScanCommon.SupportFormUserId = -1;
            }
        }