private void frmMoneyMove_Load(object sender, EventArgs e) { PTypeComboBox.Properties.DataSource = DBHelper.PayTypes; CashEditComboBox.Properties.DataSource = DBHelper.CashDesks; PersonEdit.Properties.DataSource = DBHelper.Persons; var ent_id = DBHelper.Enterprise.KaId; AccountEdit.Properties.DataSource = _db.EnterpriseAccount.Where(w => w.KaId == ent_id).Select(s => new { s.AccId, s.AccNum, s.BankName }).ToList(); if (_PayDocId == null) { _pd = _db.PayDoc.Add(new PayDoc { Id = Guid.NewGuid(), Checked = 1, DocNum = new BaseEntities().GetDocNum("pay_doc").FirstOrDefault(), OnDate = DBHelper.ServerDateTime(), Total = 0, CTypeId = 1, // За товар 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 = 6, //Коригування залишку UpdatedBy = DBHelper.CurrentUser.UserId, EntId = DBHelper.Enterprise.KaId, OperId = Guid.NewGuid() }); } 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(); } } if (_pd != null) { _pd.UpdatedBy = DBHelper.CurrentUser.UserId; if (_pd.Total < 0) { SumEdit.Value = _pd.Total * -1; SumTypeEdit.SelectedIndex = 1; } else { SumEdit.Value = _pd.Total; } PayDocBS.DataSource = _pd; } }
private void frmMoneyMove_Load(object sender, EventArgs e) { PTypeFromEdit.Properties.DataSource = DBHelper.PayTypes; PersonToEdit.Properties.DataSource = DBHelper.Persons; CashFromEdit.Properties.DataSource = DBHelper.CashDesks; ChargeTypesEdit.Properties.DataSource = DBHelper.ChargeTypes; var ent_id = DBHelper.Enterprise.KaId; AccountFromEdit.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("pay_doc").FirstOrDefault(), * OnDate = on_date, * Total = 0, * CTypeId = 1,// За товар * 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 = -3, //Списання коштів з каси * UpdatedBy = DBHelper.CurrentUser.UserId, * EntId = DBHelper.Enterprise.KaId, * OperId = oper_id * });*/ _pd_to = _db.PayDoc.Add(new PayDoc { Id = Guid.NewGuid(), Checked = 1, DocNum = new BaseEntities().GetDocNum("salary_in").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 }); } else { try { _pd_to = _db.Database.SqlQuery <PayDoc>("SELECT * from PayDoc WITH (UPDLOCK, NOWAIT) where PayDocId = {0}", _PayDocId).FirstOrDefault(); _db.Entry <PayDoc>(_pd_to).State = System.Data.Entity.EntityState.Modified; /* _pd_from = _db.Database.SqlQuery<PayDoc>("SELECT * from PayDoc WITH (UPDLOCK, NOWAIT) where OperId = {0} and DocType = -3 ", _pd_to.OperId).FirstOrDefault(); * _db.Entry<PayDoc>(_pd_from).State = System.Data.Entity.EntityState.Modified;*/ } catch { Close(); } } /* if (_pd_from != null) * { * _pd_from.UpdatedBy = DBHelper.CurrentUser.UserId; * * SumEdit.Value = _pd_from.Total; * * PayDocFromBS.DataSource = _pd_from; * }*/ if (_pd_to != null) { _pd_to.UpdatedBy = DBHelper.CurrentUser.UserId; PayDocToBS.DataSource = _pd_to; } }
private void frmMoneyMove_Load(object sender, EventArgs e) { PTypeFromEdit.Properties.DataSource = DBHelper.PayTypes; PTypeToEdit.Properties.DataSource = DBHelper.PayTypes; CashFromEdit.Properties.DataSource = DBHelper.CashDesks; CashToEdit.Properties.DataSource = DBHelper.CashDesks; var ent_id = DBHelper.Enterprise.KaId; AccountFromEdit.Properties.DataSource = _db.EnterpriseAccount.Where(w => w.KaId == ent_id).Select(s => new { s.AccId, s.AccNum, s.BankName }).ToList(); AccountToEdit.Properties.DataSource = AccountFromEdit.Properties.DataSource; PersonEdit.Properties.DataSource = DBHelper.Persons; if (_PayDocId == null) { var doc_num = new BaseEntities().GetDocNum("pay_doc").FirstOrDefault(); var on_date = DBHelper.ServerDateTime(); var oper_id = Guid.NewGuid(); _pd_from = _db.PayDoc.Add(new PayDoc { Id = Guid.NewGuid(), Checked = 1, DocNum = doc_num, OnDate = on_date, Total = 0, CTypeId = 1, // За товар 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 = -3, UpdatedBy = DBHelper.CurrentUser.UserId, EntId = DBHelper.Enterprise.KaId, OperId = oper_id }); _pd_to = _db.PayDoc.Add(new PayDoc { Id = Guid.NewGuid(), Checked = 1, DocNum = doc_num, OnDate = on_date, Total = 0, CTypeId = 1, // За товар 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 = 3, UpdatedBy = DBHelper.CurrentUser.UserId, EntId = DBHelper.Enterprise.KaId, OperId = oper_id }); } else { try { _pd_to = _db.Database.SqlQuery <PayDoc>("SELECT * from PayDoc WITH (UPDLOCK, NOWAIT) where PayDocId = {0}", _PayDocId).FirstOrDefault(); _db.Entry <PayDoc>(_pd_to).State = System.Data.Entity.EntityState.Modified; _pd_from = _db.Database.SqlQuery <PayDoc>("SELECT * from PayDoc WITH (UPDLOCK, NOWAIT) where OperId = {0} and DocType = -3 ", _pd_to.OperId).FirstOrDefault(); _db.Entry <PayDoc>(_pd_from).State = System.Data.Entity.EntityState.Modified; } catch { Close(); } } if (_pd_from != null) { _pd_from.UpdatedBy = DBHelper.CurrentUser.UserId; SumEdit.Value = _pd_from.Total; PayDocFromBS.DataSource = _pd_from; } if (_pd_to != null) { _pd_to.UpdatedBy = DBHelper.CurrentUser.UserId; PayDocToBS.DataSource = _pd_to; } }