Ejemplo n.º 1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            bool isSucceed = false;

            try
            {
                switch (Actions)
                {
                case WebAction.Add:
                    isSucceed = SubmintAdd();
                    break;

                case WebAction.Edit:
                    isSucceed = SubmintEdit();
                    break;
                }

                tmsModel t = new tmsModel();
                try
                {
                    IQueryable <LHDispatchCenter> center = DispatchCenterService.Where(p => p.KeyId == lblKeyId.Text);
                    if (center.Count() > 0)
                    {
                        t.dispatchCenterList = center.ToList();
                    }
                    IQueryable <LHStockOut> iP = new StockOutService().Where(p => p.FDispatchNum == lblKeyId.Text);
                    t.stockOutList        = iP.ToList <LHStockOut>();
                    t.stockOutDetailsList = new List <LHStockOutDetails>();
                    foreach (LHStockOut item in iP)
                    {
                        IQueryable <LHStockOutDetails> li = new StockOutDetailsService().Where(p => p.KeyId == item.KeyId);
                        foreach (LHStockOutDetails outDetails in li)
                        {
                            t.stockOutDetailsList.Add(outDetails);
                        }
                    }
                    IQueryable <LHPassCard> lHPasses = PassCardService.Where(p => p.FDispatchNum == lblKeyId.Text);
                    if (lHPasses != null)
                    {
                        t.passCardList = lHPasses.ToList();
                    }

                    t.passCardDetailsList = new List <LHPassCardDetails>();
                    foreach (LHPassCard item in t.passCardList)
                    {
                        IQueryable <LHPassCardDetails> cardDetails = new PassCardDetailsService().Where(p => p.KeyId == item.KeyId);
                        foreach (LHPassCardDetails details in cardDetails)
                        {
                            t.passCardDetailsList.Add(details);
                        }
                    }

                    IQueryable <LHStockIn> skin = new StockInService().Where(p => p.FDispatchNum == lblKeyId.Text);
                    if (skin != null && skin.Count() > 0)
                    {
                        t.stockInList        = skin.ToList();
                        t.stockInDetailsList = new List <LHStockInDetails>();
                        foreach (LHStockIn item in skin)
                        {
                            IQueryable <LHStockInDetails> inDetails = new StockInDetailsService().Where(p => p.KeyId == item.KeyId);
                            foreach (LHStockInDetails inDetail in inDetails)
                            {
                                t.stockInDetailsList.Add(inDetail);
                            }
                        }
                    }
                    new HttpRequest().httpRequest(t, "open/dbo/dboData");
                }
                catch (Exception)
                {
                }
            }
            catch (DbEntityValidationException ex)
            {
                string msg = string.Empty;
                List <ICollection <DbValidationError> > errors = (from u in ex.EntityValidationErrors select u.ValidationErrors).ToList();
                foreach (ICollection <DbValidationError> item in errors)
                {
                    msg += item.FirstOrDefault().ErrorMessage;
                }
                isSucceed = false;
            }
            finally
            {
                if (isSucceed)
                {
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    Alert.Show("提交失败!", MessageBoxIcon.Error);
                }
            }
        }