示例#1
0
        private void CombinA2(ref ListView oList, string a1)
        {
            Guid id = Guid.Empty;

            if (Guid.TryParse(cboAppendix2.SelectedValue.ToString(), out id))
            {
                var detailList = ProductDim_DetailsEx.GetListByDimensionId(id);
                foreach (var detail in detailList)
                {
                    if (!string.IsNullOrEmpty(detail.APPENDIX2))
                    {
                        CombinA3(ref oList, a1, detail.APPENDIX2);
                    }
                }
            }
        }
示例#2
0
        private void CombinA3(ref ListView oList, string a1, string a2)
        {
            Guid id = Guid.Empty;

            if (Guid.TryParse(cboAppendix3.SelectedValue.ToString(), out id))
            {
                var detailList = ProductDim_DetailsEx.GetListByDimensionId(id);
                foreach (var detail in detailList)
                {
                    if (!string.IsNullOrEmpty(detail.APPENDIX3))
                    {
                        AddToList(ref oList, a1, a2, detail.APPENDIX3);
                    }
                }

                if (detailList.Count == 0)
                {
                    AddToList(ref oList, a1, a2, string.Empty);
                }
            }
        }
示例#3
0
        private void InitialFormWithType()
        {
            var detailList = ProductDim_DetailsEx.GetListByDimensionId(this.CombinId);

            foreach (var detail in detailList)
            {
                if (detail.APPENDIX1.Length > 0 && detail.APPENDIX2.Length == 0 && detail.APPENDIX3.Length == 0)
                {
                    this.AppendixType = ProductHelper.Appendix.Appendix1;
                }
                else if (detail.APPENDIX1.Length == 0 && detail.APPENDIX2.Length > 0 && detail.APPENDIX3.Length == 0)
                {
                    this.AppendixType = ProductHelper.Appendix.Appendix2;
                }
                else if (detail.APPENDIX1.Length == 0 && detail.APPENDIX2.Length == 0 && detail.APPENDIX3.Length > 0)
                {
                    this.AppendixType = ProductHelper.Appendix.Appendix3;
                }
                else
                {
                    this.AppendixType = ProductHelper.Appendix.None;
                }
            }
        }
示例#4
0
        private void Save()
        {
            using (var ctx = new EF6.RT2020Entities())
            {
                using (var scope = ctx.Database.BeginTransaction())
                {
                    try
                    {
                        var oDim = ctx.ProductDim.Find(this.CombinId);
                        if (oDim == null)
                        {
                            #region new ProductDim
                            oDim             = new EF6.ProductDim();
                            oDim.DimensionId = Guid.NewGuid();
                            oDim.DimCode     = txtCombinNumber.Text;

                            switch (this.AppendixType)
                            {
                            case ProductHelper.Appendix.Appendix1:
                                oDim.DimType = "A1";
                                break;

                            case ProductHelper.Appendix.Appendix2:
                                oDim.DimType = "A2";
                                break;

                            case ProductHelper.Appendix.Appendix3:
                                oDim.DimType = "A3";
                                break;

                            case ProductHelper.Appendix.None:
                            default:
                                oDim.DimType = "";
                                break;
                            }

                            oDim.CreatedBy = ConfigHelper.CurrentUserId;
                            oDim.CreatedOn = DateTime.Now;

                            ctx.ProductDim.Add(oDim);
                            #endregion
                        }
                        oDim.ModifiedBy = ConfigHelper.CurrentUserId;
                        oDim.ModifiedOn = DateTime.Now;

                        ctx.SaveChanges();
                        this.CombinId = oDim.DimensionId;

                        #region SaveDetails(oDim.DimensionId);
                        var       dimensionId = oDim.DimensionId;
                        DataTable oTable      = null;
                        if (dgvCombinationList.DataSource != null)
                        {
                            oTable = dgvCombinationList.DataSource as DataTable;

                            ProductDim_DetailsEx.DeleteByDimensionId(dimensionId);
                            foreach (DataRow row in oTable.Rows)
                            {
                                var oDetail = ctx.ProductDim_Details.Find(row["DimDetailId"]);
                                if (oDetail == null)
                                {
                                    oDetail             = new EF6.ProductDim_Details();
                                    oDetail.DimDetailId = Guid.NewGuid();
                                    oDetail.DimensionId = dimensionId;

                                    ctx.ProductDim_Details.Add(oDetail);
                                }
                                oDetail.APPENDIX1 = row["Appendix1"].ToString();
                                oDetail.APPENDIX2 = row["Appendix2"].ToString();
                                oDetail.APPENDIX3 = row["Appendix3"].ToString();

                                ctx.SaveChanges();
                            }
                        }
                        #endregion

                        scope.Commit();
                    }
                    catch (Exception ex)
                    {
                        scope.Rollback();
                    }
                }
            }

            if (this.CombinId != Guid.Empty)
            {
                Helper.DesktopHelper.RefreshMainList <CombinationList>();
            }
        }