Beispiel #1
0
 private void addaudit(string KeyIdName, string tableName, string tableKeyId, string tableDesc)
 {
     if (roleAuditingManager.IsNeedAuditByTableName(tableName))
     {
         //  Model.RoleAuditing roleAuditing = this.roleAuditingManager.SelectByInvoiceIdAndTable(invoice.InvoiceId, tableName);
         //if (   isUpdate == 0) //代表 添加
         if (this.action == "insert")
         {
             Model.RoleAuditing roleAuditing = new Book.Model.RoleAuditing();
             roleAuditing.RoleAuditingId = Guid.NewGuid().ToString();
             roleAuditing.AuditRank      = 0;
             roleAuditing.NextAuditRole  = new BL.RoleManager().select_byAuditRandTableName(1, tableName);
             if (roleAuditing.NextAuditRole != null)
             {
                 roleAuditing.NextAuditRoleId = roleAuditing.NextAuditRole.RoleId;
             }
             roleAuditing.AuditState  = (int)global::Helper.InvoiceAudit.WaitAudit;
             roleAuditing.Employee0Id = BL.V.ActiveOperator.EmployeeId;
             roleAuditing.InsertTime  = DateTime.Now;
             roleAuditing.InvoiceId   = tableKeyId;
             roleAuditing.InvoiceName = new BL.OperationManager().GetOperationNamebyTabel(tableName);;
             roleAuditing.TableName   = tableName;
             this.roleAuditingManager.Insert(roleAuditing);
         }
         if (this.action == "update")
         {
             if (AuditState() == 4)
             {
                 Model.RoleAuditing roleAuditing = this.roleAuditingManager.SelectByInvoiceIdAndTable(tableKeyId, tableName);
                 roleAuditing.AuditRank     = 0;
                 roleAuditing.NextAuditRole = new BL.RoleManager().select_byAuditRandTableName(1, tableName);
                 if (roleAuditing.NextAuditRole != null)
                 {
                     roleAuditing.NextAuditRoleId = roleAuditing.NextAuditRole.RoleId;
                 }
                 roleAuditing.AuditState  = (int)global::Helper.InvoiceAudit.WaitAudit;
                 roleAuditing.Employee0Id = BL.V.ActiveOperator.EmployeeId;
                 this.roleAuditingManager.Update(roleAuditing);
             }
         }
         string sql = "update " + tableName + " set  AuditState= " + (int)global::Helper.InvoiceAudit.WaitAudit + "  where " + KeyIdName + "='" + tableKeyId + "'";
         new BL.InvoiceXJManager().UpdateSql(sql);
     }
 }
Beispiel #2
0
        public void Insert(Model.Invoice invoice)
        {
            _ValidateForInsert(invoice);
            //MethodInfo methodinfo = this.GetType().GetMethod("HasRows", new Type[] { typeof(string) });
            //bool f = (bool)methodinfo.Invoke(this, new object[] { invoice.InvoiceId });

            //if (f)
            //{
            //    throw new Helper.InvalidValueException(Model.Invoice.PROPERTY_INVOICEID);
            //}

            try
            {
                V.BeginTransaction();
                invoice.InsertTime = DateTime.Now;
                TiGuiExists(invoice);
                string tableName = this.GetType().Name.Substring(0, this.GetType().Name.IndexOf("Manager"));
                if (roleAuditingManager.IsNeedAuditByTableName(tableName))
                {
                    //  Model.RoleAuditing roleAuditing = this.roleAuditingManager.SelectByInvoiceIdAndTable(invoice.InvoiceId, tableName);
                    //if (   isUpdate == 0) //代表 添加
                    {
                        invoice.AuditState = (int)global::Helper.InvoiceAudit.WaitAudit;

                        Model.RoleAuditing roleAuditing = new Book.Model.RoleAuditing();
                        roleAuditing.RoleAuditingId = Guid.NewGuid().ToString();
                        roleAuditing.AuditRank      = 0;
                        roleAuditing.NextAuditRole  = new BL.RoleManager().select_byAuditRandTableName(1, tableName);
                        if (roleAuditing.NextAuditRole != null)
                        {
                            roleAuditing.NextAuditRoleId = roleAuditing.NextAuditRole.RoleId;
                        }
                        roleAuditing.AuditState  = (int)global::Helper.InvoiceAudit.WaitAudit;
                        roleAuditing.Employee0Id = V.ActiveOperator.EmployeeId;
                        roleAuditing.InsertTime  = DateTime.Now;
                        roleAuditing.InvoiceId   = invoice.InvoiceId;

                        roleAuditing.InvoiceName = new OperationManager().GetOperationNamebyTabel(tableName);
                        roleAuditing.TableName   = tableName;
                        this.roleAuditingManager.Insert(roleAuditing);
                    }
                }
                else
                {
                    invoice.AuditState = (int)global::Helper.InvoiceAudit.NoUsing;
                }



                _Insert(invoice);
                string invoiceKind   = this.GetInvoiceKind().ToLower();
                string sequencekey_y = string.Format("{0}-y-{1}", invoiceKind, invoice.InsertTime.Value.Year);
                string sequencekey_m = string.Format("{0}-m-{1}-{2}", invoiceKind, invoice.InsertTime.Value.Year, invoice.InsertTime.Value.Month);
                string sequencekey_d = string.Format("{0}-d-{1}", invoiceKind, invoice.InsertTime.Value.ToString("yyyy-MM-dd"));
                string sequencekey   = string.Format(invoiceKind);
                SequenceManager.Increment(sequencekey_y);
                SequenceManager.Increment(sequencekey_m);
                SequenceManager.Increment(sequencekey_d);
                SequenceManager.Increment(sequencekey);


                V.CommitTransaction();
            }
            catch
            {
                V.RollbackTransaction();
                throw;
            }
        }
