Ejemplo n.º 1
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            if (_pd.OnDate.Date <= _db.CommonParams.First().EndCalcPeriod)
            {
                MessageBox.Show("Період вже закритий. Змініть дату документа!", "Відміна/Проведення платіжного документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            var rl = _db.GetRelDocList(_pd.Id).ToList();

            foreach (var item in rl)
            {
                _db.DeleteWhere <DocRels>(w => w.OriginatorId == item.Id && w.RelOriginatorId == _pd.Id);
            }
            _db.SaveChanges();

            if (PayDocCheckEdit.Checked && DocListEdit.EditValue != null)
            {
                var row = DocListEdit.GetSelectedDataRow() as GetWayBillList_Result;

                _pd = _db.PayDoc.AsNoTracking().FirstOrDefault(w => w.PayDocId == _pd.PayDocId);
                _db.SetDocRel(row.Id, _pd.Id);

                _db.SaveChanges();
            }

            current_transaction.Commit();

            Close();
        }
Ejemplo n.º 2
0
        private void SumEdit_EditValueChanged(object sender, EventArgs e)
        {
            var row = DocListEdit.GetSelectedDataRow() as GetWayBillList_Result;

            if (row == null)
            {
                textEdit4.EditValue = SumEdit.EditValue;
            }
            else
            {
                textEdit4.EditValue = row.Balans - (SumEdit.Value * CurrValueEdit.Value);
            }

            GetOk();
        }
Ejemplo n.º 3
0
        private void DocListEdit_EditValueChanged(object sender, EventArgs e)
        {
            if (!DocListEdit.ContainsFocus)
            {
                return;
            }

            var row = DocListEdit.GetSelectedDataRow() as GetWayBillList_Result;

            if (row != null)
            {
                SumEdit.EditValue        = row.Balans;
                _pd.Total                = row.Balans.Value;
                KagentComboBox.EditValue = row.KaId;
                _pd.KaId = row.KaId;

                _pd.Reason           = TypDocsEdit.Text + " №" + DocListEdit.Text;
                ReasonEdit.EditValue = _pd.Reason;
            }
        }
Ejemplo n.º 4
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            _pd_from.Total = SumEdit.Value;


            var rl = _db.GetRelDocList(_pd_from.Id).ToList();

            foreach (var item in rl)
            {
                _db.DeleteWhere <DocRels>(w => w.OriginatorId == item.Id && w.RelOriginatorId == _pd_from.Id);
            }
            _db.SaveChanges();

            if (PayDocCheckEdit.Checked && DocListEdit.EditValue != null)
            {
                var row = DocListEdit.GetSelectedDataRow() as GetWayBillList_Result;
                _db.SetDocRel(row.Id, _pd_from.Id);
                _db.SaveChanges();
            }

            current_transaction.Commit();
        }
