Exemple #1
0
        void BaseEditForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (this.action != "view")
            {
                DialogResult result = MessageBox.Show(Properties.Resources.DataChangedDoYouSave, this.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                switch (result)
                {
                case DialogResult.Yes:
                    int flagAut = 0;

                    string KeyIdName  = null;
                    string tableName  = null;
                    string tableKeyId = null;
                    string tableDesc  = null;
                    if (!string.IsNullOrEmpty(tableCode()))
                    {
                        flagAut    = 1;
                        KeyIdName  = AuditKeyId();
                        tableName  = this.tableCode().Substring(0, this.tableCode().IndexOf(','));
                        tableKeyId = this.tableCode().Substring(this.tableCode().IndexOf(',') + 1);
                        tableDesc  = new BL.OperationManager().GetOperationNamebyTabel(tableName);
                    }
                    ClickSave(flagAut, KeyIdName, tableName, tableKeyId, tableDesc);
                    e.Cancel = true;
                    break;

                case DialogResult.Cancel:
                    e.Cancel = true;
                    break;
                }
            }
            GC.GetTotalMemory(true);
        }
Exemple #2
0
        private void barManager1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            int flagAut = 0;

            string KeyIdName  = null;
            string tableName  = null;
            string tableKeyId = null;
            string tableDesc  = null;

            if (!string.IsNullOrEmpty(tableCode()))
            {
                flagAut    = 1;
                KeyIdName  = AuditKeyId();
                tableName  = this.tableCode().Substring(0, this.tableCode().IndexOf(','));
                tableKeyId = this.tableCode().Substring(this.tableCode().IndexOf(',') + 1);
                tableDesc  = new BL.OperationManager().GetOperationNamebyTabel(tableName);
            }

            switch ((string)e.Item.Tag)
            {
            case "save":
                ClickSave(flagAut, KeyIdName, tableName, tableKeyId, tableDesc);
                break;

            case "undo":
                this.MoveLast();
                this.action = "view";
                this.Refresh();
                break;

            case "new":
                try
                {
                    this.AddNew();
                    this.action = "insert";
                    this.Refresh();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                break;

            case "update":
                if (MessageBox.Show("確定要修改?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    this.action = "update";
                    this.Refresh();
                }
                break;

            case "prev":
                try
                {
                    this.MovePrev();
                    this.Refresh();
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "next":
                try
                {
                    this.MoveNext();
                    this.Refresh();
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "first":
                try
                {
                    this.MoveFirst();
                    this.Refresh();
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "last":
                try
                {
                    this.MoveLast();
                    this.Refresh();
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "delete":
                try
                {
                    int a = AuditState();
                    this.Delete();
                    if (flagAut == 1 && a != 0)
                    {
                        roleAuditingManager.DeleteByInvoiceIdAndTable(tableKeyId, tableName);
                    }

                    this.Refresh();
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Helper.ViolateConstraintException ex)
                {
                    MessageBox.Show(Properties.Resources.DeleteError + ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch
                {
                    MessageBox.Show(Properties.Resources.DeleteError, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                break;

            case "Audit":
                if (flagAut == 1)
                {
                    int flag = 0;
                    try
                    {
                        if (AuditState() != (int)global::Helper.InvoiceAudit.Audited)
                        {
                            flag = 1;
                        }
                        BL.V.BeginTransaction();

                        Model.RoleAuditing roleAuditing = this.roleAuditingManager.SelectByInvoiceIdAndTable(tableKeyId, tableName);

                        if (this.barButtonItemAudit.Caption == "審核" || this.barButtonItemAudit.Caption == "审核" || this.barButtonItemAudit.Caption == "複核" || this.barButtonItemAudit.Caption == "复核")
                        {
                            roleAuditing.AuditDate = DateTime.Now;
                            roleAuditing.AuditRank = roleAuditing.AuditRank + 1;
                            //是否最后审核
                            if (!this.roleAuditingManager.IsLastAudit(roleAuditing.AuditRank.Value + 1, tableKeyId, tableName))
                            {
                                roleAuditing.AuditState      = (int)global::Helper.InvoiceAudit.Audited;//审核结束
                                roleAuditing.NextAuditRole   = null;
                                roleAuditing.NextAuditRoleId = null;
                                roleAuditing.Role1           = new BL.RoleManager().select_byAuditRandTableName(roleAuditing.AuditRank.Value, tableName);
                                if (roleAuditing.Role1 != null)
                                {
                                    roleAuditing.Role1Id = roleAuditing.Role1.RoleId;
                                }
                            }
                            else
                            {
                                roleAuditing.AuditState = (int)global::Helper.InvoiceAudit.OnAuditing;
                                roleAuditing.Role1      = new BL.RoleManager().select_byAuditRandTableName(roleAuditing.AuditRank.Value, tableName);

                                if (roleAuditing.Role1 != null)
                                {
                                    roleAuditing.Role1Id = roleAuditing.Role1.RoleId;
                                }

                                roleAuditing.NextAuditRole = new BL.RoleManager().select_byAuditRandTableName(roleAuditing.AuditRank.Value + 1, tableName);
                                if (roleAuditing.NextAuditRole != null)
                                {
                                    roleAuditing.NextAuditRoleId = roleAuditing.NextAuditRole.RoleId;
                                }
                            }

                            roleAuditing.Employee1Id = BL.V.ActiveOperator.EmployeeId;
                            roleAuditing.UpdateTime  = DateTime.Now;
                            this.roleAuditingManager.Update(roleAuditing);
                            string sql = "update " + tableName + " set  AuditState= " + roleAuditing.AuditState + ",   AuditEmpId='" + BL.V.ActiveOperator.EmployeeId + "' where " + KeyIdName + "='" + tableKeyId + "'";
                            new BL.InvoiceXJManager().UpdateSql(sql);
                            // this.barButtonItemAudit.Caption = "棄審";
                        }
                        else if (this.barButtonItemAudit.Caption == "棄審" || this.barButtonItemAudit.Caption == "弃审")
                        {    //弃核
                            roleAuditing.AuditState    = (int)global::Helper.InvoiceAudit.GiveUpAudited;
                            roleAuditing.AuditRank     = 0;
                            roleAuditing.NextAuditRole = new BL.RoleManager().select_byAuditRandTableName(1, tableName);
                            if (roleAuditing.NextAuditRole != null)
                            {
                                roleAuditing.NextAuditRoleId = roleAuditing.NextAuditRole.RoleId;
                            }
                            this.roleAuditingManager.Update(roleAuditing);

                            string sql = "update " + tableName + " set  AuditState= " + (int)global::Helper.InvoiceAudit.GiveUpAudited + ",   AuditEmpId='" + BL.V.ActiveOperator.EmployeeId + "' where " + KeyIdName + "='" + tableKeyId + "'";
                            new BL.InvoiceXJManager().UpdateSql(sql);
                            //   this.barButtonItemAudit.Caption = "審核";
                        }

                        this.Refresh();
                        BL.V.CommitTransaction();
                    }



                    catch (Exception ex)
                    {
                        if (flag == 1)
                        {
                            this.barButtonItemAudit.Caption = "審核";
                        }
                        else
                        {
                            this.barButtonItemAudit.Caption = "棄審";
                        }
                        BL.V.RollbackTransaction();
                        throw ex;
                    }
                }
                break;
            //if (!string.IsNullOrEmpty(this.tableCode()))
            //{

            //    Model.wfrecord wfr = wfrecordManager.GetByTableCodeAndKeyId(this.tableCode().Substring(0, this.tableCode().IndexOf(',')), this.tableCode().Substring(this.tableCode().IndexOf(',') + 1, this.tableCode().LastIndexOf(',') - this.tableCode().IndexOf(',') - 1));
            //    if (wfr != null)
            //    {
            //        if (this.AuditState() != (int)global::Helper.InvoiceAudit.Audited)
            //        {//审核

            //            Model.process noprocess = processManager.GetProcessbyid(wfr.nowprocessid);
            //            if (noprocess != null)
            //            {
            //                wfr.processId = wfr.nowprocessid;
            //                wfr.nowprocessid = noprocess.Processnex;
            //                Model.process proc = processManager.GetProcessbyid(wfr.nowprocessid);
            //                wfr.allovertime = DateTime.Today;
            //                if (proc.processType == "结束")
            //                {
            //                    wfr.allstate = (int)global::Helper.InvoiceAudit.Audited;
            //                }
            //                else
            //                {
            //                    wfr.allstate = (int)global::Helper.InvoiceAudit.OnAuditing;
            //                }
            //                wfrecordManager.Update(wfr);
            //                string sql = "update " + this.tableCode().Substring(0, this.tableCode().IndexOf(',')) + " set  AuditState= " + wfr.allstate + ",   AuditEmpId='" + BL.V.ActiveOperator.EmployeeId + "' where " + this.AuditKeyId() + "='" + this.tableCode().Substring(this.tableCode().IndexOf(',') + 1, this.tableCode().LastIndexOf(',') - this.tableCode().IndexOf(',') - 1) + "'";
            //                new BL.InvoiceXJManager().UpdateSql(sql);
            //            }
            //            this.barButtonItemAudit.Caption = "棄審";
            //        }
            //        else
            //        {
            //            //弃核
            //            foreach (Model.process p in processManager.SelectProcessbywf(wfr.WorkflowId))
            //            {
            //                if (p.processType == "开始")
            //                {
            //                    wfr.processId = p.processId;
            //                    wfr.nowprocessid = p.Processnex;
            //                    break;
            //                }
            //            }
            //            wfr.allovertime = DateTime.Now;
            //            wfr.allstate = (int)global::Helper.InvoiceAudit.GiveUpAudited;
            //            wfrecordManager.Update(wfr);

            //            string sql = "update " + this.tableCode().Substring(0, this.tableCode().IndexOf(',')) + " set  AuditState= " + wfr.allstate + ",   AuditEmpId='" + BL.V.ActiveOperator.EmployeeId + "' where " + this.AuditKeyId() + "='" + this.tableCode().Substring(this.tableCode().IndexOf(',') + 1, this.tableCode().LastIndexOf(',') - this.tableCode().IndexOf(',') - 1) + "'";
            //            new BL.InvoiceXJManager().UpdateSql(sql);

            //            this.barButtonItemAudit.Caption = "審核";

            //        }


            //    }
            //}
            //更新表单
            //this.Refresh();
            //BL.V.CommitTransaction();
            //if (wfinsertManager.Checkwfbytablescode(tableCode()))
            //{
            //    wfinsertManager.insertwfrecord("TechonlogyHeader", "工艺 " + this.techonlogyHeader.TechonlogyHeadername, this.techonlogyHeader.TechonlogyHeaderId);
            //}
            //else
            //{
            //}
            //    }
            //    catch (Exception ex)
            //    {
            //        this.barButtonItemAudit.Caption = "審核";
            //        BL.V.RollbackTransaction();
            //        throw ex;
            //    }
            //    break;
            case "Attachment":
                if (!string.IsNullOrEmpty(tableKeyId))
                {
                    BaseAttachmentView bav = new BaseAttachmentView(tableKeyId, this.GetType().FullName);
                    bav.ShowDialog(this);
                }
                break;
            }
        }