Ejemplo n.º 1
0
        public async Task <IHttpActionResult> PostWeb_FDocR(string ace, string sal, string group, FDocRObject FDocRObject)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, 0, "18", 9, 0);

            if (con == "ok")
            {
                string sql = string.Format(CultureInfo.InvariantCulture,
                                           @"select top(10000)  * FROM  dbo.Web_FDocR('{0}', '{1}','{2}') AS FDocR where 1 = 1 ",
                                           FDocRObject.ModeCode1, FDocRObject.ModeCode2, dataAccount[2]);

                sql += UnitPublic.SpiltCodeAnd("InvCode", FDocRObject.InvCode);
                sql += UnitPublic.SpiltCodeAnd("KGruCode", FDocRObject.KGruCode);
                sql += UnitPublic.SpiltCodeAnd("KalaCode", FDocRObject.KalaCode);
                sql += UnitPublic.SpiltCodeAnd("CustCode", FDocRObject.CustCode);
                sql += UnitPublic.SpiltCodeAnd("OprCode", FDocRObject.OprCode);
                sql += UnitPublic.SpiltCodeAnd("MkzCode", FDocRObject.MkzCode);

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

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

                var listFDocR = UnitDatabase.db.Database.SqlQuery <Web_FDocR>(sql);
                return(Ok(listFDocR));
            }
            return(Ok(con));
        }
        public async Task <IHttpActionResult> PostWeb_TestMoveFactor(string ace, string sal, string group, long serialNumber, string ModeCode)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, serialNumber, "", 0, 0);

            if (con == "ok")
            {
                string sql = string.Format(CultureInfo.InvariantCulture,
                                           @"DECLARE	@retval nvarchar(250)
                                            EXEC	[dbo].[Web_TestFDoc_Move]
		                                            @serialNumber = {0},
		                                            @MoveToModeCode = '{1}',
		                                            @retval = @retval OUTPUT

                                            SELECT	@retval as N'@retval'"    ,
                                           serialNumber,
                                           ModeCode);
                try
                {
                    var result = UnitDatabase.db.Database.SqlQuery <string>(sql).ToList();
                    return(Ok(result));
                    // return Ok("");
                }
                catch (Exception e)
                {
                    throw;
                }
            }
            return(Ok(con));
        }
        public async Task <IHttpActionResult> DeleteAFI_FDocBi(string ace, string sal, string group, long SerialNumber, int BandNo, string ModeCode, string FlagLog)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, SerialNumber, ModeCode, 6, BandNo);

            if (con == "ok")
            {
                try
                {
                    // Fct5: 'Fct5DocB'   'Radif'
                    // Inv5: 'Inv5DocB'   'Radif'
                    // Afi1: 'Afi1FDocB'  'BandNo'


                    //var list = UnitDatabase.db.AFI_FDocBi.First(c=>c.SerialNumber == SerialNumber && c.BandNo==BandNo);
                    //if (list == null)
                    //{
                    //    return NotFound();
                    //}
                    string sql = string.Format(@"DECLARE	@return_value int
                                                 EXEC	@return_value = [dbo].[Web_SaveFDoc_BD]
		                                                @SerialNumber = {0},
		                                                @BandNo = {1}
                                                 SELECT	'Return Value' = @return_value",
                                               SerialNumber,
                                               BandNo);

                    int value = UnitDatabase.db.Database.SqlQuery <int>(sql).Single();
                    if (value == 0)
                    {
                        await UnitDatabase.db.SaveChangesAsync();
                    }

                    string sqlUpdateBand = string.Format(@"DECLARE	@return_value int
                                                           EXEC	@return_value = [dbo].[Web_Doc_BOrder]
	                                                            @TableName = '{0}',
                                                                @SerialNumber = {1},
                                                                @BandNoFld = '{2}'
                                                           SELECT	'Return Value' = @return_value"    ,
                                                         ace == "Web1" ? "Afi1FDocB" : "Fct5DocB",
                                                         SerialNumber,
                                                         ace == "Web1" ? "BandNo" : "Radif");
                    int valueUpdateBand = UnitDatabase.db.Database.SqlQuery <int>(sqlUpdateBand).Single();
                    //await UnitDatabase.db.SaveChangesAsync();
                }
                catch (Exception e)
                {
                    throw;
                }
                string sql1       = string.Format(@"SELECT SerialNumber,BandNo,KalaCode,KalaName,MainUnit,MainUnitName,Amount1,Amount2,Amount3,UnitPrice,TotalPrice,Discount,Comm,Up_Flag,KalaDeghatR1,KalaDeghatR2,KalaDeghatR3,KalaDeghatM1,KalaDeghatM2,KalaDeghatM3,DeghatR
                                         FROM Web_FDocB WHERE SerialNumber = {0}", SerialNumber.ToString());
                var    listFactor = UnitDatabase.db.Database.SqlQuery <Web_FDocB>(sql1);
                UnitDatabase.SaveLog(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, SerialNumber, ModeCode, 1, FlagLog, 0);
                return(Ok(listFactor));
            }
            return(Ok(con));
        }
        public async Task <IHttpActionResult> PostWeb_ADocR(string ace, string sal, string group, ADocRObject ADocRObject)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, 0, "16", 9, 0);

            if (con == "ok")
            {
                string status    = UnitPublic.SpiltCodeCama(ADocRObject.StatusCode);
                string oprCode   = UnitPublic.SpiltCodeCama(ADocRObject.OprCode);
                string mkzCode   = UnitPublic.SpiltCodeCama(ADocRObject.MkzCode);
                string aModeCode = UnitPublic.SpiltCodeCama(ADocRObject.AModeCode);
                string AccCode   = UnitPublic.SpiltCodeCama(ADocRObject.AccCode);

                string sql = string.Format(CultureInfo.InvariantCulture,
                                           @"select top(10000) * FROM  Web_ADocR({0},{1},'{2}') AS ADocR where 1 = 1 ",
                                           ADocRObject.DispBands,
                                           ADocRObject.JamRooz,
                                           dataAccount[2]);

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

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



                if (ADocRObject.azShomarh != "")
                {
                    sql += string.Format(" and DocNo >= '{0}' ", ADocRObject.azShomarh);
                }

                if (ADocRObject.taShomarh != "")
                {
                    sql += string.Format(" and DocNo <= '{0}' ", ADocRObject.taShomarh);
                }

                sql += UnitPublic.SpiltCodeAnd("Status", ADocRObject.StatusCode);
                sql += UnitPublic.SpiltCodeAnd("ModeCode", ADocRObject.AModeCode);
                sql += UnitPublic.SpiltCodeAnd("OprCode", ADocRObject.OprCode);
                sql += UnitPublic.SpiltCodeAnd("MkzCode", ADocRObject.MkzCode);

                sql += UnitPublic.SpiltCodeLike("AccCode", ADocRObject.AccCode);

                sql += " order by DocNo,BandNo";

                var listADocR = UnitDatabase.db.Database.SqlQuery <Web_ADocR>(sql);
                return(Ok(listADocR));
            }
            return(Ok(con));
        }
