protected ProjectProblemActionUserLinkFacade(ProjectProblemActionUserLinkModel model) : base(model)
 {
 }
예제 #2
0
        void save()
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                Action.Action           = txtAction.Text.Trim();
                Action.CompletedDate    = (DateTime?)dtpDateCompleted.EditValue;
                Action.Result           = txtResult.Text.Trim();
                Action.IsCompleted      = chkIsCompleted.Checked;
                Action.ProjectProblemID = ProjectProblemID;

                if (Action.ID <= 0)
                {
                    Action.ID = (int)pt.Insert(Action);
                }
                else
                {
                    pt.Update(Action);
                }

                for (int i = 0; i < grvData.RowCount; i++)
                {
                    long id = TextUtils.ToInt64(grvData.GetRowCellValue(i, colID));
                    ProjectProblemActionUserLinkModel model = new ProjectProblemActionUserLinkModel();
                    if (id > 0)
                    {
                        model = (ProjectProblemActionUserLinkModel)ProjectProblemActionUserLinkBO.Instance.FindByPK(id);
                    }

                    model.UserId = TextUtils.ToString(grvData.GetRowCellValue(i, colUserId));
                    model.ProjectProblemActionID = Action.ID;

                    if (id > 0)
                    {
                        pt.Update(model);
                    }
                    else
                    {
                        pt.Insert(model);
                    }
                }

                pt.CommitTransaction();

                loadGrid();
                _isSaved = true;

                MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }

            if (_isSaved)
            {
                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
        }