Ejemplo n.º 1
0
        private void WaybillDetInGridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            var dr  = WaybillDetInGridView.GetRow(e.RowHandle) as GetWaybillDetIn_Result;
            var wbd = _db.WaybillDet.Find(dr.PosId);

            wbd.Amount  = Convert.ToDecimal(e.Value);
            wbd.Checked = 1;

            var wmt = _db.WMatTurn.FirstOrDefault(w => w.SourceId == wbd.PosId && w.TurnType == 3);

            if (wmt != null)
            {
                //  if (wb.WType == 16)
                // {
                // удаляем резерв з видаткових документів
                _db.DeleteWhere <WMatTurn>(w => w.PosId == wbd.PosId);
                _db.WMatTurn.Add(new WMatTurn()
                {
                    SourceId = wbd.PosId,
                    PosId    = wbd.PosId,
                    WId      = wbd.WId.Value,
                    MatId    = wbd.MatId,
                    OnDate   = wbd.OnDate.Value,
                    TurnType = 3,
                    Amount   = wbd.Amount
                });
                // }
            }
            _db.SaveChanges();

            IHelper.MapProp(_db.GetWaybillDetIn(_wbill_id).AsNoTracking().FirstOrDefault(w => w.PosId == wbd_row.PosId), wbd_row);

            //    var dd = WayBillsController.GetWaybillDetIn(_db, _wbill_id);
        }
Ejemplo n.º 2
0
        private void EditMaterialBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var row = WaybillDetInGridView.GetFocusedRow() as v_ProductionPlanDet;

            new frmProductionPlanDet(_db, row.Id, pp).ShowDialog();

            RefreshDet();
        }
Ejemplo n.º 3
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var dr = WaybillDetInGridView.GetFocusedRow() as GetWaybillDetIn_Result;

            if (dr != null)
            {
                IHelper.ShowMatRSV(dr.MatId, _db);
            }
        }
Ejemplo n.º 4
0
        private void frmWayBillIn_Load(object sender, EventArgs e)
        {
            WaybillDetInGridView.RestoreLayoutFromRegistry(IHelper.reg_layout_path + "frmWayBillIn\\WaybillDetInGridView");

            if (_wbill_id == null && doc_id == null)
            {
                is_new_record = true;

                wb = _db.WaybillList.Add(new WaybillList()
                {
                    Id        = Guid.NewGuid(),
                    WType     = _wtype,
                    OnDate    = DBHelper.ServerDateTime(),
                    Num       = "",
                    CurrId    = 2,
                    OnValue   = 1,
                    PersonId  = DBHelper.CurrentUser.KaId,
                    Nds       = DBHelper.Enterprise.NdsPayer == 1 ? DBHelper.CommonParam.Nds : 0,
                    UpdatedBy = DBHelper.CurrentUser.UserId,
                    EntId     = DBHelper.Enterprise.KaId,
                });

                _db.SaveChanges();
            }
            else
            {
                wb = _db.WaybillList.FirstOrDefault(f => f.Id == doc_id || f.WbillId == _wbill_id);
            }

            if (wb != null)
            {
                DBHelper.UpdateSessionWaybill(wb.WbillId);

                if (is_new_record) //Після копіювання згенерувати новий номер
                {
                    wb.Num = new BaseEntities().GetDocNum("wb_in").FirstOrDefault();
                }

                WaybillListBS.DataSource = wb;

                GetDocValue(wb);
            }

            KagentComboBox.Properties.DataSource     = DBHelper.Kagents;
            PersonComboBox.Properties.DataSource     = DBHelper.Persons;
            CurrencyLookUpEdit.Properties.DataSource = _db.Currency.ToList();

            var wh_list = DBHelper.WhList;

            WHComboBox.Properties.DataSource = wh_list;
            WHComboBox.EditValue             = wh_list.Where(w => w.Def == 1).Select(s => s.WId).FirstOrDefault();

            RefreshDet();
        }
Ejemplo n.º 5
0
        private void WaybillDetInGridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            var row = WaybillDetInGridView.GetFocusedRow() as v_IntermediateWeighingDet;
            var wbd = _db.IntermediateWeighingDet.Find(row.Id);

            if (e.Column.FieldName == "Amount")
            {
            }

            if (e.Column.FieldName == "Total")
            {
            }

            _db.SaveChanges();
            RefreshDet();
        }
Ejemplo n.º 6
0
        private void DelMaterialBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var row = WaybillDetInGridView.GetFocusedRow() as v_ProductionPlanDet;

            if (row != null)
            {
                var det = _db.ProductionPlanDet.Find(row.Id);
                if (det != null)
                {
                    _db.ProductionPlanDet.Remove(det);
                }
                _db.SaveChanges();
                WaybillDetInGridView.DeleteSelectedRows();
            }
            GetOk();
        }
