Exemplo n.º 1
0
        protected void ResourcesGrid_OnRowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("EmptyInsert"))
            {
                TextBox nameField  = ResourcesGrid.Controls[0].Controls[0].FindControl("Name") as TextBox;
                TextBox valueField = ResourcesGrid.Controls[0].Controls[0].FindControl("Translation") as TextBox;

                LanguageString languageString = new LanguageString();
                languageString.ResourceName = nameField.Text.Trim();
                languageString.Translation  = valueField.Text.Trim();
                languageString.Language     = _Language;
                languageString.Save();
                ResourcesGrid.DataBind();
                ResourcesGrid.ShowFooter = false;
            }
            else if (e.CommandName.Equals("Insert"))
            {
                TextBox nameField  = ResourcesGrid.FooterRow.FindControl("Name") as TextBox;
                TextBox valueField = ResourcesGrid.FooterRow.FindControl("Translation") as TextBox;


                // check if a resource with same key already exists
                if (AbleContext.Resolve <ILanguageStringRepository>().Load(nameField.Text.Trim()) == null)
                {
                    LanguageString languageString = new LanguageString();
                    languageString.ResourceName = nameField.Text.Trim();
                    languageString.Translation  = valueField.Text.Trim();
                    languageString.Language     = _Language;
                    languageString.Save();
                    ResourcesGrid.DataBind();
                }
                else
                {
                    RequiredFieldValidator NameValidator = ResourcesGrid.FooterRow.FindControl("NameValidator") as RequiredFieldValidator;
                    NameValidator.IsValid      = false;
                    NameValidator.ErrorMessage = "<br/>Name already exists.";
                }
            }
            else if (e.CommandName.Equals("Cancel"))
            {
                ResourcesGrid.ShowFooter = false;
            }
        }
Exemplo n.º 2
0
        protected void ResourcesGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int            resourceId     = (int)ResourcesGrid.DataKeys[e.RowIndex].Value;
            LanguageString languageString = LanguageStringDataSource.Load(resourceId);

            if (languageString != null)
            {
                GridViewRow row   = (GridViewRow)ResourcesGrid.Rows[e.RowIndex];
                TextBox     name  = (TextBox)row.FindControl("Name");
                TextBox     value = (TextBox)row.FindControl("Translation");

                languageString.ResourceName = name.Text.Trim();
                languageString.Translation  = value.Text.Trim();

                languageString.Save();
            }
            ResourcesGrid.EditIndex = -1;
            e.Cancel = true;
            ResourcesGrid.DataBind();
        }
Exemplo n.º 3
0
 protected void AddButton_Click(object sender, EventArgs e)
 {
     ResourcesGrid.ShowFooter = true;
     ResourcesGrid.DataBind();
 }
Exemplo n.º 4
0
 protected void SearchButton_Click(object sender, EventArgs e)
 {
     ResourcesGrid.DataBind();
 }