Beispiel #3
0
        private void ClickSave(int flagAut, string KeyIdName, string tableName, string tableKeyId)
        {
            try
            {
                bool checkwf = false;

                //if (this.action == "insert")
                //{
                //    Workflowinsert wfinsert = new Workflowinsert();

                //    if (!string.IsNullOrEmpty(this.tableCode()))
                //    {
                //        checkwf = wfinsert.Checkwfbytablescode(this.tableCode().Substring(0, this.tableCode().IndexOf(',')));
                //        if (checkwf)
                //            saveAuditState = (int)global::Helper.InvoiceAudit.WaitAudit;
                //    }
                //}
                saveAuditState = (int)global::Helper.InvoiceAudit.NoUsing;
                this.Save();


                //MessageBox.Show("fdafda");
                if (flagAut == 1 && roleAuditingManager.IsNeedAuditByTableName(tableName))
                {
                    //  Model.RoleAuditing roleAuditing = this.roleAuditingManager.SelectByInvoiceIdAndTable(invoice.InvoiceId, tableName);
                    //if (   isUpdate == 0) //代表 添加
                    if (this.action == "insert")
                    {
                        Model.RoleAuditing roleAuditing = new Book.Model.RoleAuditing();
                        roleAuditing.RoleAuditingId = Guid.NewGuid().ToString();
                        roleAuditing.AuditRank      = 0;
                        roleAuditing.NextAuditRole  = new BL.RoleManager().select_byAuditRandTableName(1, tableName);
                        if (roleAuditing.NextAuditRole != null)
                        {
                            roleAuditing.NextAuditRoleId = roleAuditing.NextAuditRole.RoleId;
                        }
                        roleAuditing.AuditState  = (int)global::Helper.InvoiceAudit.WaitAudit;
                        roleAuditing.Employee0Id = BL.V.ActiveOperator.EmployeeId;
                        roleAuditing.InsertTime  = DateTime.Now;
                        roleAuditing.InvoiceId   = tableKeyId;
                        roleAuditing.InvoiceName = new BL.OperationManager().GetOperationNamebyTabel(tableName);;
                        roleAuditing.TableName   = tableName;
                        this.roleAuditingManager.Insert(roleAuditing);
                    }
                    if (this.action == "update")
                    {
                        if (AuditState() == 4)
                        {
                            Model.RoleAuditing roleAuditing = this.roleAuditingManager.SelectByInvoiceIdAndTable(tableKeyId, tableName);
                            roleAuditing.AuditRank     = 0;
                            roleAuditing.NextAuditRole = new BL.RoleManager().select_byAuditRandTableName(1, tableName);
                            if (roleAuditing.NextAuditRole != null)
                            {
                                roleAuditing.NextAuditRoleId = roleAuditing.NextAuditRole.RoleId;
                            }
                            roleAuditing.AuditState  = (int)global::Helper.InvoiceAudit.WaitAudit;
                            roleAuditing.Employee0Id = BL.V.ActiveOperator.EmployeeId;
                            this.roleAuditingManager.Update(roleAuditing);
                        }
                    }
                    string sql = "update " + tableName + " set  AuditState= " + (int)global::Helper.InvoiceAudit.WaitAudit + "  where " + KeyIdName + "='" + tableKeyId + "'";
                    new BL.AcademicBackGroundManager().UpdateSqlMap(sql);
                }
                //catch (Exception ex)
                //{
                //    BL.V.RollbackTransaction();
                //    throw ex;
                //}

                this.action = "view";
                this.Refresh();
            }
            catch (Helper.MessageValueException ex)
            {
                if (!string.IsNullOrEmpty(ex.Message) && !ex.Message.Equals("SaveCancel", StringComparison.InvariantCultureIgnoreCase))
                {
                    MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                return;
            }
            catch (Helper.RequireValueException ex)
            {
                if (this.requireValueExceptions.ContainsKey(ex.Message))
                {
                    AA aa = this.requireValueExceptions[ex.Message];
                    MessageBox.Show(aa.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    aa.Control.Focus();
                    return;
                }
                throw;
            }
            catch (Helper.InvalidValueException ex)
            {
                if (this.invalidValueExceptions.ContainsKey(ex.Message))
                {
                    AA aa = this.invalidValueExceptions[ex.Message];
                    MessageBox.Show(aa.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    aa.Control.Focus();
                    return;
                }
                throw;
            }
            catch (Helper.ViolateConstraintException ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }
            catch (Helper.VersionOverTimeException)
            {
                MessageBox.Show(Properties.Resources.ObjectHasChange, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.action = "view";
                this.Refresh();
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            MessageBox.Show(Properties.Resources.SuccessfullySaved, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.DialogResult = DialogResult.OK;
        }