public JsonResult generateVoucherNumber(int companyCode, int branchCode, int voucherCode, DateTime voucherDate) { using (SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB()) { var voucherTypes = db.Database.SqlQuery <VoucherTypeVM>("select CAST( RANK() over (order by AccountCode,VoucherCode ) AS int) as VoucherTypeRowNumber, VoucherCode,VoucherName,AccountCode,AccountTitle,TransactionType, Category,Frequency,CompanyCode,BranchCode from LOV_VoucherType") .Where(x => x.CompanyCode == companyCode && x.BranchCode == branchCode).ToList(); var voucherType = voucherTypes.Where(x => x.VoucherCode == voucherCode).FirstOrDefault(); var assignAccountCodeDisable = voucherType.TransactionType; int voucherNumber = new hdlVoucherMaster().getVoucherNumber(companyCode, branchCode, voucherCode, voucherDate); Dictionary <int, string> voucherTypeAccount = new Dictionary <int, string>(); voucherTypeAccount.Add(1, "Bank"); voucherTypeAccount.Add(2, "Cash"); return(Json(new { VoucherNumber = voucherNumber, AccountCode = voucherType.TransactionType.Contains(voucherTypeAccount.Values.ToString()) ? voucherType.AccountCode:null, AccountTitle = voucherType.TransactionType.Contains(voucherTypeAccount.Values.ToString()) ? voucherType.AccountTitle : null }, JsonRequestBehavior.AllowGet)); } }
public JsonResult ValidateInstrumentNumber(int companyCode, int branchCode, int instrumentRowNumber, int voucherTypeRowNumber, int instrumentNumber) { using ( SmsMis.Models.Console.Handlers.Admin.SmsMisDB db = new SmsMis.Models.Console.Handlers.Admin.SmsMisDB()) { var voucherTypes = db.Database.SqlQuery <VoucherTypeVM>( "select CAST( RANK() over (order by AccountCode,VoucherCode ) AS int) as VoucherTypeRowNumber, VoucherCode,VoucherName,AccountCode,AccountTitle,TransactionType, Category,Frequency,CompanyCode,BranchCode from LOV_VoucherType") .Where(x => x.CompanyCode == companyCode && x.BranchCode == branchCode).ToList(); var voucherType = voucherTypes.Where(x => x.VoucherTypeRowNumber == voucherTypeRowNumber).FirstOrDefault(); var accountCode = ""; if (voucherType != null) { accountCode = voucherType.AccountCode; } var InstrumentTypes = db.Database.SqlQuery <InstrumentTypeVM>( "select CAST(RANK() over (order by AccountCode) AS int) as InstrumentTypeRowNumber, AccountCode,InstrumentTypeCode,InstrumentName,CompanyCode,BranchCode from lov_instrument") .Where(x => x.CompanyCode == companyCode && x.BranchCode == branchCode).ToList(); var InstrumentType = InstrumentTypes.Where(x => x.InstrumentTypeRowNumber == instrumentRowNumber).FirstOrDefault(); var instrumentCode = 0; if (InstrumentType != null) { instrumentCode = InstrumentType.InstrumentTypeCode; } if (accountCode != "" || instrumentCode != 0) { bool ValidNotValid = new hdlVoucherMaster().ValidateInstrumntNumber(companyCode, branchCode, accountCode, instrumentCode, instrumentNumber); return(Json(ValidNotValid, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); } }