Ejemplo n.º 5
0
        public IQueryable <Web_CheckStatus> GetWeb_CheckStatus(string ace, string sal, string group, int PDMode, int Report)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, 0, "", 0, 0);

            if (con == "ok")
            {
                return(UnitDatabase.db.Web_CheckStatus.Where(c => c.PDMode == PDMode && c.Report == Report));
            }
            return(null);
        }
        public async Task <IQueryable <Web_FDocH> > GetWeb_FDocH(string ace, string sal, string group, long serialNumber, string ModeCode)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, serialNumber, "", 0, 0);

            if (con == "ok")
            {
                var a = UnitDatabase.db.Web_FDocH.Where(c => c.SerialNumber == serialNumber && c.ModeCode == ModeCode);
                return(a);
            }
            return(null);
        }
        public async Task <IHttpActionResult> GetAllWeb_FDocP(string ace, string sal, string group, long SerialNumber)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, SerialNumber, "", 0, 0);

            if (con == "ok")
            {
                string sql       = string.Format(@"select * from Web_FDocP where SerialNumber = {0} order by BandNo", SerialNumber);
                var    listFDocP = UnitDatabase.db.Database.SqlQuery <Web_FDocP>(sql);
                return(Ok(listFDocP));
            }
            return(Ok(con));
        }
        public async Task <IHttpActionResult> GetWeb_FDocHCount(string ace, string sal, string group, string ModeCode)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, 0, "", 0, 0);

            if (con == "ok")
            {
                string sql   = string.Format(@"SELECT count(SerialNumber) FROM Web_FDocH WHERE ModeCode = '{0}'", ModeCode);
                int    count = UnitDatabase.db.Database.SqlQuery <int>(sql).Single();
                return(Ok(count));
            }
            return(Ok(con));
        }
