public async Task <IHttpActionResult> PostWeb_ErjDocK(string userName, string password, string ace, string sal, string group, ErjDocKObject ErjDocKObject)
        {
            if (UnitDatabase.CreateConection(userName, password, ace, sal, group))
            {
                string sql = string.Format(CultureInfo.InvariantCulture,
                                           @"select * FROM  Web_ErjDocK('{0}') AS ErjDocK where 1 = 1",
                                           ErjDocKObject.SrchSt);

                if (ErjDocKObject.userMode == "USER")
                {
                    sql += string.Format(" and Eghdam = '{0}' ", ErjDocKObject.userName);
                }

                if (ErjDocKObject.azTarikh != "")
                {
                    sql += string.Format(" and DocDate >= '{0}' ", ErjDocKObject.azTarikh);
                }

                if (ErjDocKObject.taTarikh != "")
                {
                    sql += string.Format(" and DocDate <= '{0}' ", ErjDocKObject.taTarikh);
                }


                if (ErjDocKObject.Status != "")
                {
                    sql += string.Format(" and Status = '{0}' ", ErjDocKObject.Status);
                }


                sql += UnitPublic.SpiltCodeAnd("CustCode", ErjDocKObject.CustCode);
                sql += UnitPublic.SpiltCodeAnd("KhdtCode", ErjDocKObject.KhdtCode);

                var listTrzI = UnitDatabase.db.Database.SqlQuery <Web_ErjDocK>(sql);
                return(Ok(listTrzI));
            }
            return(null);
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> PostWeb_ErjDocK(string ace, string sal, string group, ErjDocKObject ErjDocKObject)
        {
            if (UnitDatabase.CreateConection(ace, sal, group))
            {
                string sql = string.Format(CultureInfo.InvariantCulture,
                                           @"select * FROM  Web_ErjDocK('{0}') AS ErjDocK where 1 = 1 ",
                                           ErjDocKObject.SrchSt);

                if (ErjDocKObject.azTarikh != "")
                {
                    sql += string.Format(" and DocDate >= '{0}' ", ErjDocKObject.azTarikh);
                }

                if (ErjDocKObject.taTarikh != "")
                {
                    sql += string.Format(" and DocDate <= '{0}' ", ErjDocKObject.taTarikh);
                }


                if (ErjDocKObject.Status != "")
                {
                    sql += string.Format(" and Status = '{0}' ", ErjDocKObject.Status);
                }

                if (ErjDocKObject.CustCode != "")
                {
                    sql += " and ( ";
                    string[] CustCode = ErjDocKObject.CustCode.Split('*');
                    for (int i = 0; i < CustCode.Length; i++)
                    {
                        if (i < CustCode.Length - 1)
                        {
                            sql += string.Format("  CustCode = '{0}' Or ", CustCode[i]);
                        }
                        else
                        {
                            sql += string.Format("  CustCode = '{0}' )", CustCode[i]);
                        }
                    }
                    //sql += string.Format(" and CustCode = '{0}' ", ErjDocKObject.CustCode);
                }

                if (ErjDocKObject.KhdtCode != "")
                {
                    sql += " and ( ";
                    string[] KhdtCode = ErjDocKObject.KhdtCode.Split('*');

                    for (int i = 0; i < KhdtCode.Length; i++)
                    {
                        if (i < KhdtCode.Length - 1)
                        {
                            sql += string.Format("  KhdtCode = {0} Or ", KhdtCode[i]);
                        }
                        else
                        {
                            sql += string.Format("  KhdtCode = {0} )", KhdtCode[i]);
                        }
                    }
                }


                var listTrzI = UnitDatabase.db.Database.SqlQuery <Web_ErjDocK>(sql);
                return(Ok(listTrzI));
            }
            return(null);
        }