예제 #1
0
        private void CopyItemBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            switch (focused_tree_node.GType)
            {
            case 2:
                var dr  = MoneyMoveGridView.GetFocusedRow() as MoneyMoveList_Result;
                var doc = DB.SkladBase().DocCopy(dr.Id, DBHelper.CurrentUser.KaId).FirstOrDefault();
                if (dr.DocType == 6)
                {
                    using (var money_corr = new frmMoneyCorrecting(doc.out_wbill_id))
                    {
                        money_corr.ShowDialog();
                    }
                }

                if (dr.DocType == 3)
                {
                    using (var money_move = new frmMoneyMove(doc.out_wbill_id))
                    {
                        money_move.ShowDialog();
                    }
                }

                break;
            }
            RefrechItemBtn.PerformClick();
        }
예제 #2
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            using (var frm = new frmMoneyMove())
            {
                frm.ShowDialog();
            }

            RefrechItemBtn.PerformClick();
        }
예제 #3
0
        public static void FinDocEdit(MoneyMoveList_Result pd_row)
        {
            if (pd_row == null)
            {
                return;
            }

            using (var db = new BaseEntities())
            {
                var trans = db.Database.BeginTransaction();
                try
                {
                    var pd = db.Database.SqlQuery <PayDoc>("SELECT * from PayDoc WITH (UPDLOCK, NOWAIT) where PayDocId = {0}", pd_row.PayDocId).FirstOrDefault();
                    if (pd == null)
                    {
                        MessageBox.Show(Resources.not_find_wb);
                        return;
                    }

                    if (pd.Checked == 1)
                    {
                        if (MessageBox.Show(Resources.edit_info, "Відміна проводки", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                        {
                            pd.Checked = 0;
                            db.Entry <PayDoc>(pd).State = System.Data.Entity.EntityState.Modified;

                            var pd_to = db.PayDoc.FirstOrDefault(w => w.OperId == pd.OperId);
                            if (pd_to != null)
                            {
                                pd_to.Checked = 0;
                            }

                            db.SaveChanges();
                        }
                    }
                    trans.Commit();

                    if (pd.Checked == 0)
                    {
                        if (pd.DocType == 6)
                        {
                            using (var pd_form = new frmMoneyCorrecting(pd_row.PayDocId))
                            {
                                pd_form.ShowDialog();
                            }
                        }

                        if (pd.DocType == 3)
                        {
                            using (var pd_form = new frmMoneyMove(pd_row.PayDocId))
                            {
                                pd_form.ShowDialog();
                            }
                        }
                    }
                }
                catch (EntityCommandExecutionException exception)
                {
                    var e = exception.InnerException as SqlException;
                    if (e != null)
                    {
                        if (!e.Errors.Cast <SqlError>().Any(error =>
                                                            (error.Number == DeadlockErrorNumber) ||
                                                            (error.Number == LockingErrorNumber) ||
                                                            (error.Number == UpdateConflictErrorNumber)))
                        {
                            MessageBox.Show(e.Message);
                        }
                        else
                        {
                            MessageBox.Show(Resources.deadlock);
                        }
                    }
                    else
                    {
                        MessageBox.Show(exception.Message);
                    }

                    return;
                }
            }
        }