public clsMsg validate(clsCmd cmd) { foreach (var f in this) { var msg = f.validate(cmd); if (msg.Validated == false) { return(msg); } } return(g.msg()); }
public Form getForm(string path, clsCmd cmd) { var res = call(path, cmd); if (res.result is Form) { var frm = res.result as Form; setProp(frm); return(frm); } return(null); }
public void fillDropDown(ListControl drp1, string sDataPath, clsCmd cmd, string sDisplayMember = "", string sValueMember = "") { var _response = appService.call(sDataPath, cmd); if (_response.isValid) { DataTable t = _response.result as DataTable; drp1.DisplayMember = sDisplayMember.isEmpty() ? t.Columns[0].ColumnName : sDisplayMember; drp1.ValueMember = sValueMember.isEmpty() ? t.Columns[t.Columns.Count - 1].ColumnName : sValueMember; drp1.DataSource = t; } }
public clsAPIResponse call(string sPath, clsCmd cmd) { var obj = lstRequest.Find(p => p.path == sPath); if (obj == null) { return new clsAPIResponse() { message = string.Format("path [{0}] not found !", sPath) } } ; return(obj.call(cmd)); }
public override object execScalar(clsCmd cmd) { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); var sqlcmd = conn.CreateCommand(); utility.setCommand(cmd, sqlcmd); sqlcmd.CommandText = cmd.SQL; sqlcmd.CommandType = cmd.CommandType; return(sqlcmd.ExecuteScalar()); } }
public override NTier.sqlReport.SQLReportBase getReport(clsCmd cmd) { if (rdlPath.isEmpty() == false) { string sRdlFullPath = _tier.getPath(rdlPath); var rpt = AppDomain.CurrentDomain.CreateInstance("NTier_Web", "NTier.sqlReport.SQLReportWeb").Unwrap() as NTier.sqlReport.SQLReportBase; rpt.output = g.ConvertFileToByteArray(sRdlFullPath); rpt.ds = ds.getDs(cmd); rpt.downloadName = this.downloadName; return(rpt); } return(null); }
public override DataTable getData(clsCmd cmd) { var sqlcmd = getConnection().CreateCommand(); utility.setCommand(cmd, sqlcmd); sqlcmd.CommandText = cmd.SQL; sqlcmd.CommandType = cmd.CommandType; SQLiteDataAdapter ad = new SQLiteDataAdapter(sqlcmd); DataTable t = new DataTable(); ad.Fill(t); return(t); }
public clsCmd getSaveCommand(DataTable t, clsCmd cmd) { int iID = cmd.getIntValue(PrimaryKeyField); correctCommand(cmd, t); if (iID == 0) { return(getInsertCommand(t, cmd)); } else { return(getUpdateCommand(t, cmd)); } }
public clsAPIResponse call(clsCmd cmd) { return(clsAPIResponse.get("not implemented")); //var oCRUD = new NTier.CRUD.clsCRUD(_appService.getAdapter(), name, name, autoIncrementField, true); //try //{ // oCRUD.delete(cmd); // return new clsAPIResponse() { message = "" }; //} //catch (Exception ex) //{ // return new clsAPIResponse() { message = ex.Message }; //} }
private clsMsg validate(XmlNode xNode , clsCmd cmd) { var oValidation = new NTier.Validations.clsValidation(); XmlNodeList xNodeValidations = xNode.SelectNodes("validations/validate"); foreach (XmlNode xnodeValidate in xNodeValidations) { string sType = xnodeValidate.getXmlAttributeValue("type"); string sFieldName = xnodeValidate.getXmlAttributeValue("fieldName"); string sFieldTitle = xnodeValidate.getXmlAttributeValue("fieldTitle"); bool required = xnodeValidate.getXmlAttributeValue("required") == "true" ? true : false; switch (sType) { case "basic": int iMaxLength = g.parseInt(xnodeValidate.getXmlAttributeValue("maxLength")); oValidation.addTextField(sFieldName, sFieldTitle, iMaxLength); break; case "unique": string sTableName = xnodeValidate.getXmlAttributeValue("tableName"); string sPrimaryKey = xnodeValidate.getXmlAttributeValue("primaryKey"); //Validation delete oValidation.addDuplicate(_adapter, sTableName, sPrimaryKey, sFieldName, sFieldTitle, required); break; case "drp": oValidation.addDropDownField(sFieldName, sFieldTitle); break; case "email": oValidation.addEmailField(sFieldName, sFieldTitle, required); break; case "numeric": oValidation.addNumberField(sFieldName, sFieldTitle, required); break; case "check": string checkContraintValues = xnodeValidate.getXmlAttributeValue("values"); oValidation.addCheckConstraint(sFieldName, sFieldTitle, checkContraintValues); break; } } return(oValidation.validate(cmd)); }
public override DataTable getData(clsCmd cmd) { using (SqlConnection conn = new SqlConnection(connectionString)) { var sqlcmd = conn.CreateCommand(); utility.setCommand(cmd, sqlcmd); sqlcmd.CommandText = cmd.SQL; sqlcmd.CommandType = cmd.CommandType; SqlDataAdapter ad = new SqlDataAdapter(sqlcmd); DataTable t = new DataTable(); ad.Fill(t); return(t); } }
public clsAPIResponse drp(clsCmd cmd) { var _adapter = _appService.getAdapter(); var oView = new NTier.Request.clsGetDataView(_adapter); oView.viewName = this.view; string sDisplayField = this.displayFields[0]; string sIDField = this.primaryKeyFields[0]; DataTable t = oView.getDataByColumns(cmd, sDisplayField, sIDField); return(clsAPIResponse.ok(t)); }
public string getDeleteScript(clsCmd prms) { StringBuilder sb1 = new StringBuilder(); sb1.AppendFormat("DELETE FROM {0} ", this.TableName); var sWhere = getWhereCondition(prms); if (sWhere != "") { sb1.AppendFormat(" WHERE {0}", sWhere); } return(sb1.ToString()); }
public clsMsg getData(clsCmd cmd) { var oViewData = new NTier.Request.clsGetDataView(this._adapter); oViewData.viewName = this.ViewName; try { DataTable t = oViewData.getData(cmd); return(g.msg("", t)); } catch (Exception ex) { return(g.msg_exception(ex)); } }
public clsMsg getDropDownData(string sPath , clsCmd cmd) { XmlNode xNode = xDoc.SelectSingleNode("//appConfig/requestData[@type='DropDown']/dt[@name='" + sPath + "']"); if (xNode.getXmlAttributeValue("type") == "sql") { string sSQL = xNode.getXmlText("sql"); cmd.SQL = sqlbuilder.sqlUtility.joinWhereCondition(sSQL, cmd); var t = _adapter.getData(cmd); //var t = _adapter.getData(sSQL); return(g.msg("", t)); } return(g.msg("")); }
public clsAPIResponse getSearchForm(clsCmd cmd) { if (_frmSearch != null && _frmSearch.IsDisposed) { _frmSearch = null; } if (frm == null) { _frmSearch = new frmGridSelectMultiple(); _frmSearch.gridInfo = this; } return(new clsAPIResponse() { result = _frmSearch }); }
public override clsMsg validate(clsCmd cmd) { var msg = base.validate(cmd); if (msg.Validated == false) { return(msg); } string sVal = cmd.getStringValue(this.FieldName); if (sVal.isEmpty() == false && g.isEmail(sVal) == false) { return(g.msg(string.Format("Wrong Email value [{1}] \nYou have not specified proper email value for field [{0}]", this.FieldTitle, sVal))); } return(g.msg("")); }
private void addWhereCondition(StringBuilder sb1, clsCmd prms) { if (prms.Count == 0) { return; } List <string> lstFilters = new List <string>(); foreach (var f in prms) { lstFilters.Add(string.Format("{0} = @{0}", f.Name)); } sb1.Append(" WHERE "); sb1.Append(string.Join(" AND ", lstFilters.ToArray())); }
public DataTable getData(clsCmd cmd) { string q = "select * from " + viewName + " where 1=1 "; add_json_filter(cmd); cmd.SQL = NTier.sqlbuilder.sqlUtility.joinWhereCondition(q, cmd, "_filter"); if (!OrderBy.isEmpty()) { cmd.SQL += " order by " + OrderBy; } var t = _adapter.getData(cmd); return(t); }
public clsAPIResponse call(clsCmd cmd) { clsAPIResponse oLastResponse = new clsAPIResponse() { message = "" }; foreach (clsCallObject f in this.Reverse <clsCallObject>()) { var res = f.call(cmd); oLastResponse = res; if (res.isValid == false) { return(res); } } return(oLastResponse); }
//Amit Jha public clsAPIResponse getForm(clsCmd cmd) { if (frm != null && frm.IsDisposed) { frm = null; } if (frm == null) { frm = new frmGrid(); frm.gridInfo = this; } return(new clsAPIResponse() { result = frm }); }
public static string joinWhereCondition(string sSelectSQL, clsCmd cmd, params string[] sIgnoreFields) { string sWhere = getWhereCondition(cmd, sIgnoreFields); if (string.IsNullOrWhiteSpace(sWhere)) { return(sSelectSQL); } else if (sSelectSQL.Contains("where", "WHERE")) { return(sSelectSQL + " AND " + sWhere); } else { return(sSelectSQL + " WHERE " + sWhere); } }
private void btnLogin_Click(object sender, EventArgs e) { var cmd = new clsCmd(); cmd.setValue("userid", txtUserID.Text); cmd.setValue("pwd", txtPwd.Text); var msg = _Tier.exec("login", cmd); if (msg.Validated) { result = msg; this.Close(); } else { ui.warn(msg.Message); } }
public clsMsg getFileFromQueryString(System.Collections.Specialized.NameValueCollection qs) { string sPath = qs["path"]; string[] sKeys = qs.AllKeys; var cmd = new clsCmd(); foreach (string sKey in sKeys) { if (sKey.isEmpty() == false && sKey.ToUpper() != "PATH") { cmd.setValue(sKey, qs[sKey]); } } var msg = webUtil.tier.getFileContent(sPath, cmd); return(msg); }
private void add_json_filter(clsCmd cmd) { if (cmd.ContainFields("_filter")) { string sFilterJson = cmd.getStringValue("_filter"); var tFilter = Newtonsoft.Json.JsonConvert.DeserializeObject <DataTable>(sFilterJson); foreach (DataRow rFilter in tFilter.Rows) { if (rFilter["val"].ToString().isEmpty() == false && rFilter["name"].ToString().isEmpty() == false) { var prm = cmd.setValue(rFilter["name"].ToString(), rFilter["val"].ToString()); prm.Operator = rFilter["operator"].ToString(); } } cmd.Remove(cmd["_filter"]); } }
public clsCmd getValues() { var cmd = new clsCmd(); foreach (var f in this) { cmd.setValue(f.Field, f.getValue()); } foreach (var file in FileList) { if (file.isFileSelected()) { cmd.Files.Add(file.getFileData()); } } return(cmd); }
public clsAPIResponse getForm(clsCmd cmd) { if (frm != null && frm.IsDisposed) { frm = null; } if (frm == null) { frm = Activator.CreateInstance(assemblyName, classPath).Unwrap() as Form; } return(new clsAPIResponse() { result = frm }); }
public clsMsg upload_bhavdata_row(clsCmd cmd) { int iDaily_PriceID = 0; int iStockID = 0; string sDate1 = ""; string sSymbol = ""; string sSeries = ""; sSymbol = cmd.getStringValue("symbol").Trim(); sSeries = cmd.getStringValue("series").Trim(); DataRow[] rowsStock = getStockMaster().Select(string.Format(" symbol ='{0}' and series = '{1}' ", sSymbol, sSeries)); NTier.CRUD.clsCRUD oCRUD_DailyPrice = _tier.getCRUD("trDaily_Price"); if (rowsStock.Length > 0) { iStockID = g.parseInt(rowsStock[0]["id"]); sDate1 = cmd.getStringValue("date1").Trim(); iDaily_PriceID = oBLLStock.getDaily_PriceID(iStockID, sDate1); cmd.setValue("mStockID", iStockID); cmd.setValue("id", iDaily_PriceID); clsMsg msg = oCRUD_DailyPrice.save(cmd); return(msg); } else { if (sSeries.ToUpper().Trim() == "EQ") { string sMsg = string.Format("Stock Master not found for Series : {0} And Symbol : {1}", sSeries, sSymbol); return(g.msg(sMsg)); } } return(g.msg("")); }
public override clsAPIResponse call(clsCmd cmd) { var _adapter = _appService.getAdapter(); if (fields.Count > 0) { int iID = cmd.getIntValue(idField); StringBuilder sbSQL = new StringBuilder(); sbSQL.AppendFormat("select Count(*) from {0} where {1} != @{1} ", table, idField); var cmd2 = new clsCmd(); List <string> lstValues = new List <string>(); List <string> lstFieldTitle = new List <string>(); foreach (var f in fields) { sbSQL.AppendFormat(" and {0} = @{0} ", f.field); cmd2.setValue(f.field, cmd[f.field].Value); lstValues.Add(cmd2.getStringValue(f.field)); lstFieldTitle.Add(f.getfieldTitle()); } cmd2.setValue(idField, cmd.getIntValue(idField)); cmd2.SQL = sbSQL.ToString(); int iCount = g.parseInt(_adapter.execScalar(cmd2)); if (iCount > 0) { if (fields.Count > 1) { return(clsAPIResponse.get(string.Format("The Values [{0}] for Fields [{1}] already exists, can't accept duplicate !", string.Join(",", lstValues.ToArray()), string.Join(",", lstFieldTitle.ToArray())))); } else if (fields.Count == 1) { return(clsAPIResponse.get(string.Format("The Value [{0}] for Field [{1}] already exists, can't accept duplicate value !", lstValues[0], lstFieldTitle[0]))); } } } return(clsAPIResponse.ok()); }
public clsMsg upload_bhavdata(clsCmd cmd) { DataTable t = null; var msg = getBhavDataInDataTable(cmd); if (msg.Validated) { t = msg.Obj as DataTable; } foreach (DataRow r in t.Rows) { var cmd2 = new clsCmd(); cmd2.AddValues(r); upload_bhavdata_row(cmd2); } return(g.msg()); }