Exemple #1
0
            public BorderEditorControl()
            {
                Height = 90;
                Width  = 120;

                top          = new EditControl(this);
                top.Size     = new Size(Width - 30, 15);
                top.Location = new Point(15, 0);
                top.Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;

                left          = new EditControl(this);
                left.Size     = new Size(15, Height - 30);
                left.Location = new Point(0, 15);
                left.Anchor   = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom;

                right          = new EditControl(this);
                right.Size     = new Size(15, Height - 30);
                right.Location = new Point(Width - 15, 15);
                right.Anchor   = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;

                bottom          = new EditControl(this);
                bottom.Size     = new Size(Width - 30, 15);
                bottom.Location = new Point(15, Height - 15);
                bottom.Anchor   = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;

                Controls.Clear();
                Controls.Add(top);
                Controls.Add(left);
                Controls.Add(right);
                Controls.Add(bottom);
            }
        private void EditProd(object sender, RoutedEventArgs e)
        {
            try
            {
                producttable p       = (producttable)(DatabaseGrid.SelectedItem);
                StackPanel   element = new StackPanel();
                EditControl  edit    = new EditControl(p);
                element.Orientation = Orientation.Horizontal;

                element.Children.Add(new TextBlock()
                {
                    Text = "Добавление товара "
                });


                Button btn = new Button();
                btn.Click          += ((MainWindow)((Grid)((TabControl)((TabItem)Parent).Parent).Parent).Parent).deleteBtnClk;
                btn.Content         = "✕";
                btn.Background      = Brushes.Transparent;
                btn.BorderThickness = new Thickness(0);


                element.Children.Add(btn);
                TabItem item = new TabItem()
                {
                    Content = edit,
                    Header  = element
                };
                MainWindow.Main.ControlView.Items.Add(item);
                MainWindow.Main.ControlView.SelectedItem = item;
            }
            catch (Exception ex) { MessageBox.Show("Выберите элемент для редактирования", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); }
        }
 /// <summary>
 /// Initializes a new instance of the <see
 /// cref="T:XMLLanguage">XMLLangauge</see> class.
 /// </summary>
 /// <param name="control">represents the EditControl to which to which this instance
 /// has to be hooked</param>
 public XMLLanguage(EditControl control)
     : base(control)
 {
     this.Name           = "XML";
     this.FileExtension  = "xml";
     this.ApplyColoring  = true;
     this.TextForeground = Brushes.Brown;
 }
Exemple #4
0
 public void EditFocusOver(object sender, System.EventArgs e)
 {
     if (EditControl != null)
     {
         //Console.WriteLine("FocusOver");
         this.Text = EditControl.Text;
         EditControl.Hide();
     }
 }
 public RedscriptLanguage(EditControl control) : base(control)
 {
     Name                 = "Redscript";
     FileExtension        = "reds";
     ApplyColoring        = true;
     SupportsIntellisense = false;
     SupportsOutlining    = true;
     //TextForeground = Brushes.Black;
 }
        protected void btnCancel_Click(object sender, EventArgs e)
        {
            foreach (IEditContentControl EditControl in phNewOrEditControls.Controls)
            {
                EditControl.Cancel();
            }

            RedirectBack();
        }
        public void UiaTextProvider_GetWindowExStyle_ContainsClientedge()
        {
            using EditControl textBox = new EditControl(
                      style: WS.OVERLAPPED | WS.VISIBLE);
            Mock <UiaTextProvider> providerMock = new Mock <UiaTextProvider>(MockBehavior.Strict);

            WS_EX actual = providerMock.Object.GetWindowExStyle(textBox);

            Assert.True(actual.HasFlag(WS_EX.CLIENTEDGE));
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            foreach (IEditContentControl EditControl in phNewOrEditControls.Controls)
            {
                EditControl.IsPublished = chkPublished.Checked;
                EditControl.Save();
            }

            RedirectBack();
        }
        public void UiaTextProvider_GetWindowStyle_ContainsVisible()
        {
            using EditControl textBox = new EditControl(
                      editStyle: ES.MULTILINE | ES.LEFT | ES.AUTOHSCROLL | ES.AUTOVSCROLL,
                      style: WS.OVERLAPPED | WS.VISIBLE);
            Mock <UiaTextProvider> providerMock = new Mock <UiaTextProvider>(MockBehavior.Strict);

            WS actual = providerMock.Object.GetWindowStyle(textBox);

            Assert.True(actual.HasFlag(WS.VISIBLE));
        }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of the <see
 /// cref="T:IronPythonDemo.PythonLanguage">PythonLanguage</see> class.
 /// </summary>
 /// <param name="control">represents the EditControl to which to which this instance
 /// has to be hooked</param>
 public PythonLanguage(EditControl control)
     : base(control)
 {
     this.Name                 = "Python";
     this.FileExtension        = "py";
     this.ApplyColoring        = true;
     this.SupportsIntellisense = false;
     this.SupportsOutlining    = true;
     this.TextForeground       = Brushes.Black;
     this.blocksStack          = new Stack <BlockListener>();
 }
        public void UiaTextProvider_GetEditStyle_DoesntContainMultilineStyle_ForSinglelineTextBox()
        {
            // EditControl Multiline is false when EditControl doesn't have ES_MULTILINE style
            using EditControl textBox = new EditControl(
                      editStyle: ES.LEFT | ES.AUTOHSCROLL | ES.AUTOVSCROLL,
                      style: WS.OVERLAPPED | WS.VISIBLE);
            Mock <UiaTextProvider> providerMock = new Mock <UiaTextProvider>(MockBehavior.Strict);

            ES actual = providerMock.Object.GetEditStyle(textBox);

            Assert.False(actual.HasFlag(ES.MULTILINE));
        }
