Пример #1
0
        public int?Save(tblPrescription tblins, List <EntityPrescriptionDetails> lst)
        {
            int?PrescriptionId = 0;

            try
            {
                objData.STP_Insert_tblPrescription(Convert.ToInt32(tblins.AdmitId), Convert.ToInt32(tblins.DeptCategory), tblins.DeptDoctor, Convert.ToDateTime(tblins.Prescription_Date),
                                                   tblins.IsDressing, tblins.IsInjection, tblins.InjectionName, tblins.Investigation, tblins.Impression, tblins.AdviceNote, tblins.Remarks, ref PrescriptionId);
                foreach (EntityPrescriptionDetails item in lst)
                {
                    tblPrescriptionDetail tbl = new tblPrescriptionDetail()
                    {
                        ProductId       = Convert.ToInt32(item.ProductId),
                        Morning         = item.Morning,
                        Afternoon       = item.Afternoon,
                        Night           = item.Night,
                        NoOfDays        = item.NoOfDays,
                        Quantity        = item.Quantity,
                        Prescription_Id = Convert.ToInt32(PrescriptionId),
                        IsDelete        = false
                    };
                    objData.tblPrescriptionDetails.InsertOnSubmit(tbl);
                    tblStockDetail stock = new tblStockDetail()
                    {
                        ProductId       = Convert.ToInt32(item.ProductId),
                        OpeningQty      = 0,
                        InwardQty       = 0,
                        InwardPrice     = 0,
                        InwardAmount    = 0,
                        OutwardQty      = Convert.ToInt32(item.Quantity),
                        TransactionType = "Issue",
                        DocumentNo      = PrescriptionId,
                    };
                    objData.tblStockDetails.InsertOnSubmit(stock);
                }
                objData.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(PrescriptionId);
        }
Пример #2
0
 public void Update(List <EntityPrescriptionDetails> lst)
 {
     try
     {
         foreach (EntityPrescriptionDetails item in lst)
         {
             tblPrescriptionDetail objsal = new tblPrescriptionDetail();
             objsal = (from tbl in objData.tblPrescriptionDetails
                       where tbl.PrescriptionDetailId == item.PrescriptionDetailId &&
                       tbl.IsDelete == false
                       select tbl).FirstOrDefault();
             if (objsal != null)
             {
                 objsal.ProductId = item.ProductId;
                 objsal.Quantity  = item.Quantity;
                 objsal.Morning   = item.Morning;
                 objsal.Afternoon = item.Afternoon;
                 objsal.Night     = item.Night;
                 objsal.NoOfDays  = item.NoOfDays;
                 objsal.IsDelete  = item.IsDelete;
             }
             else
             {
                 objsal = new tblPrescriptionDetail()
                 {
                     ProductId = Convert.ToInt32(item.ProductId), Quantity = item.Quantity, Morning = item.Morning, Afternoon = item.Afternoon, Night = item.Night, NoOfDays = item.NoOfDays, Prescription_Id = Convert.ToInt32(item.Prescription_Id)
                 };
                 objData.tblPrescriptionDetails.InsertOnSubmit(objsal);
             }
         }
         objData.SubmitChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #3
0
        public void Update(tblPrescription obj, List <EntityPrescriptionDetails> lst)
        {
            try
            {
                tblPrescription objcurrent = (from tbl in objData.tblPrescriptions
                                              where tbl.Prescription_Id == obj.Prescription_Id
                                              select tbl).FirstOrDefault();
                if (objcurrent != null)
                {
                    objcurrent.AdmitId           = obj.AdmitId;
                    objcurrent.DeptCategory      = obj.DeptCategory;
                    objcurrent.DeptDoctor        = obj.DeptDoctor;
                    objcurrent.Prescription_Date = obj.Prescription_Date;
                    objcurrent.InjectionName     = obj.InjectionName;
                    objcurrent.IsDressing        = obj.IsDressing;
                    objcurrent.IsInjection       = obj.IsInjection;
                    objcurrent.Investigation     = obj.Investigation;
                    objcurrent.Impression        = obj.Impression;
                    objcurrent.AdviceNote        = obj.AdviceNote;
                    objcurrent.Remarks           = obj.Remarks;
                }

                foreach (EntityPrescriptionDetails item in lst)
                {
                    tblPrescriptionDetail objsal = new tblPrescriptionDetail();
                    objsal = (from tbl in objData.tblPrescriptionDetails
                              where tbl.PrescriptionDetailId == item.PrescriptionDetailId &&
                              tbl.Prescription_Id == item.Prescription_Id && tbl.ProductId == item.ProductId &&
                              tbl.IsDelete == false
                              select tbl).FirstOrDefault();
                    if (objsal != null)
                    {
                        objsal.ProductId = Convert.ToInt32(item.ProductId);
                        objsal.Morning   = item.Morning;
                        objsal.Afternoon = item.Afternoon;
                        objsal.Night     = item.Night;
                        objsal.NoOfDays  = item.NoOfDays;
                        objsal.Quantity  = item.Quantity;
                        objsal.IsDelete  = item.IsDelete;
                    }
                    else
                    {
                        objsal = new tblPrescriptionDetail()
                        {
                            ProductId       = item.ProductId,
                            Morning         = item.Morning,
                            Afternoon       = item.Afternoon,
                            Night           = item.Night,
                            NoOfDays        = item.NoOfDays,
                            Quantity        = item.Quantity,
                            Prescription_Id = Convert.ToInt32(obj.Prescription_Id),
                            IsDelete        = false
                        };
                        objData.tblPrescriptionDetails.InsertOnSubmit(objsal);
                    }

                    tblStockDetail stock = (from tbl in objData.tblStockDetails
                                            where tbl.IsDelete == false &&
                                            tbl.DocumentNo == item.Prescription_Id &&
                                            tbl.ProductId == item.ProductId &&
                                            tbl.TransactionType.Equals("Issue")
                                            select tbl).FirstOrDefault();
                    if (stock != null)
                    {
                        stock.ProductId    = Convert.ToInt32(item.ProductId);
                        stock.OpeningQty   = 0;
                        stock.InwardQty    = 0;
                        stock.InwardPrice  = 0;
                        stock.InwardAmount = 0;
                        stock.OutwardQty   = Convert.ToInt32(item.Quantity);
                        stock.IsDelete     = item.IsDelete;
                    }
                    else
                    {
                        tblStockDetail stock1 = new tblStockDetail()
                        {
                            ProductId       = Convert.ToInt32(item.ProductId),
                            OpeningQty      = 0,
                            InwardQty       = 0,
                            InwardPrice     = 0,
                            InwardAmount    = 0,
                            OutwardQty      = Convert.ToInt32(item.Quantity),
                            TransactionType = "Issue",
                            IsDelete        = false,
                        };
                        objData.tblStockDetails.InsertOnSubmit(stock1);
                    }
                }
                objData.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }