Beispiel #1
0
 /***** update approvement group *****/
 public void updateApprovementGroup(ApprovementGroup approvementGr)
 {
     using (var session = NHibernateHelper.OpenSession())
     {
         using (var transaction = session.BeginTransaction())
         {
             session.Merge(approvementGr);
             transaction.Commit();
         }
     }
 }
Beispiel #2
0
        /******* add an approvement group  */

        public ApprovementGroup addApprovementGroup(ApprovementGroup approvementGroupe)
        {
            using (var session = NHibernateHelper.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    session.Save(approvementGroupe);
                    transaction.Commit();
                }
            }

            return(approvementGroupe);
        }
        private void registerApprovementGroupe_Click(object sender, EventArgs e)
        {
            if (this.isValidateFrom())
            {
                if (this.idGroupeApprovement.Text != "")
                {
                    //update Approment Group
                    int id = int.Parse(this.idGroupeApprovement.Text);
                    ApprovementGroup approvementGr = deviationModel.getApprovementGroup(id);

                    approvementGr.liblle     = this.liblle.Text;
                    approvementGr.role       = this.role.Text;
                    approvementGr.groupEmail = this.groupEmail.Text;

                    deviationModel.updateApprovementGroup(approvementGr);

                    MessageBox.Show("Approvement Group was successfully updated !");

                    //reload the Approvement group list
                    this.showApprovementGroupList();
                }
                else
                {
                    //add new approvement Group
                    ApprovementGroup approvementGroup = new ApprovementGroup();
                    approvementGroup.liblle     = this.liblle.Text;
                    approvementGroup.role       = this.role.Text;
                    approvementGroup.groupEmail = this.groupEmail.Text;
                    deviationModel.addApprovementGroup(approvementGroup);

                    MessageBox.Show("Approvement Group was successfully added !");

                    //reload the Approvement group list
                    this.showApprovementGroupList();
                }
            }
        }
Beispiel #4
0
        //create a Deviation object from Form inputs
        private Deviation getDeviationObject()
        {
            Deviation deviation = new Deviation();

            deviation.deviationRef          = this.deviationNO.Text;
            deviation.deviationRiskCategory = this.riskCategory.Text;
            deviation.requestedBy           = this.requestedBy.Text;
            deviation.position                = this.position.Text;
            deviation.deviationType           = this.deviationType.SelectedItem.ToString();
            deviation.describeOtherType       = this.deviationDescription.Text;
            deviation.signature               = this.deviationSignature.Text;
            deviation.detailStandardCondition = this.standardCondition.Text;
            deviation.detailRequestCondition  = this.detailRequestedDeviation.Text;
            deviation.barcode = this.barcode.Text;
            deviation.anlage  = this.anlage.Text;
            deviation.product = this.product.Text;
            if (this.actionType == "newDeviation")
            {
                deviation.status = "Pending";
            }

            DateTime deviationDateCreation = this.deviationDateCreation.Value;
            DateTime deviationTimeCreation = this.deviationTimeCreation.Value;

            deviation.dateCreation = new DateTime(deviationDateCreation.Year, deviationDateCreation.Month, deviationDateCreation.Day, deviationTimeCreation.Hour, deviationTimeCreation.Minute, deviationTimeCreation.Second);

            DateTime pFirstDate = this.pFirstDate.Value;
            DateTime pFirstTime = this.pFirstTime.Value;

            deviation.startDatePeriod = new DateTime(pFirstDate.Year, pFirstDate.Month, pFirstDate.Day, pFirstTime.Hour, pFirstTime.Minute, pFirstTime.Second);

            DateTime pSecondDate = this.pSecondDate.Value;
            DateTime pSecondTime = this.pSecondTime.Value;

            deviation.endDatePeriod = new DateTime(pSecondDate.Year, pSecondDate.Month, pSecondDate.Day, pSecondTime.Hour, pSecondTime.Minute, pSecondTime.Second);



            //add Reasons
            IList <Reason> listReasons = new List <Reason>();
            Reason         reas1       = new Reason {
                reason = this.reason1.Text
            };
            Reason reas2 = new Reason {
                reason = this.reason2.Text
            };
            Reason reas3 = new Reason {
                reason = this.reason3.Text
            };
            Reason reas4 = new Reason {
                reason = this.reason4.Text
            };
            Reason reas5 = new Reason {
                reason = this.reason5.Text
            };

            listReasons.Add(reas1); listReasons.Add(reas2); listReasons.Add(reas3);
            listReasons.Add(reas4); listReasons.Add(reas5);
            deviation.reasons = listReasons;


            //add Approvement Groups
            IList <Approvement> listApprovements = new List <Approvement>();

            foreach (DataGridViewRow row in this.approvementGroupDataGrid.Rows)
            {
                int approvementGroupId = (int)row.Cells[0].Value;
                if (approvementGroupId != 0)
                {
                    ApprovementGroup approvementGroup = deviationModel.getApprovementGroup(approvementGroupId);
                    if (approvementGroup != null)
                    {
                        Approvement approvement = new Approvement();
                        approvement.approvementGroup = approvementGroup;
                        listApprovements.Add(approvement);
                    }
                }
            }

            deviation.approvements = listApprovements;


            //Add Attachments
            IList <Attachments> listAttachments = new List <Attachments>();

            foreach (DataGridViewRow row in this.uploadFileDataGridView.Rows)
            {
                Attachments attachement = new Attachments();
                attachement.fileName   = row.Cells[0].Value.ToString();
                attachement.fileNameDb = row.Cells[1].Value.ToString();
                attachement.date       = DateTime.Now;
                if (row.Cells[3].Value != null)
                {
                    attachement.liblle = row.Cells[3].Value.ToString();
                }

                listAttachments.Add(attachement);
            }

            deviation.attachements = listAttachments;


            return(deviation);
        }