Exemple #12
0
        override protected void OnEdtModeChange(bool newValue)
        {
            if (EditControl != null && newValue == true)
            {
                EditControl.Focus();

                if (EditControl.Text.Length > 0)
                {
                    EditControl.SelectAll();
                }
            }
        }
        public void UiaTextProvider_GetEditStyle_ContainsMultilineStyle_ForMultilineTextBox()
        {
            // EditControl Multiline is true when EditControl has ES_MULTILINE style
            using EditControl textBox = new EditControl(
                      editStyle: ES.MULTILINE | ES.LEFT | ES.AUTOHSCROLL | ES.AUTOVSCROLL,
                      style: WS.OVERLAPPED | WS.VISIBLE);
            Mock <UiaTextProvider> providerMock = new Mock <UiaTextProvider>(MockBehavior.Strict);

            ES actual = UiaTextProvider.GetEditStyle(textBox);

            Assert.True(actual.HasFlag(ES.MULTILINE));
        }
 private void SetComponent()
 {
     if (!isEditable)
     {
         var buyProduct = new BuyProduct();
         ProductOperation.Children.Add(buyProduct);
     }
     else
     {
         var editButtons = new EditControl();
         ProductOperation.Children.Add(editButtons);
     }
 }
Exemple #15
0
        //Used to check if the pointer is within the bounds of the edit control.
        //If it is, focus should go to the edit control.  If it is outside the bounds
        //Focus should not be in the edit control.
        private void Page_PointerPressed(CoreWindow sender, PointerEventArgs args)
        {
            Rect _boundingbox = EditControl.GetLayout();

            if (_boundingbox.Contains(args.CurrentPoint.Position))
            {
                _textEditContext.InternalSetFocus();
                EditControl.Focus(FocusState.Programmatic);
            }
            else
            {
                _textEditContext.InternalRemoveFocus();
            }
        }
Exemple #16
0
        /// <summary>
        /// Extracts code snippets from given folder and adds them to the current language configuration of EditControl.
        /// </summary>
        /// <param name="dir">Path to the directory with code snippets.</param>
        /// <param name="editor">Instance of EditControl to add code snippets to.</param>
        public static void Extract(string dir, EditControl editor)
        {
            CodeSnippetsContainer container = Extract(dir);

            foreach (string containerName in container.ContainersNames)
            {
                editor.Language.AddCodeSnippetsContainer(container.GetContainerByName(containerName));
            }

            foreach (string snippetName in container.SnippetsNames)
            {
                editor.Language.AddCodeSnippet(container.GetSnippetByTitle(snippetName));
            }
        }
Exemple #17
0
        private void BindFromTemplate(int TemplateId)
        {
            DataTable dt = new DataTable();
            ArrayList GeneralCategories = new ArrayList();
            ArrayList ProjectCategories = new ArrayList();

            Task.MakeProjectSysFieldsFromTemplate(TemplateId, dt, GeneralCategories, ProjectCategories);
            if (dt.Rows.Count > 0)
            {
                txtDeliverables.Text = dt.Rows[0]["Deliverables"].ToString();
                txtDescription.Text  = dt.Rows[0]["Description"].ToString();
                txtGoals.Text        = dt.Rows[0]["Goals"].ToString();
                txtScope.Text        = dt.Rows[0]["Scope"].ToString();

                Util.CommonHelper.SafeSelect(ddCurrency, dt.Rows[0]["CurrencyId"].ToString());
                Util.CommonHelper.SafeSelect(ddlCalendar, dt.Rows[0]["CalendarId"].ToString());
                Util.CommonHelper.SafeSelect(ddlType, dt.Rows[0]["TypeId"].ToString());
                Util.CommonHelper.SafeSelect(ddlManager, dt.Rows[0]["ManagerId"].ToString());
                Util.CommonHelper.SafeSelect(ddlExecManager, dt.Rows[0]["ExecutiveManagerId"].ToString());
                ddlPriority.SelectedValue = dt.Rows[0]["Priority"].ToString();

                foreach (ListItem item in lbProjectCategory.Items)
                {
                    if (ProjectCategories.Contains(int.Parse(item.Value)))
                    {
                        item.Selected = true;
                    }
                    else
                    {
                        item.Selected = false;
                    }
                }

                foreach (ListItem item in lbCategory.Items)
                {
                    if (GeneralCategories.Contains(int.Parse(item.Value)))
                    {
                        item.Selected = true;
                    }
                    else
                    {
                        item.Selected = false;
                    }
                }

                EditControl.MetaClassName = String.Concat("ProjectsEx_", ddlType.SelectedValue);
                EditControl.BindData();
            }
        }
        void tabControl1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.RemovedItems.Count > 0)
            {
                TabItem item = e.RemovedItems[0] as TabItem;
                if (item.Content == null || (item.Content != null && !(item.Content is EditControl)))
                {
                    return;
                }
                EditControl tempControl = item.Content as EditControl;
                Binding     prevBinding = BindingOperations.GetBinding(tempControl, EditControl.FontFamilyProperty);
                if (prevBinding != null)
                {
                    FontFamily tempFont = tempControl.FontFamily;
                    BindingOperations.ClearBinding(tempControl, EditControl.FontFamilyProperty);
                    tempControl.FontFamily = tempFont;

                    double tempSize = tempControl.FontSize;
                    BindingOperations.ClearBinding(tempControl, EditControl.FontSizeProperty);
                    tempControl.FontSize = tempSize;
                }
            }

            if (e.AddedItems.Count > 0)
            {
                TabItem item = e.AddedItems[0] as TabItem;
                if (item.Content == null || (item.Content != null && !(item.Content is EditControl)))
                {
                    return;
                }
                EditControl tempControl = item.Content as EditControl;
                Binding     prevBinding = BindingOperations.GetBinding(tempControl, EditControl.FontFamilyProperty);
                if (prevBinding == null)
                {
                    fontlst.SelectedItem = tempControl.FontFamily;
                    fontsze.SelectedItem = tempControl.FontSize;
                    Binding binding = new Binding("SelectedItem");
                    binding.Source = fontlst;
                    binding.Mode   = BindingMode.TwoWay;
                    BindingOperations.SetBinding(tempControl, EditControl.FontFamilyProperty, binding);

                    Binding bindingSize = new Binding("SelectedItem");
                    bindingSize.Source = fontsze;
                    bindingSize.Mode   = BindingMode.TwoWay;
                    BindingOperations.SetBinding(tempControl, EditControl.FontSizeProperty, bindingSize);
                }
            }
            e.Handled = true;
        }
Exemple #19
0
        public RoslynEditor()
        {
            this.InitializeComponent();

            // Set up text box
            this._textBox = new EditControl {
                Dock = DockStyle.Fill
            };
            this._textBox.ApplyConfiguration(KnownLanguages.CSharp);
            this._textBox.TextChanged += (sender, args) =>
            {
                this._code = this._textBox.Text;
                this.CodeChanged(this, args);
            };
            this.Controls.Add(this._textBox);
        }
        protected void rptDimensions_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "ChangeLanguage")
            {
                if (Boolean.Parse(hfMustSave.Value))
                {
                    // Save when changing language
                    foreach (IEditContentControl EditControl in phNewOrEditControls.Controls)
                    {
                        EditControl.Save();
                    }
                }

                var Url = GetCultureUrl(int.Parse(e.CommandArgument.ToString()));
                Response.Redirect(Url);
            }
        }
Exemple #21
0
        private void LabelControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (EditControl.IsReadOnly)
            {
                return;
            }

            LabelControl.Visibility = Visibility.Hidden;
            EditControl.Visibility  = Visibility.Visible;

            Dispatcher.BeginInvoke(
                new Action(() =>
            {
                EditControl.Focus();
            }
                           ), DispatcherPriority.Loaded);
        }
Exemple #22
0
 protected void EditOver(object sender, System.Windows.Forms.KeyPressEventArgs e)
 {
     if (EditControl != null)
     {
         if (e.KeyChar == 13)
         {
             //Console.WriteLine("EditOver13");
             this.Text = EditControl.Text;
             EditControl.Hide();
         }
         else if (e.KeyChar == 27)
         {
             //Console.WriteLine("EditOver27");
             EditControl.Hide();
         }
     }
 }