Ejemplo n.º 5
0
        private void frmPayDoc_Load(object sender, EventArgs e)
        {
            PTypeComboBox.Properties.DataSource    = DBHelper.PayTypes;
            CashEditComboBox.Properties.DataSource = DBHelper.CashDesks;
            KagentComboBox.Properties.DataSource   = DBHelper.Kagents;
            PersonEdit.Properties.DataSource       = DBHelper.Persons;
            CurrEdit.Properties.DataSource         = DBHelper.Currency;
            ChargeTypesEdit.Properties.DataSource  = DBHelper.ChargeTypes;


            var ent_id = DBHelper.Enterprise.KaId;

            user_acc_list = _db.EnterpriseAccount.Where(w => w.KaId == ent_id).Select(s => new user_acc
            {
                AccId      = s.AccId,
                AccNum     = s.AccNum,
                Name       = s.BankName,
                ExtDocType = 1
            }).ToList();


            if (_PayDocId == null)
            {
                int    w_type           = _DocType.Value != -2 ? _DocType.Value * 3 : _DocType.Value;
                string doc_setting_name = w_type == -3 ? "pay_doc_out" : w_type == 3 ? "pay_doc_in" : "pay_doc";
                _pd = _db.PayDoc.Add(new PayDoc
                {
                    Id        = Guid.NewGuid(),
                    Checked   = 1,
                    DocNum    = new BaseEntities().GetDocNum(doc_setting_name).FirstOrDefault(),
                    OnDate    = DBHelper.ServerDateTime(),
                    Total     = _summ_pay == null ? 0 : _summ_pay.Value,
                    CTypeId   = DBHelper.ChargeTypes.Any(a => a.Def == 1) ? DBHelper.ChargeTypes.FirstOrDefault(w => w.Def == 1).CTypeId : DBHelper.ChargeTypes.FirstOrDefault().CTypeId, // За товар
                    WithNDS   = 1,                                                                                                                                                        // З НДС
                    PTypeId   = 1,                                                                                                                                                        // Наличкой
                    CashId    = DBHelper.CashDesks.Where(w => w.Def == 1).Select(s => s.CashId).FirstOrDefault(),                                                                         // Каса по умолчанию
                    CurrId    = DBHelper.Currency.Where(w => w.Def == 1).Select(s => s.CurrId).FirstOrDefault(),                                                                          //Валюта по умолчанию
                    OnValue   = 1,                                                                                                                                                        //Курс валюти
                    MPersonId = DBHelper.CurrentUser.KaId,
                    DocType   = _DocType.Value,
                    UpdatedBy = DBHelper.CurrentUser.UserId,
                    KaId      = _ka_id,
                    EntId     = DBHelper.Enterprise.KaId
                });
            }
            else
            {
                try
                {
                    _pd = _db.Database.SqlQuery <PayDoc>("SELECT * from PayDoc WITH (UPDLOCK, NOWAIT) where PayDocId = {0}", _PayDocId).FirstOrDefault();
                    _db.Entry <PayDoc>(_pd).State = System.Data.Entity.EntityState.Modified;
                }
                catch
                {
                    Close();
                }
            }

            AccountEdit.Properties.DataSource = user_acc_list.Concat(_db.KAgentAccount.Where(w => w.KAId == _pd.KaId).Select(s => new user_acc
            {
                AccId      = s.AccId,
                AccNum     = s.AccNum,
                Name       = s.Kagent.Name,
                ExtDocType = -1,
                KaId       = s.KAId
            }).ToList()).ToList();

            if (_pd != null)
            {
                TurnDocCheckBox.DataBindings.Add(new Binding("EditValue", _pd, "Checked"));
                NumEdit.DataBindings.Add(new Binding("EditValue", _pd, "DocNum"));
                OnDateDBEdit.DataBindings.Add(new Binding("EditValue", _pd, "OnDate", true, DataSourceUpdateMode.OnPropertyChanged));
                PTypeComboBox.DataBindings.Add(new Binding("EditValue", _pd, "PTypeId", true, DataSourceUpdateMode.OnPropertyChanged));
                CashEditComboBox.DataBindings.Add(new Binding("EditValue", _pd, "CashId", true, DataSourceUpdateMode.OnPropertyChanged));
                ChargeTypesEdit.DataBindings.Add(new Binding("EditValue", _pd, "CTypeId", true, DataSourceUpdateMode.OnPropertyChanged));
                KagentComboBox.DataBindings.Add(new Binding("EditValue", _pd, "KaId", true, DataSourceUpdateMode.OnPropertyChanged));
                PersonEdit.DataBindings.Add(new Binding("EditValue", _pd, "MPersonId", true, DataSourceUpdateMode.OnPropertyChanged));
                SumEdit.DataBindings.Add(new Binding("EditValue", _pd, "Total"));
                CurrEdit.DataBindings.Add(new Binding("EditValue", _pd, "CurrId"));
                CurrValueEdit.DataBindings.Add(new Binding("EditValue", _pd, "OnValue", true, DataSourceUpdateMode.OnPropertyChanged));
                SchetEdit.DataBindings.Add(new Binding("EditValue", _pd, "Schet"));
                WithNDScheckEdit.DataBindings.Add(new Binding("EditValue", _pd, "WithNDS"));
                ReasonEdit.DataBindings.Add(new Binding("EditValue", _pd, "Reason"));
                NotesEdit.DataBindings.Add(new Binding("EditValue", _pd, "Notes"));
                AccountEdit.DataBindings.Add(new Binding("EditValue", _pd, "AccId", true, DataSourceUpdateMode.OnPropertyChanged));
            }

            if (_DocType < 0)
            {
                if (_DocType == -2)
                {
                    Text = "Властивості платежу (дод. витрати)";
                }
                if (_DocType == -1)
                {
                    Text = "Властивості вихідного платежу";
                }

                TypDocsEdit.Properties.DataSource = DBHelper.DocTypeList.Where(w => w.Id == 1 || w.Id == 6 || w.Id == 16).ToList();
                if (TypDocsEdit.EditValue == null)
                {
                    TypDocsEdit.EditValue = 1;
                }
            }
            else
            {
                Text = "Властивості вхідного платежу";
                labelControl13.Text = "Платник:";
                TypDocsEdit.Properties.DataSource = DBHelper.DocTypeList.Where(w => new int[] { -1, -6, 2, -16, -8, }.Any(a => a.Equals(w.Id))).ToList();
                if (TypDocsEdit.EditValue == null)
                {
                    TypDocsEdit.EditValue = -1;
                }
            }

            var rl = _db.GetRelDocList(_pd.Id).FirstOrDefault();

            if (rl != null)
            {
                PayDocCheckEdit.Checked = true;
                TypDocsEdit.EditValue   = rl.DocType;
                GetDocList();
                DocListEdit.EditValue = rl.Id;

                var row = DocListEdit.GetSelectedDataRow() as GetWayBillList_Result;

                textEdit4.EditValue = (row == null ? 0 : row.Balans) - SumEdit.Value;

                KagentComboBox.Enabled = false;
            }
        }
