Пример #1
0
        public void Update(DemandMasterModel model)
        {
            EHMSEntities ent = new EHMSEntities();
            var          obj = ent.ItemDemandMasters.Where(x => x.ItemDemandID == model.ItemDemandID).SingleOrDefault();

            model.CreatedBy   = obj.CreatedBy;
            model.CreatedDate = obj.CreatedDate;
            model.Status      = obj.Status;
            AutoMapper.Mapper.Map(model, obj);
            ent.Entry(obj).State = System.Data.EntityState.Modified;
            foreach (var item in ent.ItemDemandDetails.Where(x => x.ItemDemandID == obj.ItemDemandID && x.DispatchStatus == false).ToList())
            {
                ent.ItemDemandDetails.Remove(item);
            }
            foreach (var item in model.StockItemEntryList)
            {
                ItemDemandDetail demandDetail = new ItemDemandDetail();
                demandDetail.ItemDemandID   = obj.ItemDemandID;
                demandDetail.ItemID         = item.StockItemEntryId;
                demandDetail.QuantityDemand = item.Quantity;
                demandDetail.DispatchStatus = false;
                demandDetail.Remarks        = "";
                ent.ItemDemandDetails.Add(demandDetail);
            }
            ent.SaveChanges();
        }
Пример #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (validationResult() == true)
     {
         if (_itemDemandDetailId > 0)
         {
             var data = dbContext.ItemDemandDetail.SingleOrDefault(x => x.ID == _itemDemandDetailId);
             data.ITEMDEMANDDETAIL_QUANTITY = Convert.ToDouble(txtQuantity.Text);
             var projectExploreQuantity       = dbContext.ProjectExplore.Find(data.ITEMDEMANDDETAIL_ITEM_ID).PROJECTEXPLORE_ITEMQUANTITY;
             var itemDemandMasterConfirmation = dbContext.ItemDemandMaster.SingleOrDefault(x => x.ID == _itemDemandMasterId).ITEMDEMANDMASTER_ITEMCONFIRMATION;
             if (Convert.ToDouble(txtQuantity.Text) > projectExploreQuantity)
             {
                 data.ITEMDEMANDDETAIL_ITEM_CONFIRMATION = true;
                 itemDemandMasterConfirmation            = true;
                 XtraMessageBox.Show("Talep Edilen Miktar Keşif Miktarından Büyük Olduğu İçin Koordinator Onay Vermesini Bekleyiniz.!", "UYARI!", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 data.ITEMDEMANDDETAIL_ITEM_CONFIRMATION = false;
                 itemDemandMasterConfirmation            = false;
             }
             data.ITEMDEMANDDETAIL_ITEM_ID = (int)lueItem.EditValue;
         }
         else
         {
             ItemDemandDetail itemDemandDetail = new ItemDemandDetail();
             itemDemandDetail.ITEMDEMANDDETAIL_QUANTITY  = Convert.ToDouble(txtQuantity.Text);
             itemDemandDetail.ITEMDEMANDDETAIL_ITEM_ID   = (int)lueItem.EditValue;
             itemDemandDetail.ITEMDEMANDDETAIL_MASTER_ID = _itemDemandMasterId;
             dbContext.ItemDemandDetail.Add(itemDemandDetail);
             dbContext.SaveChanges();
             var projectExploreQuantity       = dbContext.ProjectExplore.SingleOrDefault(x => x.PROJECTEXPLORE_ITEM_ID == itemDemandDetail.ITEMDEMANDDETAIL_ITEM_ID).PROJECTEXPLORE_ITEMQUANTITY;
             var itemDemandMasterConfirmation = dbContext.ItemDemandMaster.SingleOrDefault(x => x.ID == _itemDemandMasterId);
             if (Convert.ToDouble(txtQuantity.Text) > projectExploreQuantity)
             {
                 itemDemandDetail.ITEMDEMANDDETAIL_ITEM_CONFIRMATION            = true;
                 itemDemandMasterConfirmation.ITEMDEMANDMASTER_ITEMCONFIRMATION = true;
                 XtraMessageBox.Show("Talep Edilen Miktar Keşif Miktarından Büyük Olduğu İçin Koordinator Onay Vermesini Bekleyiniz.!", "UYARI!", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 itemDemandDetail.ITEMDEMANDDETAIL_ITEM_CONFIRMATION            = false;
                 itemDemandMasterConfirmation.ITEMDEMANDMASTER_ITEMCONFIRMATION = true;
             }
         }
         txtQuantity.EditValue = "";
         lueItem.EditValue     = null;
         _itemDemandDetailId   = 0;
         dbContext.SaveChanges();
         LoadData();
     }
 }
        public void Insert(DemandMasterModel model)
        {
            EHMSEntities ent       = new EHMSEntities();
            var          objToSave = AutoMapper.Mapper.Map <DemandMasterModel, ItemDemandMaster>(model);

            objToSave.CreatedBy    = 1;
            objToSave.CreatedDate  = DateTime.Now;
            objToSave.Status       = true;
            objToSave.DepartmentID = 1;
            ent.ItemDemandMasters.Add(objToSave);
            ent.SaveChanges();
            foreach (var item in model.StockItemEntryList)
            {
                ItemDemandDetail demandDetail = new ItemDemandDetail();
                demandDetail.ItemDemandID   = ent.ItemDemandMasters.OrderByDescending(x => x.ItemDemandID).FirstOrDefault().ItemDemandID;
                demandDetail.ItemID         = item.StockItemEntryId;
                demandDetail.QuantityDemand = item.Quantity;
                demandDetail.DispatchStatus = false;
                demandDetail.Remarks        = "";
                ent.ItemDemandDetails.Add(demandDetail);
            }
            ent.SaveChanges();
        }
Пример #4
0
        public void Insert(DemandMasterModel model)
        {
            EHMSEntities ent       = new EHMSEntities();
            var          objToSave = AutoMapper.Mapper.Map <DemandMasterModel, ItemDemandMaster>(model);

            objToSave.CreatedBy    = 1;
            objToSave.CreatedDate  = DateTime.Now;
            objToSave.Status       = true;
            objToSave.DepartmentID = HospitalManagementSystem.Utility.GetCurrentUserDepartmentId();
            ent.ItemDemandMasters.Add(objToSave);
            ent.SaveChanges();
            foreach (var item in model.StockItemEntryList)
            {
                ItemDemandDetail demandDetail = new ItemDemandDetail();
                demandDetail.ItemDemandID   = objToSave.ItemDemandID;
                demandDetail.ItemID         = item.StockItemEntryId;
                demandDetail.QuantityDemand = item.Quantity;
                demandDetail.DispatchStatus = false;
                demandDetail.Remarks        = "";
                ent.ItemDemandDetails.Add(demandDetail);
            }
            ent.SaveChanges();
        }