Ejemplo n.º 1
0
        private void getDataFromGrid()
        {
            Log.UCTechReception.Debug("getDataFromGrid()");

            VisualisationPret currentPret = new VisualisationPret();

            currentPret.Photo = dateTimePicker1.Text;
            List <VisualisationProduct> plist = new List <VisualisationProduct>();

            foreach (GridViewRowInfo row in radGridView1.Rows)
            {
                VisualisationProduct p = new VisualisationProduct();
                foreach (GridViewCellInfo cellInfo in row.Cells)
                {
                    if (cellInfo.Value == null)
                    {
                        cellInfo.Value = "";
                    }
                    switch (cellInfo.ColumnInfo.Name)
                    {
                    case "Produit":
                        p.Name = cellInfo.Value.ToString();
                        break;

                    case "SN":
                        p.Sn = cellInfo.Value.ToString();
                        break;

                    case "CommentaireP":
                        p.Com = cellInfo.Value.ToString();
                        break;

                    default:
                        break;
                    }
                }
                // data from Child Rows
                GridViewHierarchyRowInfo hierarchyRow = row as GridViewHierarchyRowInfo;
                if (hierarchyRow != null)
                {
                    GridViewInfo currentView = hierarchyRow.ActiveView;
                    foreach (GridViewInfo view in hierarchyRow.Views)
                    {
                        hierarchyRow.ActiveView = view;
                        List <VisualitationAccesories> alist = new List <VisualitationAccesories>();
                        foreach (GridViewRowInfo crow in view.ChildRows)
                        {
                            VisualitationAccesories a = new VisualitationAccesories();
                            foreach (GridViewCellInfo ccellInfo in crow.Cells)
                            {
                                if (ccellInfo.Value == null)
                                {
                                    ccellInfo.Value = "";
                                }
                                switch (ccellInfo.ColumnInfo.Name)
                                {
                                case "Accessoire":
                                    a.Name = ccellInfo.Value.ToString();
                                    break;

                                case "PN":
                                    a.Pn = ccellInfo.Value.ToString();
                                    break;

                                case "CommentaireA":
                                    a.Com = ccellInfo.Value.ToString();
                                    break;

                                default:
                                    break;
                                }
                            }
                            alist.Add(a);
                        }
                        p.listAccessories       = alist;
                        hierarchyRow.ActiveView = currentView;
                    }
                }
                plist.Add(p);
            }
            List <string> l_Photo = new List <string>();

            foreach (RadListDataItem item in radListControl1.Items)
            {
                l_Photo.Add(item.ToString());
            }
            currentPret.l_Photo      = l_Photo;
            currentPret.listProducts = plist;
            detail.Add(currentPret);
        }
Ejemplo n.º 2
0
        private int populateDb()
        {
            Log.UCTechReception.Debug("populateDb()");

            int idLoan = 0;

            // creating a loan associated with product, accessories, doc
            try
            {
                // using elementAt(0) because the list is empty after creating another one
                VisualisationPret loan = detail.ElementAt(0);
                LOAN newLoan           = new LOAN
                {
                    LOA_USER_ID_FK = UserManager.currentUser.Id,
                    LOA_PROVIDER   = radDropDownListProvider.Text,
                    LOA_COMM_G     = tBoxObservation.Text,
                    LOA_DATE       = dateTimePicker1.Value,
                    LOA_STATE      = 0
                };
                VpretContext.Instance.vPretContext.LOAN.InsertOnSubmit(newLoan);
                VpretContext.Instance.vPretContext.SubmitChanges();
                idLoan = newLoan.LOA_ID;
                foreach (string item in loan.l_Photo)
                {
                    DOCUMENT photo = new DOCUMENT
                    {
                        DOC_LOA_ID_FK = idLoan,
                        DOC_NAME      = item.ToString(),
                    };
                    VpretContext.Instance.vPretContext.DOCUMENT.InsertOnSubmit(photo);
                    VpretContext.Instance.vPretContext.SubmitChanges();
                }
                foreach (VisualisationProduct product in loan.listProducts)
                {
                    PRODUCT newProduct = new PRODUCT
                    {
                        PRO_LOA_ID_FK = idLoan,
                        PRO_SN        = product.Sn,
                        PRO_NAME      = product.Name,
                        PRO_COM       = product.Com,
                        PRO_STATE     = 0
                    };
                    VpretContext.Instance.vPretContext.PRODUCT.InsertOnSubmit(newProduct);
                    VpretContext.Instance.vPretContext.SubmitChanges();
                    foreach (VisualitationAccesories accessorie in product.listAccessories)
                    {
                        ACCESSORIES naccessorie = new ACCESSORIES
                        {
                            ACC_LOA_ID_FK = idLoan,
                            ACC_PRO_ID_FK = newProduct.PRO_ID,
                            ACC_NAME      = accessorie.Name,
                            ACC_PN        = accessorie.Pn,
                            ACC_COM       = accessorie.Com,
                            ACC_STATE     = 0
                        };
                        VpretContext.Instance.vPretContext.ACCESSORIES.InsertOnSubmit(naccessorie);
                        VpretContext.Instance.vPretContext.SubmitChanges();
                    }
                }
            }
            catch (Exception e)
            {
                Log.UCTechReception.Error("Population failed with exception: " + e.ToString());
            }
            finally
            {
                Log.UCTechReception.Debug("Population completed.");
            }
            return(idLoan);
        }