Ejemplo n.º 9
0
        public async Task <IHttpActionResult> GetWeb_AMode(string ace, string sal, string group)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, 0, "", 0, 0);

            if (con == "ok")
            {
                string sql       = "SELECT * FROM Web_AMode";
                var    listAMode = UnitDatabase.db.Database.SqlQuery <Web_AMode>(sql);
                return(Ok(listAMode));
            }
            return(Ok(con));
        }
Ejemplo n.º 10
0
        public async Task <IHttpActionResult> GetWeb_ADocB(string ace, string sal, string group, long serialNumber)
        {
            var dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);

            string con = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, serialNumber, "", 0, 0);

            if (con == "ok")
            {
                string sql       = string.Format(@"SELECT *  FROM Web_ADocB WHERE SerialNumber = {0}", serialNumber);
                var    listSanad = UnitDatabase.db.Database.SqlQuery <Web_ADocB>(sql);
                return(Ok(listSanad));
            }
            return(Ok(con));
        }
Ejemplo n.º 11
0
        public async Task <IHttpActionResult> GetWeb_Jari(string ace, string sal, string group)
        {
            var dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);

            string con = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, 0, "", 0, 0);

            if (con == "ok")
            {
                string sql      = string.Format(@"SELECT distinct Jari as name FROM Web_CheckList where Jari <> ''");
                var    listJari = UnitDatabase.db.Database.SqlQuery <Web_ValueBank>(sql);
                return(Ok(listJari));
            }
            return(Ok(con));
        }
        public async Task <IHttpActionResult> GetWeb_FDocB(string ace, string sal, string group, long serialNumber)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, serialNumber, "", 0, 0);

            if (con == "ok")
            {
                string sql        = string.Format(@"SELECT SerialNumber,BandNo,KalaCode,KalaName,MainUnit,MainUnitName,Amount1,Amount2,Amount3,UnitPrice,TotalPrice,Discount,Comm,Up_Flag,KalaDeghatR1,KalaDeghatR2,KalaDeghatR3,KalaDeghatM1,KalaDeghatM2,KalaDeghatM3,DeghatR
                                         FROM Web_FDocB WHERE SerialNumber = {0}", serialNumber);
                var    listFactor = UnitDatabase.db.Database.SqlQuery <Web_FDocB>(sql);
                return(Ok(listFactor));
            }
            return(Ok(con));
        }
        public async Task <IHttpActionResult> GetWeb_FDocHLastDate(string ace, string sal, string group, string ModeCode)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, 0, "", 0, 0);

            if (con == "ok")
            {
                string sql      = string.Format(@"EXEC[dbo].[Web_Doc_Dates]
                                             @TableName = '{0}',
		                                     @Mode = '''{1}'''"        , "fct5doch", ModeCode);
                string lastdate = UnitDatabase.db.Database.SqlQuery <string>(sql).Single();
                return(Ok(lastdate));
            }
            return(Ok(con));
        }
