public ActionResult Create(tblProject tblProject)
        {
            tblProjectDap newDap = new tblProjectDap();
            if (tblProject.fldProjectID == 0)
            {
                if (newDap.AddProject(tblProject, 0))
                {

                    return RedirectToAction("Index");
                }
                else
                {
                    return View();
                }
            }
            else
            {
                if (newDap.AddProject(tblProject, tblProject.fldProjectID))
                {

                    return RedirectToAction("Index");
                }
                else
                {
                    return View();
                }
            }
        }
Example #2
0
 private void ctxUpdate_Click(object sender, EventArgs e)
 {
     tblProject curProject = new tblProject();
     tblProjectDap newDap = new tblProjectDap();
     curProject = newDap.GetByfldProjectTreeID(curSelectedNode.Key);
     frmErga_Single newSingle = new frmErga_Single(curProject.fldProjectID,0, enums.formState.Update);
     newSingle.ShowDialog();
     FillTree();
 }
Example #3
0
 private void ctxAdd_SubTask_Click(object sender, EventArgs e)
 {
     tblProject parentProject =  new tblProject();
        tblProjectDap newDap = new tblProjectDap();
        parentProject = newDap.GetByfldProjectTreeID(curSelectedNode.Key);
        frmErga_Single newSingle = new frmErga_Single(0,parentProject.fldProjectID, enums.formState.AddChild);
        newSingle.ShowDialog();
        FillTree();
 }
 // GET: /Projects/Create
 public ActionResult CreatePartial(long id)
 {
     if (id == 0)
     {
         tblProject childProject = new tblProject();
         childProject.fldProjectID = 0;
         return PartialView("_PartialCreateProject", childProject);
     }
     else
     {
         tblProject parentProject = new tblProject();
         tblProject childProject = new tblProject();
         tblProjectDap newDap = new tblProjectDap();
         parentProject = newDap.GetByfldProjectID(id);
         childProject.fldProjectID = parentProject.fldProjectID;
         childProject.fldProjectTreeID = parentProject.fldProjectTreeID;
         return PartialView("_PartialCreateProject",childProject);
     }
 }
Example #5
0
        private void cmdAdd_Click(object sender, EventArgs e)
        {
            _tblProject = new tblProject();
            saveFormToObject(_tblProject);
            tblProjectDap newDap = new tblProjectDap();

            switch (fState)
            {
                case enums.formState.Add:
                    newDap.AddProject(_tblProject, 0);
                    //SaveGrids();
                    break;
                case enums.formState.AddChild:
                    _tblProject.fldParentID = _fldParentProjectID;
                    newDap.AddProject(_tblProject, _fldParentProjectID);

                    //SaveGrids();
                    break;
            }
            MessageBox.Show("Η εισαγωγή ολοκληρώθηκε", "Μήνυμα");
            fState = enums.formState.Update;
            updateButtons(fState);
        }
        public bool AddProject(tblProject model, long parentProjectID)
        {
            try
            {
                tblProjectDap newDap = new tblProjectDap();
                if (parentProjectID == 0)
                {

                    string strMaxnum =
                        (newDap.Query<string>(
                            "select max(fldProjectTreeID) from tblProject where len(fldProjectTreeID) =5 "))
                            .FirstOrDefault().ToString();
                    long lngMaxnum = long.Parse(strMaxnum);
                    lngMaxnum += 1;
                    strMaxnum = ("0000" + lngMaxnum.ToString()).ToString();
                    strMaxnum = strMaxnum.Substring(strMaxnum.Length - 5);
                    model.fldProjectTreeID = strMaxnum;
                    model.fldProjectTreeCode = lngMaxnum.ToString();
                }
                else
                {
                    tblProject parentProject = new tblProject();
                    parentProject = GetByfldProjectID(parentProjectID);

                    int fldProjectTreeIDLen = parentProject.fldProjectTreeID.Length;
                    //string qry = "select max(fldProjectTreeID) from tblProject where len(fldProjectTreeID) = " +
                    //             (fldProjectTreeIDLen + 5).ToString() + " and tblProject.fldProjectTreeID like '" +
                    //             parentProjectID + "%' ";
                    string qry = "select max(fldProjectTreeID) from tblProject where len(fldProjectTreeID) = " +
                                (fldProjectTreeIDLen + 5).ToString() + " and tblProject.fldProjectTreeID like @parentProjectID ";
                    //var res = (newDap.Query<string>(qry)).FirstOrDefault();
                    var res = (newDap.Query<string>(qry, new { parentProjectID = parentProject.fldProjectTreeID  + "%" })).FirstOrDefault();
                    if (res != null)
                    {

                        long lngMaxnum = long.Parse(res.ToString().Right(5));
                        lngMaxnum += 1;
                        string strMaxnum = ("0000" + lngMaxnum.ToString()).ToString();
                        strMaxnum = strMaxnum.Right(5);
                        model.fldProjectTreeID = res.ToString().Left(res.ToString().Length - 5) + strMaxnum;
                        model.fldParentID = parentProject.fldProjectID;
                        model.fldProjectTreeCode =
                            StringExtensions.ConvertHierachicaltoCode(model.fldProjectTreeID, 5);
                    }
                    else
                    {
                        model.fldProjectTreeID = parentProject.fldProjectTreeID + "00001";
                        model.fldParentID = parentProject.fldProjectID;
                        model.fldProjectTreeCode =
                            StringExtensions.ConvertHierachicaltoCode(model.fldProjectTreeID, 5);
                    }

                }

                newDap.Insert(model);
                return true;
            }
            catch
            {
                return false;
            }
        }
Example #7
0
 private void saveFormToObject(tblProject tblProject)
 {
     Assign.GenericAssign(this.fldProjectName.Text, value => tblProject.fldProjectName = value);
     Assign.GenericAssign(this.fldProjectDescription.Text, value => tblProject.fldProjectDescription = value);
     Assign.GenericAssign((DateTime?)this.fldDateStart.Value, value => tblProject.fldDateStart = value);
     Assign.GenericAssign((DateTime?)this.fldDateCompletePlanned.Value, value => tblProject.fldDateCompletePlanned = value);
     Assign.GenericAssign((DateTime?)this.fldDateCompleteActual.Value, value => tblProject.fldDateCompleteActual = value);
     Assign.GenericAssign(this.fldIsCompleted.Checked, value => tblProject.fldIsCompleted = value);
 }
Example #8
0
 private void loadFormfromObject(tblProject tblProject)
 {
     Assign.GenericAssign(_tblProject.fldProjectID.ToString(), value => this.fldProjectID.Text = value);
     Assign.GenericAssign(_tblProject.fldProjectName, value => this.fldProjectName.Text = value);
     Assign.GenericAssign(_tblProject.fldProjectDescription, value => this.fldProjectDescription.Text = value);
     Assign.GenericAssign(_tblProject.fldDateStart, value => this.fldDateStart.Value = value);
     Assign.GenericAssign(_tblProject.fldDateCompletePlanned, value => this.fldDateCompletePlanned.Value = value);
     Assign.GenericAssign(_tblProject.fldDateCompleteActual, value => this.fldDateCompleteActual.Value = value);
     Assign.GenericAssign(_tblProject.fldIsCompleted, value => this.fldIsCompleted.Checked = value);
 }
Example #9
0
        private void frmErga_Single_Load(object sender, EventArgs e)
        {
            updateButtons(fState);
            FillCombos();
            switch (fState)
            {
                case enums.formState.Add:
                    break;
                case enums.formState.AddChild:
                    break;
                case enums.formState.Update:

                case enums.formState.Delete:
                    {
                        tblProjectDap newDap = new tblProjectDap();
                        _tblProject = newDap.GetByfldProjectID(_fldProjectID);
                        loadFormfromObject(_tblProject);
                        FillGrids();
                    }
                    break;

            }
        }
 public void Update(tblProject model)
 {
     Execute(SqlUpdateCommand, model);
 }
 public void Insert(tblProject model)
 {
     Execute(SqlInsertCommand, model);
 }
        public ActionResult CreatePartial(tblProject tblProject)
        {
            try
            {
                tblProjectDap newDap = new tblProjectDap();
                if (tblProject.fldProjectID == 0)
                {

                    string strMaxnum =
                        (newDap.Query<string>(
                            "select max(fldProjectTreeID) from tblProject where len(fldProjectTreeID) =5 "))
                            .FirstOrDefault().ToString();
                    long lngMaxnum = long.Parse(strMaxnum);
                    lngMaxnum += 1;
                    strMaxnum = ("0000" + lngMaxnum.ToString()).ToString();
                    strMaxnum = strMaxnum.Substring(strMaxnum.Length - 5);
                    tblProject.fldProjectTreeID = strMaxnum;
                    tblProject.fldProjectTreeCode = lngMaxnum.ToString();
                }
                else
                {
                    int fldProjectTreeIDLen = tblProject.fldProjectTreeID.Length;
                    string qry = "select max(fldProjectTreeID) from tblProject where len(fldProjectTreeID) = " +
                                 (fldProjectTreeIDLen + 5).ToString() + " and tblProject.fldProjectTreeID like '" +
                                 tblProject.fldProjectTreeID + "%' ";
                    var res = (newDap.Query<string>(qry)).FirstOrDefault();
                    if (res != null)
                    {

                        long lngMaxnum = long.Parse(res.ToString().Right(5));
                        lngMaxnum += 1;
                        string strMaxnum = ("0000" + lngMaxnum.ToString()).ToString();
                        strMaxnum = strMaxnum.Right(5);
                        tblProject.fldProjectTreeID = res.ToString().Left(res.ToString().Length-5) + strMaxnum;
                        tblProject.fldParentID = tblProject.fldProjectID;
                        tblProject.fldProjectTreeCode =
                            StringExtensions.ConvertHierachicaltoCode(tblProject.fldProjectTreeID,5);
                    }
                    else
                    {
                        tblProject.fldProjectTreeID = tblProject.fldProjectTreeID + "00001";
                        tblProject.fldParentID = tblProject.fldProjectID;
                        tblProject.fldProjectTreeCode =
                            StringExtensions.ConvertHierachicaltoCode(tblProject.fldProjectTreeID, 5);
                    }

                }

                newDap.Insert(tblProject);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        public ActionResult Edit(tblProject tlProject)
        {
            try
            {
                if (ModelState.IsValid)
                {

                    tblProjectDap newDap = new tblProjectDap();
                    newDap.Update(tlProject);
                    return RedirectToAction("Index");
                }
                else
                {
                    return RedirectToAction("Index");
                }

            }
            catch
            {
                return View();
            }
        }
 //
 // GET: /Projects/Edit/5
 public ActionResult Edit(int id)
 {
     tblProject editProject = new tblProject();
     tblProjectDap newDap = new tblProjectDap();
     editProject = newDap.GetByfldProjectID(id);
     return View(editProject);
        // return PartialView("_PartialEditProject", editProject);
 }
 //
 // GET: /Projects/Details/5
 public ActionResult Details(int id)
 {
     tblProject editProject = new tblProject();
     tblProjectDap newDap = new tblProjectDap();
     editProject = newDap.GetByfldProjectID(id);
     return View(editProject);
 }