protected void treelstToolUnits_NodeInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { //DND //Guid inventoryID = PrivateSession.Instance.InventoryId; Guid inventoryUnitId = Guid.Parse(e.NewValues["InventoryUnitId!Key"].ToString()); Boolean check = false; InventoryBO bo = new InventoryBO(); Guid checkGuid = Guid.Empty; List <Guid> inventotyUnitList = new List <Guid>(); bo.getInventoryTree(session, PrivateSession.Instance.InventoryId, ref inventotyUnitList); if (inventotyUnitList != null || inventotyUnitList.Count > 0) { checkGuid = inventotyUnitList.Find(p => p == inventoryUnitId); } if (!Guid.Equals(checkGuid, Guid.Empty)) { check = true; } Guid parentInventotyId; if (!treelstToolUnits.NewNodeParentKey.Equals(String.Empty)) { parentInventotyId = Guid.Parse(treelstToolUnits.NewNodeParentKey); // parentInventotyId = PrivateSession.Instance.InventoryId; if (bo.checkIsAlreadyHaveAChild(session, parentInventotyId)) { throw new Exception(String.Format("Lỗi: 1 nhánh chỉ được tạo 1 đơn vị lưu trữ")); } } if (check == true) { //SQL search Name trong InventoryUnit XPCollection <InventoryUnit> collectionUnit = new XPCollection <InventoryUnit>(session); collectionUnit.Criteria = CriteriaOperator.And( new BinaryOperator("InventoryUnitId", inventoryUnitId, BinaryOperatorType.Equal), new BinaryOperator("RowStatus", 1, BinaryOperatorType.Equal) ); InventoryUnit nameInventoryUnit = collectionUnit.First(); //Sau khi search lay duoc Mang gia tri //nameInventoryUnit . goi ra ten cot can lay throw new Exception(String.Format("Lỗi trùng đơn vị lưu trữ {0} trên cây", nameInventoryUnit.Name.ToString())); } else { string parentKey = treelstToolUnits.NewNodeParentKey; if (parentKey.Equals(String.Empty)) { e.NewValues["ParentInventoryId!Key"] = this.treelstToolUnits.RootValue; } } //END DND }
public String searchForeignCurrencyId(Session session) { XPCollection <ForeignCurrency> collectionFC = new XPCollection <ForeignCurrency>(session); collectionFC.Criteria = CriteriaOperator.And( new BinaryOperator("Name", "NAAN_DEFAULT", BinaryOperatorType.Equal), new BinaryOperator("RowStatus", -1, BinaryOperatorType.Equal) ); ForeignCurrency FCId = collectionFC.First(); return(FCId.ForeignCurrencyId.ToString()); }
//DND public String searchOrganizationId(Session session) { XPCollection <Organization> collectionOrg = new XPCollection <Organization>(session); collectionOrg.Criteria = CriteriaOperator.And( new BinaryOperator("Code", "NAAN_DEFAULT", BinaryOperatorType.Equal), new BinaryOperator("RowStatus", -1, BinaryOperatorType.Equal) ); Organization orgId = collectionOrg.First(); return(orgId.OrganizationId.ToString()); }
public String searchVouchesTypeId(Session session, string value) { XPCollection <VouchesType> collection = new XPCollection <VouchesType>(session); collection.Criteria = CriteriaOperator.And( new BinaryOperator("Description", value, BinaryOperatorType.Equal), new BinaryOperator("RowStatus", 1, BinaryOperatorType.Equal) ); VouchesType voucherType_id = collection.First(); return(voucherType_id.VouchesTypeId.ToString()); }
public String searchOrgId(Session session, string value) { string a = ""; if (!value.Equals("")) { XPCollection <Organization> collectionOrgAd = new XPCollection <Organization>(session); collectionOrgAd.Criteria = CriteriaOperator.And( new BinaryOperator("Code", value, BinaryOperatorType.Equal), new BinaryOperator("RowStatus", 1, BinaryOperatorType.Equal) ); Organization orgAdress = collectionOrgAd.First(); a = orgAdress.OrganizationId.ToString(); } return(a.ToString()); }
/// <summary> /// vraci seznam kladných nenulových předpisů dle poplatku a osoby_id /// částka predpisu je částka snížená o přípárování zápornou částí (CASTKA = PREDPIS + SANKCE - SPAROVANO_MINUSEM /// => seznam neobsahuje předpisy, které byly celé uhrazeny jen zápornymi předpisy /// </summary> /// <param name="session"></param> /// <param name="EXT_APP_KOD"></param> /// <param name="predpis"></param> /// <returns></returns> internal PREDPISY_RESP DejPredpisy(Session session, int EXT_APP_KOD, int osobaId, int poplKod) { Session sesna = session; PREDPISY_RESP resp = new PREDPISY_RESP(); resp.status = Status.NOTEXISTS; CriteriaOperator criteria; sesna.DropIdentityMap(); #region kontrola vstupnich udaju try { if (EXT_APP_KOD == null) { throw new Exception("kód externí aplikace není zadán"); } KONTROLA_POPLATKU kp = new KONTROLA_POPLATKU(sesna, EXT_APP_KOD); if (!kp.EAexist()) { throw new Exception("Chybný kód externí aplikace."); } if (!kp.existPravoNadPoplatkem(poplKod)) { throw new Exception("K pohledávce neexistuje oprávnění."); } if (osobaId <= 0) { throw new Exception("Osoba musí být zadána."); } #region kontrola prava na cteni predpisu PravoNadPoplatkem pnp = null; try { pnp = new PravoNadPoplatkem(sesna); } catch (Exception) { throw new Exception("kontrola přístp. práv uživatele nad daty Příjmové agendy skončila chybou"); } if (!pnp.PravoExist(poplKod, PravoNadPoplatkem.PrtabTable.PRPL, PravoNadPoplatkem.SQLPerm.SELECT)) { throw new Exception("PoplWS - nedostatečná oprávnění pro čtení předpisů."); } #endregion kontrola prava nad predpisy } catch (Exception exc) { resp.result = Result.ERROR; if (exc.InnerException == null) { resp.ERRORMESS = exc.Message; } else { resp.ERRORMESS = exc.InnerException.Message; } return(resp); } #endregion kontrola vstupnich udaju try { criteria = CriteriaOperator.Parse("ADR_ID = ?", osobaId); XPCollection <P_ADRESA_ROBRHS> osoba = new XPCollection <P_ADRESA_ROBRHS>(sesna, criteria); string adrIco; if (osoba.Count == 1) { adrIco = osoba.First().ADR_ICO; } else { resp.result = Result.OK; resp.status = Status.NOTEXISTS; resp.ERRORMESS = string.Format("Osoba {0} neexistuje", osobaId); return(resp); } int roku; if (!int.TryParse(System.Configuration.ConfigurationManager.AppSettings["DejPredpisy_HistRoku"], out roku)) { roku = 1; } DateTime predpisyOdRoku = new DateTime(DateTime.Now.AddYears(-1 * roku).Year, 1, 1); criteria = CriteriaOperator.Parse("CompoundKey.PRPL_ICO = ? and CompoundKey.PRPL_POPLATEK = ? " + " and PRPL_RECORD in (' ', 'P') and " + " (PRPL_VYSTAVENO > ? or PRPL_PREDPIS + PRPL_SANKCE - PRPL_SPAROVANO > 0)", adrIco, poplKod, predpisyOdRoku); XPCollection <P_PRPL> prpls = new XPCollection <P_PRPL>(sesna, criteria); foreach (var item in prpls) { if (item.USER_PREDPIS - item.PRPL_SPAROVANO_MINUSEM <= 0) { continue; } if (item.PRPL_PREDPIS < 0) { continue; } C_NAZPOPL nazpopl = sesna.GetObjectByKey <C_NAZPOPL>((decimal)poplKod); if (nazpopl != null) { resp.BANKOVNI_SPOJENI.SMER_KOD_BANKY = nazpopl.NAZPOPL_PRIJBANKA; resp.BANKOVNI_SPOJENI.CISLO_UCTU = nazpopl.NAZPOPL_PRIJUCET; resp.BANKOVNI_SPOJENI.IBAN = nazpopl.NAZPOPL_IBAN; } //zkopiruji PREDPISBaseUhr predpis = new PREDPISBaseUhr(); Utils.copy.CopyDlePersistentAttr <PREDPISBaseUhr>(item, predpis); predpis.PRPL_TYPDANE = item.PRPL_TYPDANE.TYPDANE_KOD; predpis.TYP_NAZEV = item.PRPL_TYPDANE.TYPDANE_NAZEV; predpis.POPLATEK_KOD = (int)nazpopl.NAZPOPL_POPLATEK; predpis.POPLATEK_NAZEV = nazpopl.C_NAZPOPL_NAZEV; predpis.PRPL_VS = item.PRPL_VS; decimal uhrazenoKc = 0, prKc = 0; Util.Util.DejKCReduk(ref prKc, ref uhrazenoKc, item.USER_PREDPIS, item.PRPL_SPAROVANO, item.PRPL_SPAROVANO_MINUSEM); predpis.PRPL_PREDPIS = prKc; predpis.KC_UHRAZENO = uhrazenoKc; foreach (var itemDPH in item.P_PRPL_DPH) { RADEK_DPH dph = new RADEK_DPH(); DPHRozpisPredp tmp = new DPHRozpisPredp(); Utils.copy.CopyDlePersistentAttr <DPHRozpisPredp>(itemDPH, tmp); Utils.copy.CopyDlePersistentAttr <RADEK_DPH>(tmp, dph); predpis.RADKY_DPH.Add(dph); } resp.PREDPISY.Add(predpis); } resp.result = Result.OK; if (resp.PREDPISY.Count > 0) { resp.status = Status.EXISTS; } return(resp); } catch (Exception exc) { resp.result = Result.ERROR; resp.status = Status.ERROR; resp.ERRORMESS = "Chyba při získávání seznamu předpisů."; Util.Util.WriteLog(exc.Message + "\n\n" + exc.InnerException); return(resp); } }
public OSOBA_RESP InsertOsobu(Session session, int EXT_APP_KOD, OSOBA osoba) { Session sesna = session; OSOBA_RESP osobaResp = new OSOBA_RESP(); osoba.ADR_EA = EXT_APP_KOD; try { #region test vyplneni vstupnich hodnot if (osoba.RC_IC != null) { osoba.RC_IC = osoba.RC_IC.Trim(); } if (osoba.JMENO != null) { osoba.JMENO = osoba.JMENO.Trim(); } if (osoba.PRIJMENI != null) { osoba.PRIJMENI = osoba.PRIJMENI.Trim(); } if (string.IsNullOrEmpty(osoba.RC_IC)) // na string.IsNullOrWhiteSpace(osoba.RC_IC) testovat nemusim, //protoze je vyse Trimovan { P_NASTAVENI nast = sesna.GetObjectByKey <P_NASTAVENI>("ICOP"); if ((nast == null) || ((nast != null) && (nast.HODNOTA == "1"))) { osobaResp.result = Result.ERROR; osobaResp.ERRORMESS = "IČ/RČ musí být vyplněno"; return(osobaResp); } } if (EXT_APP_KOD == null) { throw new Exception("kód externí aplikace není zadán"); } P_EXTAPP EA = sesna.GetObjectByKey <P_EXTAPP>(EXT_APP_KOD); if (EA == null) { throw new Exception("chybný kód externí aplikace"); } if (((osoba.TYP == TypOsoby.F) || (osoba.TYP == TypOsoby.C)) && (string.IsNullOrEmpty(osoba.RC_IC)) && (string.IsNullOrEmpty(osoba.JMENO) || string.IsNullOrEmpty(osoba.PRIJMENI) || (!osoba.DATUM_NAROZENI.HasValue)) ) { throw new Exception("u fyzické osoby musí být vyplněno jméno, příjmení a datum narození"); } if (!string.IsNullOrEmpty(osoba.STAT)) { P_STAT stat = sesna.FindObject <P_STAT>(CriteriaOperator.Parse("Upper(STAT_NAZEV) = ?", osoba.STAT.ToUpper())); if (stat == null) { stat = sesna.FindObject <P_STAT>(CriteriaOperator.Parse("STAT_KOD = ?", osoba.STAT.ToUpper())); } if (stat == null) { throw new Exception(string.Format("stát \"{0}\" není uveden v číselníku států", osoba.STAT)); } else { osoba.STAT = stat.STAT_KOD; } } else { osoba.STAT = null; } if (osoba.ZAHRANICNI_ADRESA != null) { if ((osoba.TYP != TypOsoby.C) && (osoba.TYP != TypOsoby.P)) { throw new Exception(string.Format("Zahraniční adresu lze uvádět pouze pro cizince a právnické osoby.")); } if (String.IsNullOrEmpty(osoba.ZAHRANICNI_ADRESA.STAT)) { throw new Exception(string.Format("U zahraniční adresy musí být uveden stát.")); } if (!String.IsNullOrEmpty(osoba.OBEC_NAZEV) || !String.IsNullOrEmpty(osoba.ULICE_NAZEV) || (osoba.CIS_DOMU != null) || (osoba.CIS_OR != null) || !String.IsNullOrEmpty(osoba.PSC) || !String.IsNullOrEmpty(osoba.STAT) ) { throw new Exception(string.Format("U zahraniční adresy nelze současně uvádět trvalou adresu.")); } P_STAT stat = sesna.FindObject <P_STAT>(CriteriaOperator.Parse("Upper(STAT_NAZEV) = ?", osoba.ZAHRANICNI_ADRESA.STAT.ToUpper())); if (stat == null) { stat = sesna.FindObject <P_STAT>(CriteriaOperator.Parse("STAT_KOD = ?", osoba.ZAHRANICNI_ADRESA.STAT.ToUpper())); } if (stat == null) { throw new Exception(string.Format("Stát \"{0}\" není uveden v číselníku států.", osoba.ZAHRANICNI_ADRESA.STAT)); } } #endregion test vyplneni vstupnich hodnot using (UnitOfWork uow = new UnitOfWork(sesna.DataLayer)) { //dotaz, zda j*z neexistuje if (!string.IsNullOrEmpty(osoba.RC_IC)) { CriteriaOperator criteria = CriteriaOperator.Parse("(ADR_SICO = ? or ADR_ICO = ?)", osoba.RC_IC, osoba.RC_IC); XPCollection <P_ADRESA_ROBRHS> adrExist = new XPCollection <P_ADRESA_ROBRHS>(sesna, criteria); if (adrExist.Count > 0) { #region adresa existuje - muze existovat vice osob se stejnym ADR_SICO #region adresa je vybirana v poradi P_ADRESA_ROBRHS osobaExist = null; int isico = -1; int iico = -1; for (int i = 1; i <= 4; i++) { if (i == 1) { adrExist.Filter = CriteriaOperator.Parse("ADR_EA = ? and ADR_ADRPOPL > -1", EXT_APP_KOD); } if (i == 2) { adrExist.Filter = CriteriaOperator.Parse("ADR_ADRPOPL > -1"); } if (i == 3) { adrExist.Filter = CriteriaOperator.Parse("ADR_EA = ?", EXT_APP_KOD); } if (i == 4) { adrExist.Filter = null; } if (adrExist.Count > 0) { if (adrExist.First(P_ADRESA_ROBRHS => P_ADRESA_ROBRHS.ADR_SICO == osoba.RC_IC).ADR_SICO != null) { isico = 0; } if (adrExist.First(P_ADRESA_ROBRHS => P_ADRESA_ROBRHS.ADR_ICO == osoba.RC_IC).ADR_ICO != null) { iico = 0; } } if (isico > -1 || iico > -1) { break; } } #endregion adresa je vybrana v poradi if (isico > -1 || iico > -1) { osobaExist = isico >= 0 ? adrExist[isico] : adrExist[iico]; if ((adrExist[adrExist.IndexOf(osobaExist)].ADR_SICO == null) && (isico == -1) && (iico >= 0)) { adrExist[iico].ADR_SICO = osoba.RC_IC; adrExist[iico].Save(); } osobaResp.result = Result.OK; osobaResp.status = Status.EXISTS; Utils.copy.CopyDlePersistentAttr <OSOBA_RESP>(osobaExist, osobaResp); Utils.copy.CopyDlePersistentAttr <KONTAKTNI_ADRESA>(osobaExist, osobaResp.KONTAKTNI_ADRESA); osobaResp.RC_IC = osobaExist.ADR_SICO; //0.8 #endregion adresa existuje return(osobaResp); } } } P_ADRESA_ROBRHS adr = new P_ADRESA_ROBRHS(uow); Utils.copy.CopyDlePersistentAttr <P_ADRESA_ROBRHS>(osoba, adr); Utils.copy.CopyDlePersistentAttr <P_ADRESA_ROBRHS>(osoba.KONTAKTNI_ADRESA, adr); if (osoba.ZAHRANICNI_ADRESA != null) { Utils.copy.CopyDlePersistentAttr <P_ADRESA_ROBRHS>(osoba.ZAHRANICNI_ADRESA, adr); } try { uow.CommitChanges(); CriteriaOperator criteria = CriteriaOperator.Parse("ADR_ICO = ?", adr.ADR_ICO); XPCollection <P_ADRESA_ROBRHS> adrInserted = new XPCollection <P_ADRESA_ROBRHS>(sesna, criteria); Utils.copy.CopyDlePersistentAttr <OSOBA_RESP>(adrInserted[0], osobaResp); Utils.copy.CopyDlePersistentAttr <KONTAKTNI_ADRESA>(adrInserted[0], osobaResp.KONTAKTNI_ADRESA); osobaResp.result = Result.OK; osobaResp.status = Status.INSERTED; osobaResp.ADR_ID = adrInserted[0].ADR_ID; osobaResp.RC_IC = adrInserted[0].ADR_SICO; //0.8 return(osobaResp); } catch (Exception exc) { uow.RollbackTransaction(); osobaResp.result = Result.ERROR; if (exc.InnerException == null) { osobaResp.ERRORMESS = exc.Message; } else { osobaResp.ERRORMESS = exc.InnerException.Message; } return(osobaResp); /* * throw new Exception(String.Format("chyba \n {0}", exc.InnerException.Message)); */ } } //uow } catch (Exception exc) { osobaResp.result = Result.ERROR; if (exc.InnerException == null) { osobaResp.ERRORMESS = exc.Message; } else { osobaResp.ERRORMESS = exc.InnerException.Message; } Util.Util.WriteLog(osobaResp.ERRORMESS + "\n" + exc.StackTrace); return(osobaResp); /* * throw new Exception(String.Format("chyba \n {0}", exc.InnerException.Message)); */ } }
public static AudienceTV MapAudTV(Zero.POCO.Audiences.AudienceTV Adj, UnitOfWork uow, XPCollection<XpoSupportTV> supports) { var audience = new Donnees.AudienceTV(uow); audience.Oid = Adj.id != default(Guid) ? Adj.id : Guid.NewGuid(); audience.NumeroQuertdheure = Adj.NumeroQuertdheure; audience.NumeroJour = Adj.NumeroJour; var support = supports.First(e => e.Code == Adj.SupportTV.Code); audience.SupportTV = support; return audience; }
public static AudienceRadio MapAudRD(POCO.Audiences.AudienceRadio Adj, UnitOfWork uow, XPCollection<XpoSupportRadio> supports) { var audience = new Donnees.AudienceRadio(uow); audience.Oid = Adj.id != default(Guid) ? Adj.id : Guid.NewGuid(); audience.QuartHeure = Adj.QuartHeure; audience.NumeroJour = Adj.NumeroJour; var support = supports.First(e => e.Code == Adj.SupportRadio.Code); audience.SupportRadio = support; return audience; }
public static Donnees.AudienceJournal MapAudJournal(AudienceJournal Adj, UnitOfWork uow, XPCollection<XpoSupportPresse> supports) { var audience = new Donnees.AudienceJournal(uow); audience.NombreOccurence = Adj.NombreOccurence; audience.NumJournal = Adj.NumJournal; audience.Oid = Adj.id != default(Guid) ? Adj.id : Guid.NewGuid(); var support = supports.First(e => e.Code==Adj.NumJournal); audience.SupportPresse = support; return audience; }