Пример #1
0
        public void SaveSummaryServices(int iserial, string serviceCode, string serviceName, string notes, bool Checked, double qty)
        {
            using (var entities = new WorkFlowManagerDBEntities())
            {
                if (Checked)
                {
                    var dyeingSummaryServices = entities.DyeingSummaryServices.SingleOrDefault(x => x.SummaryRowIserial == iserial && x.ServiceCode == serviceCode);

                    var summaryServiceNewRow = new DyeingSummaryService();

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