Exemple #23
0
        protected override void OnChartKeyPress(KeyPressEventArgs e)
        {
            base.OnChartKeyPress(e);

            if (e.KeyChar > 0x1F && !ReadOnly)
            {
                if (!EditMode)
                {
                    EditObject();
                }

                if (EditControl != null)
                {
                    EditControl.Send_WM_CHAR(e.KeyChar);
                }

                e.Handled = true;
            }
        }
Exemple #24
0
        private void EditControl_KeyDown(object sender, KeyEventArgs e)
        {
            if ((Keyboard.GetKeyStates(Key.LeftAlt) & KeyStates.Down) > 0 ||
                (Keyboard.GetKeyStates(Key.RightAlt) & KeyStates.Down) > 0)
            {
                if ((Keyboard.GetKeyStates(Key.Return) & KeyStates.Down) > 0)
                {
                    EditControl.SelectedText = Environment.NewLine;
                    EditControl.Select(EditControl.SelectionStart + 1, 0);
                    return;
                }
            }

            if (e.Key == Key.Enter)
            {
                EditControl.Text = EditControl.Text.Trim('\r', '\n');
                ExitEditMode();
            }
        }
        protected override WebControl CreateControlInternal(Control container)
        {
            control = Reflection.CreateObject(ControlType, ControlType) as EditControl;

            if (control != null)
            {
                control.ID            = ID + "_Control";
                control.Name          = ID;
                control.EditMode      = PropertyEditorMode.Edit;
                control.Required      = false;
                control.Value         = Value;
                control.OldValue      = Value;
                control.ValueChanged += ValueChanged;

                control.CssClass = "dnnFormInput";

                container.Controls.Add(control);
            }

            return(control);
        }
        protected override WebControl CreateControlInternal(Control container)
        {
            this.control = Reflection.CreateObject(this.ControlType, this.ControlType) as EditControl;

            if (this.control != null)
            {
                this.control.ID            = this.ID + "_Control";
                this.control.Name          = this.ID;
                this.control.EditMode      = PropertyEditorMode.Edit;
                this.control.Required      = false;
                this.control.Value         = this.Value;
                this.control.OldValue      = this.Value;
                this.control.ValueChanged += this.ValueChanged;
                this.control.DataField     = this.DataField;

                this.control.CssClass = "dnnFormInput";

                container.Controls.Add(this.control);
            }

            return(this.control);
        }
Exemple #27
0
        private void SetLanguageFormat(Languages language, string filePath)
        {
            edit    = new EditControl();
            uriList = new ObservableCollection <Uri>();
            edit.DocumentLanguage = language;
            edit.DocumentSource   = filePath;

            fontlst.SelectedItem  = new FontFamily("Verdana");
            fontsize.SelectedItem = (Double)13;

            Binding fontFamily = new Binding("SelectedItem");

            fontFamily.Source = fontlst;
            edit.SetBinding(EditControl.FontFamilyProperty, fontFamily);

            Binding fontSize = new Binding("SelectedItem");

            fontSize.Source = fontsize;
            edit.SetBinding(EditControl.FontSizeProperty, fontSize);

            Grid.SetRow(edit, 2);
            grid1.Children.Add(edit);
        }
Exemple #28
0
        private void menuItem2_Click(object sender, System.EventArgs e)
        {
            Form form1 = new MetroForm();

            form1.Text                                = "Script";
            form1.ShowIcon                            = false;
            form1.StartPosition                       = FormStartPosition.CenterScreen;
            this.editControl1                         = new EditControl();
            editControl1.ScrollVisualStyle            = ScrollBarCustomDrawStyles.Metro;
            this.editControl1.Dock                    = DockStyle.Fill;
            this.editControl1.ShowLineNumbers         = false;
            this.editControl1.ShowOutliningCollapsers = false;
            this.editControl1.SaveOnClose             = false;
            this.editControl1.ReadOnly                = true;
            this.editControl1.ShowVerticalSplitters   = false;
            this.editControl1.ShowHorizontalSplitters = false;
            this.editControl1.ShowIndicatorMargin     = false;
            editControl1.ApplyConfiguration(Edit.Enums.KnownLanguages.HTML);
            form1.Controls.Add(editControl1);
            form1.Size             = new System.Drawing.Size(600, 500);
            this.editControl1.Text = this.htmluiControl1.Text;
            form1.ShowDialog();
        }
Exemple #29
0
 protected void ddlType_SelectedIndexChanged(object sender, EventArgs e)
 {
     EditControl.MetaClassName = String.Concat("ProjectsEx_", ddlType.SelectedValue);
     EditControl.BindData();
 }