Ejemplo n.º 7
0
        private void DelMaterialBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (wbd_row != null)
            {
                if (wbd_row.PosId > 0)
                {
                    _db.DeleteWhere <WaybillDet>(w => w.PosId == wbd_row.PosId);
                }
                else
                {
                    _db.DeleteWhere <WayBillSvc>(w => w.PosId == wbd_row.PosId * -1);
                }
                _db.Save(wb.WbillId);

                WaybillDetInGridView.DeleteSelectedRows();
            }
        }
Ejemplo n.º 8
0
        private void frmWayBillIn_FormClosed(object sender, FormClosedEventArgs e)
        {
            WaybillDetInGridView.SaveLayoutToRegistry(IHelper.reg_layout_path + "frmWayBillIn\\WaybillDetInGridView");

            DBHelper.UpdateSessionWaybill(_wbill_id.Value, true);

            if (is_new_record)
            {
                _db.DeleteWhere <WaybillList>(w => w.WbillId == _wbill_id);
                //   current_transaction.Commit();
            }

            /*      if (current_transaction.UnderlyingTransaction.Connection != null)
             *    {
             *        current_transaction.Rollback();
             *    }*/

            _db.Dispose();
            //   current_transaction.Dispose();
        }
Ejemplo n.º 9
0
        private void DelMaterialBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (iw_det_row != null && _db.GetWayBillMakeDet(iw_det_row.WbillId).Any(a => a.MatId == iw_det_row.MatId && a.Rsv == 0))
            {
                var det = _db.IntermediateWeighingDet.Find(iw_det_row.Id);
                if (det != null)
                {
                    _db.IntermediateWeighingDet.Remove(det);
                }
                _db.SaveChanges();

                WaybillDetInGridView.DeleteSelectedRows();
            }
            else
            {
                MessageBox.Show("Видаляти заборонено, сировина вже зарезервована");
            }

            GetOk();
        }
Ejemplo n.º 10
0
        private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (wbd_row.PosType == 0)
            {
                var wbd = _db.WaybillDet.Find(wbd_row.PosId);
                if (wbd != null)
                {
                    if (wbd.Checked == 1)
                    {
                        wbd.Checked     = 0;
                        wbd_row.Checked = 0;
                    }
                    else
                    {
                        wbd.Checked     = 1;
                        wbd_row.Checked = 1;
                    }
                }
            }
            if (wbd_row.PosType == 2)
            {
                var wbt = _db.WayBillTmc.Find(wbd_row.PosId);
                if (wbt != null)
                {
                    if (wbt.Checked == 1)
                    {
                        wbt.Checked     = 0;
                        wbd_row.Checked = 0;
                    }
                    else
                    {
                        wbt.Checked     = 1;
                        wbd_row.Checked = 1;
                    }
                }
            }

            _db.SaveChanges();

            WaybillDetInGridView.RefreshRow(WaybillDetInGridView.FocusedRowHandle);
        }
Ejemplo n.º 11
0
        private void WaybillDetInGridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            var row = WaybillDetInGridView.GetFocusedRow() as v_ProductionPlanDet;
            var wbd = _db.ProductionPlanDet.Find(row.Id);

            if (e.Column.FieldName == "Amount")
            {
                wbd.Amount = Convert.ToDecimal(e.Value);
                var real_amount = wbd.Amount.Value - wbd.Remain.Value;
                var tmp_amount  = (real_amount / (row.ResipeOut == 0 ? 100.00m : row.ResipeOut)) * 100; // real_amount + (real_amount - (real_amount * row.ResipeOut / 100));
                wbd.Total = Math.Ceiling(tmp_amount / row.RecipeAmount) * row.RecipeAmount;
            }

            if (e.Column.FieldName == "Total")
            {
                wbd.Total = Convert.ToDecimal(e.Value);
            }

            _db.SaveChanges();
            RefreshDet();
        }
Ejemplo n.º 12
0
        private void EditMaterialBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var dr = WaybillDetInGridView.GetRow(WaybillDetInGridView.FocusedRowHandle) as GetWaybillDetIn_Result;

            if (dr != null)
            {
                if (dr.PosId > 0)
                {
                    using (var wb_det = new frmWayBillDetIn(_db, dr.PosId, wb))
                    {
                        wb_det.ShowDialog();
                    }
                }
                else
                {
                    using (var svc_det = new frmWaybillSvcDet(_db, dr.PosId * -1, wb))
                    {
                        svc_det.ShowDialog();
                    }
                }

                RefreshDet();
            }
        }
Ejemplo n.º 13
0
 private void WaybillDetInGridView_FocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
 {
     wbd_row = WaybillDetInGridView.GetRow(WaybillDetInGridView.FocusedRowHandle) as GetWaybillDetIn_Result;
 }