Exemplo n.º 5
0
        protected void UploadButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                // SET THE PATH
                string uploadPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data\\Temp");

                // SAVE THE BINARY FILE DATA
                HttpPostedFile file = null;
                if (Request.Files.Count > 0)
                {
                    file = Request.Files[0];
                }
                bool fileUploaded = ((file != null) && (file.ContentLength > 0));
                if (fileUploaded)
                {
                    string fileName = Path.GetFileName(file.FileName);
                    if (FileHelper.IsExtensionValid(fileName, "csv, xml"))
                    {
                        StreamReader reader   = new StreamReader(file.InputStream);
                        string       contents = reader.ReadToEnd();

                        string cleanExtension = Path.GetExtension(fileName.Replace(" ", string.Empty)).ToLowerInvariant();
                        if (cleanExtension.StartsWith("."))
                        {
                            cleanExtension = cleanExtension.Substring(1);
                        }
                        if (cleanExtension == "xml")
                        {
                            // import xml
                            try
                            {
                                XmlDocument doc = new XmlDocument();
                                doc.LoadXml(contents);
                                UploadCompleteMessage.Text    = string.Format(UploadCompleteMessage.Text, LanguageManager.ImportResourcesXml(_Language, doc));
                                UploadCompleteMessage.Visible = true;
                                ResourcesGrid.DataBind();
                            }
                            catch (Exception ex)
                            {
                                CustomValidator xmlValidator = new CustomValidator();
                                xmlValidator.IsValid           = false;
                                xmlValidator.ControlToValidate = "UploadFile";
                                xmlValidator.ErrorMessage      = "An error has occured while uploading Xml resources from file. " + ex.Message;
                                xmlValidator.Text            = "*";
                                xmlValidator.ValidationGroup = "Upload";
                                phUploadFileTypes.Controls.Add(xmlValidator);
                                UploadPopup.Show();
                            }
                        }
                        else
                        {
                            // import csv
                            try
                            {
                                UploadCompleteMessage.Text    = string.Format(UploadCompleteMessage.Text, LanguageManager.ImportResourcesCsv(_Language, contents));
                                UploadCompleteMessage.Visible = true;
                                ResourcesGrid.DataBind();
                            }
                            catch (Exception ex)
                            {
                                CustomValidator xmlValidator = new CustomValidator();
                                xmlValidator.IsValid           = false;
                                xmlValidator.ControlToValidate = "UploadFile";
                                xmlValidator.ErrorMessage      = "An error has occured while uploading Csv resources from file. " + ex.Message;
                                xmlValidator.Text            = "*";
                                xmlValidator.ValidationGroup = "Upload";
                                phUploadFileTypes.Controls.Add(xmlValidator);
                                UploadPopup.Show();
                            }
                        }
                    }
                    else
                    {
                        CustomValidator filetype = new CustomValidator();
                        filetype.IsValid           = false;
                        filetype.ControlToValidate = "UploadFile";
                        filetype.ErrorMessage      = "The target file '" + fileName + "' does not have a valid file extension.";
                        filetype.Text            = "*";
                        filetype.ValidationGroup = "Upload";
                        phUploadFileTypes.Controls.Add(filetype);
                        UploadPopup.Show();
                    }
                }
            }

            else
            {
                UploadPopup.Show();
            }
        }