Ejemplo n.º 14
0
        public async Task <IHttpActionResult> PostWeb_ChangeStatus(string ace, string sal, string group, AFI_StatusChange AFI_StatusChange)
        {
            int value = 0;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, AFI_StatusChange.SerialNumber, "Adoc", 0, 0);

            if (con == "ok")
            {
                try
                {
                    string sql = string.Format(CultureInfo.InvariantCulture,
                                               @"DECLARE	@return_value int
                            EXEC	@return_value = [dbo].[Web_SaveADoc_Status]
		                            @DMode = {0},
		                            @UserCode = N'{1}',
		                            @SerialNumber = {2},
		                            @Status = N'{3}'
                            SELECT	'Return Value' = @return_value"    ,
                                               AFI_StatusChange.DMode,
                                               AFI_StatusChange.UserCode,
                                               AFI_StatusChange.SerialNumber,
                                               AFI_StatusChange.Status);

                    value = UnitDatabase.db.Database.SqlQuery <int>(sql).Single();
                    if (value == 0)
                    {
                        await UnitDatabase.db.SaveChangesAsync();
                    }
                }
                catch (Exception)
                {
                    throw;
                }

                UnitDatabase.SaveLog(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, AFI_StatusChange.SerialNumber, "ADoc", 7, "Y", 0);
                return(Ok(200));
            }
            else
            {
                return(Ok(con));
            }
        }
        public async Task <IHttpActionResult> PostWeb_Dftr(string ace, string sal, string group, DftrObject DftrObject)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, 0, "15", 9, 0);

            if (con == "ok")
            {
                // string status = UnitPublic.SpiltCodeCama(DftrObject.StatusCode);
                //string oprCode = UnitPublic.SpiltCodeCama(DftrObject.OprCode);
                // string mkzCode = UnitPublic.SpiltCodeCama(DftrObject.MkzCode);
                //string aModeCode = UnitPublic.SpiltCodeCama(DftrObject.AModeCode);

                string sql = string.Format(CultureInfo.InvariantCulture,
                                           @"select top(10000) * FROM  Web_Dftr('{0}','{1}',{2},'{3}',{4},{5},'{6}') AS Dftr where 1 = 1 and best >= 0 ",
                                           DftrObject.azTarikh,
                                           DftrObject.taTarikh,
                                           DftrObject.Naghl,
                                           DftrObject.AccCode,
                                           DftrObject.DispBands,
                                           DftrObject.JamRooz,
                                           dataAccount[2]);

                if (DftrObject.azShomarh != "")
                {
                    sql += string.Format(" and DocNo >= '{0}' ", DftrObject.azShomarh);
                }

                if (DftrObject.taShomarh != "")
                {
                    sql += string.Format(" and DocNo <= '{0}' ", DftrObject.taShomarh);
                }

                sql += UnitPublic.SpiltCodeAnd("Status", DftrObject.StatusCode);
                sql += UnitPublic.SpiltCodeAnd("ModeCode", DftrObject.AModeCode);
                sql += UnitPublic.SpiltCodeAnd("OprCode", DftrObject.OprCode);
                sql += UnitPublic.SpiltCodeAnd("MkzCode", DftrObject.MkzCode);

                sql += " order by bodytag";

                var listDftr = UnitDatabase.db.Database.SqlQuery <Web_Dftr>(sql);
                return(Ok(listDftr));
            }
            return(Ok(con));
        }
        public async Task <IHttpActionResult> PostWeb_SaveFDoc_HZ(string ace, string sal, string group, AFI_SaveFDoc_HZ AFI_SaveFDoc_HZ)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, 0, "", 0, 0);

            if (con == "ok")
            {
                string sql = string.Format(CultureInfo.InvariantCulture,
                                           @"DECLARE	@return_value int
                                             EXEC	@return_value = [dbo].[Web_SaveFDoc_HZ]
		                                            @SerialNumber = {0},
		                                            @Tanzim = '{1}'
                                             SELECT	'Return Value' = @return_value "    ,
                                           AFI_SaveFDoc_HZ.SerialNumber, AFI_SaveFDoc_HZ.Tanzim);
                var result = UnitDatabase.db.Database.SqlQuery <int>(sql).ToList();
                return(Ok("ok"));
            }
            return(Ok(con));
        }