Ejemplo n.º 6
0
        private void frmMoneyMove_Load(object sender, EventArgs e)
        {
            PTypeToEdit.Properties.DataSource    = DBHelper.PayTypes;
            PersonFromEdit.Properties.DataSource = DBHelper.Persons;

            CashToEdit.Properties.DataSource = DBHelper.CashDesks;

            ChargeTypesEdit.Properties.DataSource = DBHelper.ChargeTypes;

            var ent_id = DBHelper.Enterprise.KaId;

            AccountToEdit.Properties.DataSource = _db.EnterpriseAccount.Where(w => w.KaId == ent_id).Select(s => new { s.AccId, s.AccNum, s.BankName }).ToList();

            PersonEdit.Properties.DataSource = DBHelper.Persons;

            if (_PayDocId == null)
            {
                var on_date = DBHelper.ServerDateTime();
                var oper_id = Guid.NewGuid();

                _pd_from = _db.PayDoc.Add(new PayDoc
                {
                    Id        = Guid.NewGuid(),
                    Checked   = 1,
                    DocNum    = new BaseEntities().GetDocNum("salary_out").FirstOrDefault(),
                    OnDate    = on_date,
                    Total     = 0,
                    CTypeId   = 1,                                                                               // За товар
                    WithNDS   = 1,                                                                               // З НДС
                    PTypeId   = 2,                                                                               // Безготівковий
                    CurrId    = DBHelper.Currency.Where(w => w.Def == 1).Select(s => s.CurrId).FirstOrDefault(), //Валюта по умолчанию
                    OnValue   = 1,                                                                               //Курс валюти
                    MPersonId = DBHelper.CurrentUser.KaId,
                    DocType   = 10,                                                                              // Списання зарплати з карточки працівника
                    UpdatedBy = DBHelper.CurrentUser.UserId,
                    EntId     = DBHelper.Enterprise.KaId,
                    OperId    = oper_id,
                    KaId      = _ka_id
                });

                SumEdit.EditValue = _summ_pay == null ? 0 : _summ_pay.Value;
            }
            else
            {
                var pd = _db.PayDoc.AsNoTracking().FirstOrDefault(w => w.PayDocId == _PayDocId);
                if (pd != null)
                {
                    _pd_from = _db.Database.SqlQuery <PayDoc>("SELECT * from PayDoc WITH (UPDLOCK, NOWAIT) where PayDocId = {0}", _PayDocId).FirstOrDefault();
                    _db.Entry <PayDoc>(_pd_from).State = System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    new Exception("Документ не знайдено");
                }

                SumEdit.Value = pd.Total;
            }

            if (_pd_from != null)
            {
                _pd_from.UpdatedBy      = DBHelper.CurrentUser.UserId;
                PayDocFromBS.DataSource = _pd_from;
            }

            TypDocsEdit.Properties.DataSource = DBHelper.DocTypeList.Where(w => new int[] { -1, -6, 2, -16, -8, }.Any(a => a.Equals(w.Id))).ToList();

            if (TypDocsEdit.EditValue == null)
            {
                TypDocsEdit.EditValue = -1;
            }

            var rl = _db.GetRelDocList(_pd_from.Id).FirstOrDefault();

            if (rl != null)
            {
                PayDocCheckEdit.Checked = true;
                TypDocsEdit.EditValue   = rl.DocType;
                GetDocList();
                DocListEdit.EditValue = rl.Id;

                var row = DocListEdit.GetSelectedDataRow() as GetWayBillList_Result;

                textEdit4.EditValue = (row == null ? 0 : row.Balans) - SumEdit.Value;
            }
        }