示例#1
0
        public void SaveDyeingOrderDetailsServices(int iserial, string serviceCode, string serviceName, string notes, bool Checked, double qty)
        {
            using (var entities = new WorkFlowManagerDBEntities())
            {
                if (Checked)
                {
                    var dyeingSummaryServices = entities.DyeingOrderDetailsServices.SingleOrDefault(x => x.DyeingOrdersDetailsInt == iserial && x.ServiceCode == serviceCode);

                    var summaryServiceNewRow = new DyeingOrderDetailsService();

                    if (dyeingSummaryServices == null)
                    {
                        summaryServiceNewRow.ServiceCode            = serviceCode;
                        summaryServiceNewRow.ServiceName            = serviceName;
                        summaryServiceNewRow.DyeingOrdersDetailsInt = iserial;
                        summaryServiceNewRow.Notes = notes;
                        summaryServiceNewRow.Qty   = qty;
                        entities.AddToDyeingOrderDetailsServices(summaryServiceNewRow);
                    }
                    else
                    {
                        summaryServiceNewRow.Notes = notes;
                        summaryServiceNewRow.Qty   = qty;
                    }
                }
                else
                {
                    var dyeingSummaryServices = entities.DyeingOrderDetailsServices.SingleOrDefault(x => x.DyeingOrdersDetailsInt == iserial && x.ServiceCode == serviceCode);
                    if (dyeingSummaryServices != null)
                    {
                        entities.DeleteObject(dyeingSummaryServices);
                    }
                }
                entities.SaveChanges();
            }
        }