Exemplo n.º 1
0
        public void create(ProjectInfo data)
        {
            string ifErrorDelete = null ;
            try {
                if(_startDate == null) _startDate = DateTime.Now.ToShortDateString();
                _root += @"\" + data.projectTypeName + @"\" + data.clientName + @"\";
                ifErrorDelete = _root;
                Directory.CreateDirectory(_root);
                _root += _startDate + "_" + data.requestTypeName + "_" + data.projectName + @"\";
                data.path = _root;
                Directory.CreateDirectory(_root);
                string tenders = _root + "Tender task_" + _startDate + "_" + data.requestTypeName + "_" + data.projectName;
                Directory.CreateDirectory(tenders);
                Directory.CreateDirectory(_root + "Calculation_" + _startDate + "_" + data.requestTypeName + "_" + data.projectName);
                Directory.CreateDirectory(_root + "Offers_" + _startDate + "_" + data.requestTypeName + "_" + data.projectName);
                Directory.CreateDirectory(_root + "Validation_" + _startDate + "_" + data.requestTypeName + "_" + data.projectName);
                foreach(string file in _files) {
                    File.Copy(AppDomain.CurrentDomain.BaseDirectory + @"temp\" + file, tenders + @"\" + file, true);
                }

                dbManager.createProject(data);
                System.Diagnostics.Process.Start(_root);
                _root = _defaultRoot;
            } catch(SystemException ex) {
                this.close();
                System.Windows.Forms.MessageBox.Show(ex.Message);
                if(ifErrorDelete != null) Directory.Delete(ifErrorDelete, true);
                _root = _defaultRoot;
                throw ex;
            }
        }
Exemplo n.º 2
0
 public CreatorEvent(ProjectInfo data)
 {
     _data = data;
 }
Exemplo n.º 3
0
        private void createButton_Click(object sender, EventArgs e)
        {
            bool isEmpty = true;
            foreach(ComboBox box in participantBoxes) {
                if((int)box.SelectedValue != -1) {
                    isEmpty = false;
                    break;
                }
            }
            if(isEmpty) {
                MessageBox.Show("Specify at least one participant");
                return;
            }
            if(OnCreate != null) {

                if(clientBox.Text == "" || projectBox.Text == "" || typeBox.Text == "" || dateBox.Text == "" || requestBox.Text == null) {
                    MessageBox.Show("Please, fill all text boxes.");
                    return;
                }
                ProjectCreator.ProjectInfo info = new ProjectInfo();
                if(clientBox.SelectedValue == null) info.clientId = -1;
                else {
                    info.clientId = (int)clientBox.SelectedValue;
                }
                info.clientName = clientBox.Text;
                info.projectId = Int32.Parse(projectIdBox.Text);
                info.projectName = projectBox.Text;
                info.projectStartDate = startDateBox.Text;
                info.letterDate = dateBox.Text;
                info.projectType = (int)typeBox.SelectedValue;
                info.projectTypeName = typeBox.Text;
                info.requestType = (int)requestBox.SelectedValue;
                info.requestTypeName = requestBox.Text;
                info.participants = new List<int>();
                info.deadline = DateTime.Parse(deadlineBox.Text).ToShortDateString();
                foreach(ComboBox box in participantBoxes) {
                    if((int)box.SelectedValue >= 0) {
                        info.participants.Add((int)box.SelectedValue);
                    }
                }
                if(isPlanBox.Checked) {
                    info.stagesDate = new Dictionary<int, KeyValuePair<string, string>>();
                    for(int i = 0; i < stageBoxes.Count; i++) {
                        if(dateFromBoxes[i].Checked == false) continue;
                        info.stagesDate[i + 1] = new KeyValuePair<string, string>(DateTime.Parse(dateFromBoxes[i].Text).ToShortDateString(), DateTime.Parse(dateToBoxes[i].Text).ToShortDateString());
                    }
                }
                OnCreate(sender, new CreatorEvent(info));
            }
        }
Exemplo n.º 4
0
        public void createProject(ProjectInfo info)
        {
            //cnn.Open();
            int clientId = info.clientId;
            int projectId = info.projectId;
            string insertStatement;
            OleDbCommand insertCommand;
            OleDbTransaction transaction = cnn.BeginTransaction();

            try {
                if(clientId == -1) { //!(new OleDbCommand("SELECT * FROM Clients WHERE id=" + clientId.ToString(), cnn).ExecuteReader().HasRows)) {
                    insertStatement = "INSERT INTO Clients "
                             + "(clientName) "
                             + "VALUES (@clientName)";
                    insertCommand = new OleDbCommand(insertStatement, cnn);
                    insertCommand.Transaction = transaction;
                    //insertCommand.Parameters.Add("@id", OleDbType.Integer).Value = clientId;
                    insertCommand.Parameters.Add("@clientName", OleDbType.Char).Value = info.clientName;
                    insertCommand.ExecuteNonQuery();
                    insertCommand.CommandText = "Select @@Identity";
                    clientId = (int)insertCommand.ExecuteScalar();
                }

                if(info.stagesDate != null) {
                    foreach(int id in info.stagesDate.Keys) {
                        insertStatement = "INSERT INTO Stages "
                              + "(projectId, stageId, plannedStartDate, plannedEndDate, roundNumber)"
                              + "VALUES (@projectId, @stageId, @plannedStartDate, @plannedEndDate, @roundNumber)";
                        insertCommand = new OleDbCommand(insertStatement, cnn);
                        insertCommand.Transaction = transaction;
                        insertCommand.Parameters.Add("@projectId", OleDbType.Integer).Value = projectId;
                        insertCommand.Parameters.Add("@stageId", OleDbType.Integer).Value = id;
                        insertCommand.Parameters.Add("@plannedStartDate", OleDbType.Date).Value = info.stagesDate[id].Key;
                        insertCommand.Parameters.Add("@plannedEndDate", OleDbType.Date).Value = info.stagesDate[id].Value;
                        insertCommand.Parameters.Add("@roundNumber", OleDbType.Integer).Value = 1;
                        insertCommand.ExecuteNonQuery();
                    }
                }
                foreach(int player in info.participants) {
                    insertStatement = "INSERT INTO ProjectParticipants "
                        + "(projectId, participantId)"
                        + "VALUES (@projectId, @participantId)";
                    insertCommand = new OleDbCommand(insertStatement, cnn);
                    insertCommand.Transaction = transaction;
                    insertCommand.Parameters.Add("@projectId", OleDbType.Integer).Value = projectId;
                    insertCommand.Parameters.Add("@participantId", OleDbType.Integer).Value = player;
                    insertCommand.ExecuteNonQuery();
                }

                insertStatement = "INSERT INTO Projects "
                         + "(id, projectName, currentStageId, responsibleId, projectType, requestType, clientId, isClosed, pathToFolder, deadline, startDate) "
                         + "VALUES (@id, @projectName, @currentStageId, @responsibleId, @projectType, @requestType, @clientId, @isClosed, @pathToFolder, @deadline, @startDate)";

                insertCommand = new OleDbCommand(insertStatement, cnn);
                insertCommand.Transaction = transaction;
                insertCommand.Parameters.Add("@id", OleDbType.Integer).Value = projectId;
                insertCommand.Parameters.Add("@projectName", OleDbType.Char).Value = info.projectName;
                insertCommand.Parameters.Add("@currentStageId", OleDbType.Integer).Value = 1;
                insertCommand.Parameters.Add("@responsibleId", OleDbType.Integer).Value = info.pilot;
                insertCommand.Parameters.Add("@projectType", OleDbType.Integer).Value = info.projectType;
                insertCommand.Parameters.Add("@requestType", OleDbType.Integer).Value = info.requestType;
                insertCommand.Parameters.Add("@clientId", OleDbType.Integer).Value = clientId;
                insertCommand.Parameters.Add("@isClosed", OleDbType.Integer).Value = 0;
                insertCommand.Parameters.Add("@pathToFolder", OleDbType.Char).Value = info.path;
                insertCommand.Parameters.Add("@deadline", OleDbType.Date).Value = info.deadline;
                insertCommand.Parameters.Add("@startDate", OleDbType.Date).Value = info.projectStartDate;
                insertCommand.ExecuteNonQuery();
                transaction.Commit();
                //cnn.Close();
            } catch(SystemException e) {
                transaction.Rollback();
                throw e;
            }
        }