Exemplo n.º 1
0
        public clsMsg validate(clsCmd cmd)
        {
            foreach (var f in this)
            {
                var msg = f.validate(cmd);
                if (msg.Validated == false)
                {
                    return(msg);
                }
            }

            return(g.msg());
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        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());
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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));
            }
        }
Exemplo n.º 9
0
 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));
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        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));
        }
Exemplo n.º 13
0
        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());
        }
Exemplo n.º 14
0
        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(""));
        }
Exemplo n.º 16
0
        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
            });
        }
Exemplo n.º 17
0
        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(""));
        }
Exemplo n.º 18
0
        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()));
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
        //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
            });
        }
Exemplo n.º 22
0
        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);
            }
        }
Exemplo n.º 23
0
        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);
            }
        }
Exemplo n.º 24
0
        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);
        }
Exemplo n.º 25
0
        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"]);
            }
        }
Exemplo n.º 26
0
        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);
        }
Exemplo n.º 27
0
        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
            });
        }
Exemplo n.º 28
0
        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(""));
        }
Exemplo n.º 29
0
        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());
        }
Exemplo n.º 30
0
        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());
        }