Beispiel #1
0
 public ActionResult AddOptionalItem(Guid optGid)
 {
     Guid orgGid = GetOrganization();
     GeneralOptItem oOptionalItem = new GeneralOptItem
     {
         OptID = optGid,
         Name = NewResource(ModelEnum.ResourceType.STRING, orgGid)
     };
     optid = optGid;
     GeneralOptional oOptional = dbEntity.GeneralOptionals.Where(o => o.Gid == optGid).Single();
     ViewBag.optionalName = oOptional.Name.GetResource(CurrentSession.Culture);
     return View(oOptionalItem);
 }
Beispiel #2
0
        /// <summary>
        /// 保存属性选项
        /// </summary>
        /// <returns>选项列表</returns>
        public void SaveOptionalItem(GeneralOptItem OptionalItem)
        {
            GeneralOptItem oOptionalItem = new GeneralOptItem
            {
                OptID = OptionalItem.OptID,
                Code = OptionalItem.Code,
                Sorting = OptionalItem.Sorting,
                Name = new GeneralResource(ModelEnum.ResourceType.STRING, OptionalItem.Name),
                Remark = OptionalItem.Remark
            };

            dbEntity.GeneralOptItems.Add(oOptionalItem);
            dbEntity.SaveChanges();
        }
Beispiel #3
0
 public ActionResult SetOptionalItems(GeneralOptItem oOptionalItem)
 {
     //为oOptionalItem对象的主表字段赋值,值为Index方法中保存的GeneralOptional对象的Gid
     oOptionalItem.OptID = optionals.Gid;
     dbEntity.GeneralOptItems.Add(oOptionalItem);
     dbEntity.SaveChanges();
     return View();
 }
Beispiel #4
0
        /// <summary>
        /// 导入属性定义
        /// </summary>
        /// <param name="sExcelFile">Excel文件名</param>
        /// <param name="sSheetName">Sheet名</param>
        public void ImportOptional(string sExcelFile, string sSheetName)
        {
            try
            {
                ExcelData oExcel = new ExcelData(sExcelFile, sSheetName);
                DataColumn colOrgan = oExcel.ExcelTable.Columns["组织"];
                DataColumn colType = oExcel.ExcelTable.Columns["用途"];
                DataColumn colMainCode = oExcel.ExcelTable.Columns["属性代码"];
                DataColumn colOptCode = oExcel.ExcelTable.Columns["选项代码"];
                DataColumn colSorting = oExcel.ExcelTable.Columns["排序"];
                DataColumn colNameCN = oExcel.ExcelTable.Columns["中文名称"];
                DataColumn colNameUS = oExcel.ExcelTable.Columns["英文名称"];
                DataColumn colMode = oExcel.ExcelTable.Columns["输入模式"];
                DataColumn colRemark = oExcel.ExcelTable.Columns["备注"];

                string sLastOrgCode = "";
                MemberOrganization oOrgan = null;
                GeneralOptional oOption = null;
                foreach (DataRow row in oExcel.ExcelTable.Rows)
                {
                    string sOrgCode = row[colOrgan].ToString();
                    byte nType;
                    Byte.TryParse(row[colType].ToString(), out nType);
                    string sMainCode = row[colMainCode].ToString();
                    string sOptCode = row[colOptCode].ToString();
                    int nSorting;
                    Int32.TryParse(row[colSorting].ToString(), out nSorting);
                    GeneralResource oName = new GeneralResource(ModelEnum.ResourceType.STRING, 2052, row[colNameCN].ToString(), 1033, row[colNameUS].ToString());
                    byte nMode;
                    Byte.TryParse(row[colMode].ToString(), out nMode);
                    string sRemark = row[colRemark].ToString();

                    if (!String.IsNullOrEmpty(sOrgCode) && (sOrgCode != sLastOrgCode))
                    {
                        oOrgan = (from o in dbEntity.MemberOrganizations
                                  where o.Code == sOrgCode && o.Otype == (byte)ModelEnum.OrganizationType.CORPORATION
                                  select o).FirstOrDefault();
                        sLastOrgCode = sOrgCode;
                    }
                    if (!String.IsNullOrEmpty(sMainCode))
                    {
                        oOption = (from o in dbEntity.GeneralOptionals
                                   where o.OrgID == oOrgan.Gid && o.Code == sMainCode
                                   select o).FirstOrDefault();
                        if (oOption == null)
                        {
                            oOption = new GeneralOptional { Organization = oOrgan, Code = sMainCode };
                            dbEntity.GeneralOptionals.Add(oOption);
                        }
                        oOption.Otype = nType;
                        oOption.Sorting = nSorting;
                        if (oOption.Name == null)
                            oOption.Name = oName;
                        else
                            oOption.Name.SetResource(ModelEnum.ResourceType.STRING, oName);
                        oOption.InputMode = nMode;
                        oOption.Remark = sRemark;
                    }
                    else
                    {
                        GeneralOptItem oOptItem = (from i in dbEntity.GeneralOptItems
                                                   where i.Deleted == false && i.OptID == oOption.Gid && i.Code == sOptCode
                                                   select i).FirstOrDefault();
                        if (oOptItem == null)
                        {
                            oOptItem = new GeneralOptItem { Optional = oOption, Code = sOptCode };
                            dbEntity.GeneralOptItems.Add(oOptItem);
                        }
                        oOptItem.Sorting = nSorting;
                        if (oOptItem.Name == null)
                            oOptItem.Name = oName;
                        else
                            oOptItem.Name.SetResource(ModelEnum.ResourceType.STRING, oName);
                        oOptItem.Remark = sRemark;
                    }
                    dbEntity.SaveChanges();
                    if (Utility.ConfigHelper.GlobalConst.IsDebug)
                        Debug.WriteLine("{0} {1} {2}", this.ToString(), sMainCode, sRemark);
                }
                oEventBLL.WriteEvent(String.Format("导入GeneralOptional成功: {0} {1}", sExcelFile, sSheetName),
                    ModelEnum.ActionLevel.GENERIC, ModelEnum.ActionSource.SYSTEM, this.ToString());
            }
            catch (Exception ex)
            {
                oEventBLL.WriteEvent(String.Format("导入GeneralOptional错误: {0} {1} {2}", sExcelFile, sSheetName, ex.Message),
                    ModelEnum.ActionLevel.ERROR, ModelEnum.ActionSource.SYSTEM, this.ToString());
            }
        }
Beispiel #5
0
        /// <summary>
        /// 删除选中的GeneralOptItem对象
        /// </summary>
        /// <param name="OptionalItempost"></param>
        /// <returns></returns>
        public ActionResult DeleteOptionalItem(GeneralOptItem OptionalItempost)
        {
            GeneralOptItem otherOptItem = dbEntity.GeneralOptItems.Where(g => g.Gid == OptionalItempost.Gid).Single();

            otherOptItem.Deleted = true;
            dbEntity.Entry(otherOptItem).State = EntityState.Modified;
            dbEntity.SaveChanges();
            return Json(GridResponse.CreateSuccess(), JsonRequestBehavior.AllowGet);
        }