public static void Save(string generalId, string NameEn, string NameAr, string NameFr, string subid) { if (string.IsNullOrEmpty(NameEn) || string.IsNullOrEmpty(NameAr) || string.IsNullOrEmpty(NameFr)) { Utils.GetSubCode(ref NameEn, ref NameAr, ref NameFr); } if (string.IsNullOrEmpty(subid)) { subid = MgrSub.GetMaxSubCode(generalId, 1); subid = subid.Substring(0, 3) + (Convert.ToInt32(subid.Substring(3)) + 1).ToString("00000"); } SubCodeVm[] vm = new SubCodeVm[3]; vm[0] = new SubCodeVm { GeneralID = generalId, SubID = subid }; vm[1] = new SubCodeVm { GeneralID = generalId, SubID = subid }; vm[2] = new SubCodeVm { GeneralID = generalId, SubID = subid }; vm[0].LanguageID = 1; vm[0].Name = NameEn; vm[1].LanguageID = 2; vm[1].Name = NameFr; vm[2].LanguageID = 3; vm[2].Name = NameAr; MgrSub.Save(vm[0]); }
protected void btnUpload_Click(object sender, EventArgs e) { if (fUpload.HasFiles) { string path = Server.MapPath(Request.ApplicationPath + "//Temp//" + fUpload.FileName); fUpload.PostedFile.SaveAs(path); int themeId = 0; int reportId = 0; DataSet ds = GetDataTableFromExcel(path, ref themeId, ref reportId); string value; if (ds.Tables.Count > 0) { string generalID, generalName, SubiD, SubName; int lang = 1; foreach (DataTable dt in ds.Tables) { for (int x = 0; x < dt.Columns.Count; x++) { lang = int.Parse(dt.Rows[0][x].ToString().Split(new[] { '-' })[0]); generalID = dt.Columns[x].ColumnName.Split(new[] { '-' })[0]; generalName = dt.Columns[x].ColumnName.Split(new[] { '-' })[1]; if (generalID.Substring(0, 1) != "0") { generalID = dt.Columns[x].ColumnName.Split(new[] { '-' })[1]; generalName = dt.Columns[x].ColumnName.Split(new[] { '-' })[0]; } MgrGeneralCode.Save(new GeneralCodeVM() { GeneralID = generalID, Name = generalName, LanguageID = lang, ParentGeneralcodeID = "1" }); switch (lang) { case 1: MgrSubCode.Save(new SubCodeVm() { GeneralID = generalID, LanguageID = lang, Name = "ALL", SubID = generalID + "00001" }); break; case 3: MgrSubCode.Save(new SubCodeVm() { GeneralID = generalID, LanguageID = lang, Name = "الكل", SubID = generalID + "00001" }); break; case 2: MgrSubCode.Save(new SubCodeVm() { GeneralID = generalID, LanguageID = lang, Name = "TOUS", SubID = generalID + "00001" }); break; } for (int i = 1; i < dt.Rows.Count; i++) { SubiD = generalID + (i + 1).ToString("00000"); SubName = dt.Rows[i][x].ToString(); if (!string.IsNullOrEmpty(SubName)) { MgrSubCode.Save(new SubCodeVm() { GeneralID = generalID, LanguageID = lang, Name = SubName, SubID = SubiD }); } } } } ClientScript.RegisterStartupScript(GetType(), "alert", "lmis.notification.success('" + GetGlobalResourceObject("MessagesResource", "X_Success") + @"');", true); } else { } } else { ClientScript.RegisterStartupScript(GetType(), "alert", "lmis.notification.error('" + GetGlobalResourceObject("MessagesResource", "X_SelectFile") + @"');", true); } }