Exemplo n.º 6
0
        private void BindValues()
        {
            dtcStartDate.DefaultTimeString = PortalConfig.WorkTimeStart;
            dtcEndDate.DefaultTimeString   = PortalConfig.WorkTimeFinish;

            DateTime dt = DateTime.Today.AddHours(DateTime.UtcNow.Hour + 1);

            dtcStartDate.SelectedDate = User.GetLocalDate(Security.CurrentUser.TimeZoneId, dt);
            dtcEndDate.SelectedDate   = dtcStartDate.SelectedDate.AddDays(1);

            BindCategories();

            ddlActivationType.DataSource     = Task.GetListActivationTypes();
            ddlActivationType.DataTextField  = "ActivationTypeName";
            ddlActivationType.DataValueField = "ActivationTypeId";
            ddlActivationType.DataBind();

            ddlCompletionType.DataSource     = Task.GetListCompletionTypes();
            ddlCompletionType.DataTextField  = "CompletionTypeName";
            ddlCompletionType.DataValueField = "CompletionTypeId";
            ddlCompletionType.DataBind();

            ddlPhase.Items.Add(new ListItem(LocRM.GetString("dontChange"), "-1"));
            using (IDataReader reader = Project.GetListProjectPhases())
            {
                while (reader.Read())
                {
                    ddlPhase.Items.Add(new ListItem(reader["PhaseName"].ToString(), reader["PhaseId"].ToString()));
                }
            }

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

            if (TID != 0)
            {
                using (IDataReader reader = Task.GetTask(TID))
                {
                    if (reader.Read())
                    {
                        ProjID                    = (int)reader["ProjectId"];
                        txtTitle.Text             = HttpUtility.HtmlDecode(reader["Title"].ToString());
                        dtcStartDate.SelectedDate = (DateTime)reader["StartDate"];
                        dtcEndDate.SelectedDate   = (DateTime)reader["FinishDate"];
                        if ((bool)reader["IsMilestone"])
                        {
                            chbMilestone.Checked = true;
                        }
                        else
                        {
                            chbMilestone.Checked = false;
                            trPhase.Style.Add("visibility", "hidden");
                            ddlPhase.Style.Add("visibility", "hidden");
                        }
                        chbMustBeConfirmed.Checked = (bool)reader["MustBeConfirmed"];

                        if ((bool)reader["IsSummary"])
                        {
                            //dtcStartDate.Enabled = false;
                            dtcStartDate.ReadOnly = false;
                            //dtcEndDate.Enabled = false;
                            dtcEndDate.ReadOnly      = false;
                            CustomValidator1.Visible = false;
                            chbMilestone.Visible     = false;
                        }

                        ddlPriority.ClearSelection();
                        ddlPriority.Items.FindByValue(reader["PriorityId"].ToString()).Selected = true;

                        CommonHelper.SafeSelect(ddlActivationType, reader["ActivationTypeId"].ToString());
                        CommonHelper.SafeSelect(ddlCompletionType, reader["CompletionTypeId"].ToString());

                        if (reader["PhaseId"] != DBNull.Value)
                        {
                            CommonHelper.SafeSelect(ddlPhase, reader["PhaseId"].ToString());
                        }

                        if (reader["Description"] != DBNull.Value)
                        {
                            txtDescription.Text = HttpUtility.HtmlDecode(reader["Description"].ToString());
                        }

                        ucTaskTime.Value = DateTime.MinValue.AddMinutes((int)reader["TaskTime"]);
                    }
                }

                using (IDataReader reader = Task.GetListCategories(TID))
                {
                    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 = Task.GetListResources(TID))
                {
                    while (reader.Read())
                    {
                        TaskResources.Add((int)reader["UserId"]);
                    }
                }

                EditControl.ObjectId = TID;
                EditControl.BindData();
            }
            else             //Create
            {
                trPhase.Style.Add("visibility", "hidden");
                ddlPhase.Style.Add("visibility", "hidden");

                ucTaskTime.Value = DateTime.MinValue.AddMinutes(int.Parse(PortalConfig.TaskDefaultValueTaskTimeField));
                CommonHelper.SafeSelect(ddlPriority, PortalConfig.TaskDefaultValuePriorityField);
                chbMustBeConfirmed.Checked = bool.Parse(PortalConfig.TaskDefaultValueMustConfirmField);
                ArrayList list = Common.StringToArrayList(PortalConfig.TaskDefaultValueGeneralCategoriesField);
                foreach (int i in list)
                {
                    CommonHelper.SafeMultipleSelect(lbCategory, i.ToString());
                }
                CommonHelper.SafeSelect(ddlActivationType, PortalConfig.TaskDefaultValueActivationTypeField);
                CommonHelper.SafeSelect(ddlCompletionType, PortalConfig.TaskDefaultValueCompetionTypeField);
            }

            ResourcesGrid.DataSource = Project.GetListTeamMemberNamesWithManager(ProjID);
            ResourcesGrid.DataBind();

            chbMilestone.Attributes.Add("onclick",
                                        String.Format("ShowHidePhase(this, '{0}', '{1}')", trPhase.ClientID, ddlPhase.ClientID));

            lblProject.Text = "<a href='../Projects/ProjectView.aspx?ProjectID=" + ProjID + "'>" + Task.GetProjectTitle(ProjID) + "</a>";
            lblManager.Text = CommonHelper.GetUserStatus(Task.GetProjectManager(ProjID));
        }