Exemplo n.º 1
0
        public void Insert(string Name,decimal? Price,int? DirID,string Code,int? CompanyID,bool? IsDeleted,bool? IsOutOfStock,DateTime? OutOfStockDate)
        {
            SysTakeawayMenu item = new SysTakeawayMenu();

            item.Name = Name;

            item.Price = Price;

            item.DirID = DirID;

            item.Code = Code;

            item.CompanyID = CompanyID;

            item.IsDeleted = IsDeleted;

            item.IsOutOfStock = IsOutOfStock;

            item.OutOfStockDate = OutOfStockDate;

            item.Save(UserName);
        }
Exemplo n.º 2
0
 public static bool ImportCompanyMealMenu(DataTable dt, out string message)
 {
     bool result = false;
     message = string.Empty;
     DataColumn dcCompanyTel = null;
     DataColumn dcMenuName = null;
     DataColumn dcDirName = null;
     DataColumn dcPrice = null;
     DataColumn dcCode = null;
     if (dt.Columns.Contains("商家账号"))
         dcCompanyTel = dt.Columns["商家账号"];
     if (dt.Columns.Contains("餐点名称"))
         dcMenuName = dt.Columns["餐点名称"];
     if (dt.Columns.Contains("菜品系列"))
         dcDirName = dt.Columns["菜品系列"];
     if (dt.Columns.Contains("价格"))
         dcPrice = dt.Columns["价格"];
     if (dt.Columns.Contains("菜单编号"))
         dcCode = dt.Columns["菜单编号"];
     if (dcCompanyTel == null || dcMenuName == null)
     {
         message = "导入文件必须包含有商家账号和餐点名称二列信息.";
         goto lbl_return;
     }
     Dictionary<string, int> companyDict = new Dictionary<string, int>( );
     decimal dPrice; int dirId, companyId; string companyTel, menuName, dirName, menuCode;
     SysTakeawayMenu menu;
     int nCounter = 0;
     foreach (DataRow row in dt.Rows)
     {
         dirId = 0;
         dPrice = 0;
         menuCode = null;
         dirName = null;
         if (string.IsNullOrEmpty(companyTel = Utilities.ToDecimal(row[dcCompanyTel]).ToString("0")))
             continue;
         if (companyDict.ContainsKey(companyTel))
             companyId = companyDict[companyTel];
         else
         {
             companyId = CompanyBLL.GetCompanyIdByTel(companyTel, CompanyType.MealCompany);
             if (companyId == 0)
                 continue;
             companyDict.Add(companyTel, companyId);
         }
         if (string.IsNullOrEmpty(menuName = Utilities.ToString(row[dcMenuName]).Trim( )))
             continue;
         if (dcDirName != null && !string.IsNullOrEmpty(dirName = Utilities.ToString(row[dcDirName]).Trim( )))
             dirId = GetMenuDirByName(companyId, dirName);
         if (dcCode != null)
             menuCode = Utilities.ToString(row[dcCode]).Trim( );
         if (dcPrice != null)
             dPrice = Utilities.ToDecimal(row[dcPrice]);
         //var dict = GetMealDirMappingByCompanyId(cmp.Id);
         //cmpMenuId = CompanyMealMenuId.GetCompanyMealMenuId(dirName, menuName);
         //if (dict.ContainsKey(cmpMenuId))
         //    menu = dict[cmpMenuId];
         //else
         menu = new SysTakeawayMenu( );
         menu.Name = menuName;
         menu.CompanyID = companyId;
         menu.DirID = dirId;
         menu.Price = dPrice;
         menu.IsDeleted = false;
         menu.Code = menuCode;
         menu.IsOutOfStock = false;
         menu.OutOfStockDate = null;
         menu.Save( );
         if (string.IsNullOrEmpty(menu.Code))
         {
             menu.Code = menu.Id.ToString( );
             menu.Save( );
         }
         //dict[cmpMenuId] = menu;
         nCounter++;
     }
     if (companyDict.Count > 0)
         UpdateCompanyMenuDate(companyDict.Values, DateTime.Now);
     message = "成功读取到" + nCounter.ToString( ) + "条菜单信息";
     result = true;
     lbl_return:
     return result;
 }