private void MatComboBox_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
 {
     if (e.Button.Index == 1 && mat_list.Any())
     {
         using (var f = new frmIntermediateWeighingList(mat_list))
         {
             if (f.ShowDialog() == DialogResult.OK)
             {
                 MatComboBox.EditValue = f.focused_row != null ? f.focused_row.MatId : MatComboBox.EditValue;
                 AmountEdit.Focus();
             }
         }
     }
     else
     {
         MessageBox.Show("Сировина для зважування відсутня");
     }
 }
Ejemplo n.º 2
0
        private void barButtonItem8_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var mat_list = DB.SkladBase().GetWayBillMakeDet(focused_row.WbillId).OrderBy(o => o.Num).ToList().Select(s => new make_det
            {
                MatName                    = s.MatName,
                MsrName                    = s.MsrName,
                AmountByRecipe             = s.AmountByRecipe,
                AmountIntermediateWeighing = s.AmountIntermediateWeighing,
                MatId   = s.MatId,
                WbillId = focused_row.WbillId,
                //      RecipeCount = wbm.RecipeCount,
                IntermediateWeighingCount = DB.SkladBase().v_IntermediateWeighingDet.Where(w => w.WbillId == focused_row.WbillId && w.MatId == s.MatId).Count(),
                //      TotalWeightByRecipe = wbm.AmountByRecipe
            }).ToList();

            using (var f = new frmIntermediateWeighingList(mat_list))
            {
                if (f.ShowDialog() == DialogResult.OK)
                {
                    ;
                }
            }
        }
        private void frmPlannedCalculationDetDet_Load(object sender, EventArgs e)
        {
            det = _db.IntermediateWeighingDet.Find(_id);

            if (det == null)
            {
                det = new IntermediateWeighingDet
                {
                    Id     = Guid.NewGuid(),
                    Amount = 0,
                    IntermediateWeighingId = _iw.Id,
                    CreatedDate            = DBHelper.ServerDateTime(),
                    TaraAmount             = 0
                };

                isNewRecord = true;
            }


            var wh_list = DB.SkladBase().UserAccessWh.Where(w => w.UserId == DBHelper.CurrentUser.UserId).Select(s => s.WId).ToList();
            var wbm     = _db.WayBillMake.FirstOrDefault(w => w.WbillId == _iw.WbillId);

            mat_list = DB.SkladBase().GetWayBillMakeDet(_iw.WbillId).Where(w => wh_list.Contains(w.MatDefWId.Value) && w.Rsv == 0).OrderBy(o => o.Num).ToList().Select(s => new make_det
            {
                MatName                    = s.MatName,
                MsrName                    = s.MsrName,
                AmountByRecipe             = s.AmountByRecipe,
                AmountIntermediateWeighing = _db.v_IntermediateWeighingDet.Where(w => w.WbillId == _iw.WbillId && w.MatId == s.MatId && w.Id != det.Id).Sum(st => st.Total),
                MatId       = s.MatId,
                WbillId     = _iw.WbillId,
                RecipeCount = wbm.RecipeCount,
                IntermediateWeighingCount = _db.v_IntermediateWeighingDet.Where(w => w.WbillId == _iw.WbillId && w.MatId == s.MatId && w.Id != det.Id).Count(),
                TotalWeightByRecipe       = wbm.AmountByRecipe,
                RecId = wbm.RecId
            }).ToList();

            if (isNewRecord)
            {
                if (mat_list.Any())
                {
                    using (var f = new frmIntermediateWeighingList(mat_list))
                    {
                        if (f.ShowDialog() == DialogResult.OK)
                        {
                            det.MatId = f.focused_row != null ? f.focused_row.MatId : det.MatId;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Сировина для зважування відсутня");
                }
            }


            MatComboBox.Properties.DataSource = mat_list;

            IntermediateWeighingDetBS.DataSource = det;

            TareMatEdit.Properties.DataSource = _db.Tara.Where(w => w.TypeId == 5).Select(s => new { MatId = s.TaraId, s.Name, s.Artikul, s.Weight }).ToList();


            GetOk();
        }