Exemple #30
0
        protected void btnSave_ServerClick(object sender, System.EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            txtTitle.Text        = HttpUtility.HtmlEncode(txtTitle.Text);
            txtGoals.Text        = HttpUtility.HtmlEncode(txtGoals.Text);
            txtScope.Text        = HttpUtility.HtmlEncode(txtScope.Text);
            txtDescription.Text  = HttpUtility.HtmlEncode(txtDescription.Text);
            txtDeliverables.Text = HttpUtility.HtmlEncode(txtDeliverables.Text);

            int iManager = 0;

            if (ddlManager.Visible)
            {
                iManager = int.Parse(ddlManager.SelectedItem.Value);
            }
            else
            {
                iManager = int.Parse(iManagerId.Value);
            }

            ArrayList alCategories = new ArrayList();

            for (int i = 0; i < lbCategory.Items.Count; i++)
            {
                if (lbCategory.Items[i].Selected)
                {
                    alCategories.Add(int.Parse(lbCategory.Items[i].Value));
                }
            }

            ArrayList alPCategories = new ArrayList();

            for (int i = 0; i < lbProjectCategory.Items.Count; i++)
            {
                if (lbProjectCategory.Items[i].Selected)
                {
                    alPCategories.Add(int.Parse(lbProjectCategory.Items[i].Value));
                }
            }

            bool      fromtemplate = false;
            ArrayList alPort       = new ArrayList();

            for (int i = 0; i < lbPortfolios.Items.Count; i++)
            {
                if (lbPortfolios.Items[i].Selected)
                {
                    alPort.Add(int.Parse(lbPortfolios.Items[i].Value));
                }
            }

            PrimaryKeyId orgUid     = PrimaryKeyId.Empty;
            PrimaryKeyId contactUid = PrimaryKeyId.Empty;

            if (ClientControl.ObjectType == OrganizationEntity.GetAssignedMetaClassName())
            {
                orgUid = ClientControl.ObjectId;
            }
            else if (ClientControl.ObjectType == ContactEntity.GetAssignedMetaClassName())
            {
                contactUid = ClientControl.ObjectId;
            }

            if (PID != 0)
            {
                Project2.Update(PID, txtTitle.Text, txtDescription.Text, txtGoals.Text, txtScope.Text,
                                txtDeliverables.Text, iManager, int.Parse(ddlExecManager.SelectedItem.Value),
                                dtcTargetStartDate.SelectedDate.Date, dtcTargetEndDate.SelectedDate.Date,
                                dtcActualStartDate.SelectedDate.Date, dtcActualFinishDate.SelectedDate.Date,
                                int.Parse(ddlStatus.SelectedItem.Value), int.Parse(ddlType.SelectedItem.Value),
                                int.Parse(ddlCalendar.SelectedItem.Value), contactUid, orgUid,
                                int.Parse(ddCurrency.SelectedItem.Value), int.Parse(ddlPriority.SelectedItem.Value),
                                int.Parse(ddInitialPhase.SelectedValue), int.Parse(ddPrjPhases.SelectedValue),
                                int.Parse(ddlOverallStatus.SelectedValue), int.Parse(ddlRiskLevel.SelectedItem.Value),
                                int.Parse(ddlBlockType.SelectedValue),
                                alCategories, alPCategories, alPort);
            }
            else
            {
                PID = Project.Create(txtTitle.Text, txtDescription.Text, txtGoals.Text, txtScope.Text,
                                     txtDeliverables.Text, iManager, int.Parse(ddlExecManager.SelectedItem.Value),
                                     dtcTargetStartDate.SelectedDate, dtcTargetEndDate.SelectedDate,
                                     dtcActualStartDate.SelectedDate, dtcActualFinishDate.SelectedDate,
                                     int.Parse(ddlStatus.SelectedItem.Value), int.Parse(ddlType.SelectedItem.Value),
                                     int.Parse(ddlCalendar.SelectedItem.Value), contactUid, orgUid,
                                     int.Parse(ddCurrency.SelectedItem.Value), int.Parse(ddlPriority.SelectedItem.Value),
                                     int.Parse(ddInitialPhase.SelectedValue), int.Parse(ddPrjPhases.SelectedValue),
                                     int.Parse(ddlOverallStatus.SelectedValue), int.Parse(ddlRiskLevel.SelectedItem.Value),
                                     int.Parse(ddlBlockType.SelectedValue),
                                     alCategories, alPCategories, alPort);
                if (int.Parse(ddlTemplate.SelectedValue) > 0)
                {
                    fromtemplate = true;
                }
            }

            // Save meta field info
            EditControl.Save(PID);

            if (fromtemplate)
            {
                BindTemplateValues(int.Parse(ddlTemplate.SelectedValue), PID);
                if (!cbOneMore.Checked)
                {
                    Response.Redirect("../Projects/ProjectView.aspx?ProjectID=" + PID + "&Tab=1&TemplateId=" + ddlTemplate.SelectedValue);
                }
                else
                {
                    Response.Redirect("../Projects/ProjectEdit.aspx?OldProjectId=" + PID + "&TemplateId=" + ddlTemplate.SelectedValue);
                }
            }
            else
            {
                if (cbOneMore.Checked)
                {
                    Response.Redirect("../Projects/ProjectEdit.aspx");
                }
                else
                {
                    Response.Redirect("../Projects/ProjectView.aspx?ProjectID=" + PID);
                }
            }
        }