Ejemplo n.º 17
0
        public async Task <IHttpActionResult> PostWeb_TrzFKala(string ace, string sal, string group, TrzFKalaObject TrzFKalaObject)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, 0, "19", 9, 0);

            if (con == "ok")
            {
                string oprCode    = UnitPublic.SpiltCodeCama(TrzFKalaObject.OprCode);
                string mkzCode    = UnitPublic.SpiltCodeCama(TrzFKalaObject.MkzCode);
                string custCode   = UnitPublic.SpiltCodeCama(TrzFKalaObject.CustCode);
                string cGruCode   = UnitPublic.SpiltCodeCama(TrzFKalaObject.CGruCode);
                string invCode    = UnitPublic.SpiltCodeCama(TrzFKalaObject.InvCode);
                string statusCode = UnitPublic.SpiltCodeCama(TrzFKalaObject.StatusCode);

                string sql = string.Format(CultureInfo.InvariantCulture,
                                           @"select  top (10000) * FROM  dbo.Web_TrzFKala('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}',{12},'{13}') AS TrzFKala where 1 = 1 ",
                                           TrzFKalaObject.ModeCode1,
                                           TrzFKalaObject.ModeCode2,
                                           TrzFKalaObject.azTarikh,
                                           TrzFKalaObject.taTarikh,
                                           TrzFKalaObject.azShomarh,
                                           TrzFKalaObject.taShomarh,
                                           custCode,
                                           cGruCode,
                                           mkzCode,
                                           oprCode,
                                           invCode,
                                           statusCode,
                                           TrzFKalaObject.ZeroValue,
                                           dataAccount[2]
                                           );

                sql += UnitPublic.SpiltCodeAnd("KalaCode", TrzFKalaObject.KalaCode);
                sql += UnitPublic.SpiltCodeAnd("KGruCode", TrzFKalaObject.KGruCode);

                var listTrzFKala = UnitDatabase.db.Database.SqlQuery <Web_TrzFKala>(sql);
                return(Ok(listTrzFKala));
            }
            return(Ok(con));
        }
        public async Task <IHttpActionResult> PostWeb_TestFDoc_Delete(string ace, string sal, string group, TestFDoc_DeleteObject TestFDoc_DeleteObject)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, 0, "", 0, 0);

            if (con == "ok")
            {
                string sql = string.Format(CultureInfo.InvariantCulture,
                                           @"EXEC	[dbo].[Web_TestFDoc_Delete] @serialNumber = {0}, @UserCode = '{1}' ", TestFDoc_DeleteObject.SerialNumber, dataAccount[2]);
                try
                {
                    var result     = UnitDatabase.db.Database.SqlQuery <TestFDoc_Delete>(sql).ToList();
                    var jsonResult = JsonConvert.SerializeObject(result);
                    return(Ok(jsonResult));
                }
                catch (Exception e)
                {
                    throw;
                }
            }
            return(Ok(con));
        }
        public async Task <IHttpActionResult> PostWeb_IMode(string ace, string sal, string group, IModeObject iModeObject)
        {
            var dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);

            string con = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, 0, "", 0, 0);

            if (con == "ok")
            {
                string sql;
                if (iModeObject.InOut == 0)
                {
                    sql = string.Format(@"SELECT * FROM Web_IMode_F({0},'{1}') order by OrderFld ", iModeObject.Mode, iModeObject.UserCode);
                }
                else
                {
                    sql = string.Format(@"SELECT * FROM Web_IMode_F({0},'{1}') WHERE InOut = {2} order by OrderFld ", iModeObject.Mode, iModeObject.UserCode, iModeObject.InOut);
                }
                var listIMode = UnitDatabase.db.Database.SqlQuery <Web_IMode>(sql);
                return(Ok(listIMode));
            }
            return(Ok(con));
        }
        public async Task <IHttpActionResult> GetWeb_FMode(string ace, string sal, string group, int InOut)
        {
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, 0, "", 0, 0);

            if (con == "ok")
            {
                string sql;
                if (InOut == 0)
                {
                    sql = string.Format(@"SELECT * FROM Web_FMode order by OrderFld ");
                }
                else
                {
                    sql = string.Format(@"SELECT * FROM Web_FMode WHERE InOut = {0} order by OrderFld ", InOut);
                }

                var listFMode = UnitDatabase.db.Database.SqlQuery <Web_FMode>(sql);
                return(Ok(listFMode));
            }
            return(Ok(con));
        }
        public async Task <IHttpActionResult> PostWeb_UpdatePriceAnbar(string ace, string sal, string group, long serialnumber)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var    dataAccount = UnitDatabase.ReadUserPassHeader(this.Request.Headers);
            string con         = UnitDatabase.CreateConection(dataAccount[0], dataAccount[1], dataAccount[2], ace, sal, group, serialnumber, "", 0, 0);

            if (con == "ok")
            {
                try
                {
                    string sql = string.Format(CultureInfo.InvariantCulture,
                                               @"DECLARE	@return_value int
                            EXEC    @return_value = [dbo].[Web_IDocB_SetKalaPrice]
		                            @SerialNumber = {0}
                            SELECT  'Return Value' = @return_value",
                                               serialnumber);
                    int value = UnitDatabase.db.Database.SqlQuery <int>(sql).Single();
                    if (value == 0)
                    {
                        await UnitDatabase.db.SaveChangesAsync();
                    }
                }
                catch (Exception)
                {
                    throw;
                }


                string sql1      = string.Format(@"SELECT SerialNumber,BandNo,KalaCode,KalaName,MainUnit,MainUnitName,Amount1,Amount2,Amount3,UnitPrice,TotalPrice,Comm,Up_Flag,KalaDeghatR1,KalaDeghatR2,KalaDeghatR3,KalaDeghatM1,KalaDeghatM2,KalaDeghatM3,DeghatR
                                         FROM Web_IDocB WHERE SerialNumber = {0}", serialnumber);
                var    listIDocB = UnitDatabase.db.Database.SqlQuery <Web_IDocB>(sql1);
                return(Ok(listIDocB));
            }
            return(Ok(con));
        }