Exemple #31
0
        private void BindValues()
        {
            ddlTemplate.DataSource     = ProjectTemplate.GetListProjectTemplate();
            ddlTemplate.DataTextField  = "TemplateName";
            ddlTemplate.DataValueField = "TemplateId";
            ddlTemplate.DataBind();
            ddlTemplate.Items.Insert(0, new ListItem(LocRM.GetString("NotSet"), "0"));
            if (Request["TemplateId"] != null)
            {
                CommonHelper.SafeSelect(ddlTemplate, Request["TemplateId"].ToString());
            }

            ddlStatus.DataSource     = Project.GetListProjectStatus();
            ddlStatus.DataTextField  = "StatusName";
            ddlStatus.DataValueField = "StatusId";
            ddlStatus.DataBind();

            ddPrjPhases.DataSource     = Project.GetListProjectPhases();
            ddPrjPhases.DataTextField  = "PhaseName";
            ddPrjPhases.DataValueField = "PhaseId";
            ddPrjPhases.DataBind();

            ddInitialPhase.DataSource     = Project.GetListProjectPhases();
            ddInitialPhase.DataTextField  = "PhaseName";
            ddInitialPhase.DataValueField = "PhaseId";
            ddInitialPhase.DataBind();

            ddlType.DataValueField = "TypeId";
            ddlType.DataTextField  = "TypeName";
            ddlType.DataSource     = Project.GetListProjectTypes();
            ddlType.DataBind();

            ddlBlockType.DataTextField  = "Title";
            ddlBlockType.DataValueField = "primaryKeyId";
            ddlBlockType.DataSource     = Mediachase.IbnNext.TimeTracking.TimeTrackingBlockType.List(Mediachase.Ibn.Data.FilterElement.EqualElement("IsProject", "1"));
            ddlBlockType.DataBind();

            ddlOverallStatus.Items.Clear();
            for (int i = 0; i <= 100; i++)
            {
                ddlOverallStatus.Items.Add(new ListItem(i.ToString() + " %", i.ToString()));
            }

            BindGeneralCategories();
            BindProjectCategories();
            BindPortfolios();

            ddlCalendar.DataTextField  = "CalendarName";
            ddlCalendar.DataValueField = "CalendarId";
            ddlCalendar.DataSource     = Project.GetListCalendars(PID);
            ddlCalendar.DataBind();

            ddlPriority.DataTextField  = "PriorityName";
            ddlPriority.DataValueField = "PriorityId";
            ddlPriority.DataSource     = Project.GetListPriorities();
            ddlPriority.DataBind();

            ddlRiskLevel.DataTextField  = "RiskLevelName";
            ddlRiskLevel.DataValueField = "RiskLevelId";
            ddlRiskLevel.DataSource     = Project.GetListRiskLevels();
            ddlRiskLevel.DataBind();

            dtcTargetStartDate.SelectedDate = UserDateTime.UserToday;
            dtcTargetEndDate.SelectedDate   = UserDateTime.UserToday.AddMonths(1);

            ddCurrency.DataTextField  = "CurrencySymbol";
            ddCurrency.DataValueField = "CurrencyId";
            ddCurrency.DataSource     = Project.GetListCurrency();
            ddCurrency.DataBind();

            // Managers
            ListItem  li;
            ArrayList alManagers = new ArrayList();

            using (IDataReader iManagers = SecureGroup.GetListAllUsersInGroup((int)InternalSecureGroups.ProjectManager))
            {
                while (iManagers.Read())
                {
                    li = new ListItem(iManagers["LastName"].ToString() + " " + iManagers["FirstName"].ToString(), iManagers["UserId"].ToString());
                    alManagers.Add(li);
                }
            }

            if (Security.IsUserInGroup(InternalSecureGroups.PowerProjectManager))
            {
                int CurrentUserID = Security.UserID;
                for (int i = 0; i < alManagers.Count; i++)
                {
                    ddlManager.Items.Add((ListItem)alManagers[i]);
                }

                li = ddlManager.Items.FindByValue(CurrentUserID.ToString());
                if (li != null)
                {
                    li.Selected = true;
                }
            }
            else
            {
                lblManager.Visible = true;
                ddlManager.Visible = false;
                lblManager.Text    = CommonHelper.GetUserStatus((Security.CurrentUser.UserID));
                iManagerId.Value   = Security.CurrentUser.UserID.ToString();
            }

            // Exec Managers
            li = new ListItem(LocRM.GetString("NotSet"), "0");
            ddlExecManager.Items.Add(li);

            using (IDataReader iManagers = SecureGroup.GetListAllUsersIn2Group((int)InternalSecureGroups.ProjectManager, (int)InternalSecureGroups.ExecutiveManager))
            {
                while (iManagers.Read())
                {
                    ddlExecManager.Items.Add(new ListItem(iManagers["LastName"].ToString() + " " + iManagers["FirstName"].ToString(), iManagers["UserId"].ToString()));
                }
            }


            if (PID != 0)
            {
                //				ddlBlockType.Enabled = false;

                using (IDataReader reader = Project.GetProject(PID))
                {
                    if (reader.Read())
                    {
                        if (reader["OrgUid"] != DBNull.Value)
                        {
                            ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName();
                            ClientControl.ObjectId   = PrimaryKeyId.Parse(reader["OrgUid"].ToString());
                        }
                        else if (reader["ContactUid"] != DBNull.Value)
                        {
                            ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName();
                            ClientControl.ObjectId   = PrimaryKeyId.Parse(reader["ContactUid"].ToString());
                        }

                        txtTitle.Text        = HttpUtility.HtmlDecode(reader["Title"].ToString());
                        txtGoals.Text        = HttpUtility.HtmlDecode(reader["Goals"].ToString());
                        txtScope.Text        = HttpUtility.HtmlDecode(reader["Scope"].ToString());
                        txtDescription.Text  = HttpUtility.HtmlDecode(reader["Description"].ToString());
                        txtDeliverables.Text = HttpUtility.HtmlDecode(reader["Deliverables"].ToString());

                        CommonHelper.SafeSelect(ddlType, reader["TypeId"].ToString());
                        CommonHelper.SafeSelect(ddlCalendar, reader["CalendarId"].ToString());
                        CommonHelper.SafeSelect(ddCurrency, reader["CurrencyId"].ToString());
                        CommonHelper.SafeSelect(ddlPriority, reader["PriorityId"].ToString());
                        CommonHelper.SafeSelect(ddlRiskLevel, reader["RiskLevelId"].ToString());
                        CommonHelper.SafeSelect(ddlOverallStatus, reader["PercentCompleted"].ToString());
                        if (reader["BlockTypeId"] != DBNull.Value)
                        {
                            CommonHelper.SafeSelect(ddlBlockType, reader["BlockTypeId"].ToString());
                        }

                        ddlExecManager.Items.FindByText(LocRM.GetString("NotSet")).Selected = true;
                        if (reader["ExecutiveManagerId"] != DBNull.Value)
                        {
                            string str = "";
                            str = reader["ExecutiveManagerId"].ToString();
                            ListItem liExec = ddlExecManager.Items.FindByValue(reader["ExecutiveManagerId"].ToString());
                            if (liExec != null)
                            {
                                ddlExecManager.ClearSelection();
                                liExec.Selected = true;
                            }
                        }

                        if (reader["ManagerId"] != DBNull.Value)
                        {
                            if (ddlManager.Visible)
                            {
                                ListItem liClient = ddlManager.Items.FindByValue(reader["ManagerId"].ToString());
                                if (liClient != null)
                                {
                                    ddlManager.ClearSelection();
                                    liClient.Selected = true;
                                }
                            }
                            else
                            {
                                int iManager = (int)reader["ManagerId"];
                                iManagerId.Value = iManager.ToString();
                                lblManager.Text  = CommonHelper.GetUserStatus(iManager);
                            }
                        }
                        if (reader["StatusId"] != DBNull.Value)
                        {
                            ListItem liStatus = ddlStatus.Items.FindByValue(reader["StatusId"].ToString());
                            if (liStatus != null)
                            {
                                ddlStatus.ClearSelection();
                                liStatus.Selected = true;
                            }
                        }

                        if (reader["PhaseId"] != DBNull.Value)
                        {
                            ListItem liPhase = ddPrjPhases.Items.FindByValue(reader["PhaseId"].ToString());
                            if (liPhase != null)
                            {
                                ddPrjPhases.ClearSelection();
                                liPhase.Selected = true;
                            }
                        }

                        if (reader["InitialPhaseId"] != DBNull.Value)
                        {
                            ListItem liPhase = ddInitialPhase.Items.FindByValue(reader["InitialPhaseId"].ToString());
                            if (liPhase != null)
                            {
                                ddInitialPhase.ClearSelection();
                                liPhase.Selected = true;
                            }
                        }

                        dtcTargetStartDate.SelectedDate = (DateTime)reader["TargetStartDate"];
                        dtcTargetEndDate.SelectedDate   = (DateTime)reader["TargetFinishDate"];

                        if (reader["ActualStartDate"] != DBNull.Value && reader["ActualStartDate"].ToString() != "")
                        {
                            dtcActualStartDate.SelectedDate = (DateTime)reader["ActualStartDate"];
                        }
                        if (reader["ActualFinishDate"] != DBNull.Value && reader["ActualFinishDate"].ToString() != "")
                        {
                            dtcActualFinishDate.SelectedDate = (DateTime)reader["ActualFinishDate"];
                        }
                    }
                }

                using (IDataReader reader = Project.GetListCategories(PID))
                {
                    while (reader.Read())
                    {
                        for (int i = 0; i < lbCategory.Items.Count; i++)
                        {
                            ListItem lItem = lbCategory.Items.FindByText(reader["CategoryName"].ToString());
                            if (lItem != null)
                            {
                                lItem.Selected = true;
                            }
                        }
                    }
                }

                using (IDataReader reader = Project.GetListProjectCategoriesByProject(PID))
                {
                    while (reader.Read())
                    {
                        for (int i = 0; i < lbProjectCategory.Items.Count; i++)
                        {
                            ListItem lItem = lbProjectCategory.Items.FindByText(reader["CategoryName"].ToString());
                            if (lItem != null)
                            {
                                lItem.Selected = true;
                            }
                        }
                    }
                }

                using (IDataReader reader = ProjectGroup.ProjectGroupsGetByProject(PID))
                {
                    while (reader.Read())
                    {
                        for (int i = 0; i < lbPortfolios.Items.Count; i++)
                        {
                            ListItem lItem = lbPortfolios.Items.FindByValue(reader["ProjectGroupId"].ToString());
                            if (lItem != null)
                            {
                                lItem.Selected = true;
                            }
                        }
                    }
                }
            }
            else
            {
                // Client
                PrimaryKeyId org_id     = PrimaryKeyId.Empty;
                PrimaryKeyId contact_id = PrimaryKeyId.Empty;
                Common.GetDefaultClient(PortalConfig.ProjectDefaultValueClientField, out contact_id, out org_id);
                if (contact_id != PrimaryKeyId.Empty)
                {
                    ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName();
                    ClientControl.ObjectId   = contact_id;
                }
                else if (org_id != PrimaryKeyId.Empty)
                {
                    ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName();
                    ClientControl.ObjectId   = org_id;
                }

                // Priority
                Util.CommonHelper.SafeSelect(ddlPriority, PortalConfig.ProjectDefaultValuePriorityField);

                // Currency
                Util.CommonHelper.SafeSelect(ddCurrency, PortalConfig.ProjectDefaultValueCurrencyField);

                // Categories
                ArrayList list = Common.StringToArrayList(PortalConfig.ProjectDefaultValueGeneralCategoriesField);
                foreach (int i in list)
                {
                    CommonHelper.SafeMultipleSelect(lbCategory, i.ToString());
                }
                list = Common.StringToArrayList(PortalConfig.ProjectDefaultValueProjectCategoriesField);
                foreach (int i in list)
                {
                    CommonHelper.SafeMultipleSelect(lbProjectCategory, i.ToString());
                }

                // texts
                txtGoals.Text        = PortalConfig.ProjectDefaultValueGoalsField;
                txtDeliverables.Text = PortalConfig.ProjectDefaultValueDeliverablesField;
                txtScope.Text        = PortalConfig.ProjectDefaultValueScopeField;
            }

            if (PID > 0)
            {
                EditControl.ObjectId = PID;
            }
            EditControl.MetaClassName = String.Concat("ProjectsEx_", ddlType.SelectedValue);
            EditControl.BindData();

            trPriority.Visible          = PortalConfig.CommonProjectAllowEditPriorityField;
            trClient.Visible            = PortalConfig.CommonProjectAllowEditClientField;
            trCategories.Visible        = PortalConfig.CommonProjectAllowEditGeneralCategoriesField;
            trProjectCategories.Visible = PortalConfig.ProjectAllowEditProjectCategoriesField;
            GoalsRow.Visible            = PortalConfig.ProjectAllowEditGoalsField;
            DeleverablesRow.Visible     = PortalConfig.ProjectAllowEditDeliverablesField;
            ScopeRow.Visible            = PortalConfig.ProjectAllowEditScopeField;
            LeftTextCell.Visible        = GoalsRow.Visible || DeleverablesRow.Visible;
        }