예제 #1
0
        public int Insert(bool isWeb = false)
        {
            //if (!JPermission.CheckPermission("BusManagment.WorkOrder.JTariff.Insert"))
            //    return 0;
            string Query = @"
            DECLARE @EzamBeCode int = (SELECT ISNULL(MAX(Code), 0) + 1 FROM [dbo].[AutTarrifEzamBe])
            INSERT INTO [dbo].[AutTarrifEzamBe]
                        ([Code]
                        ,[TarrifCode]
                        ,[DriverPCode]
                        ,[LineCode]
                        ,[EzamBe]
                        ,[BusCodeBeJa]
                        ,[NumOfSevice]
                        ,[FirstStationCode]
                        ,[LastStationCode]
                        ,[StartTime]
                        ,[FinishTime]
                        ,[IsOk]
                        ,[InsertDate])
                    VALUES
                        (@EzamBeCode
                        ," + this.TarrifCode + @"
                        ," + this.DriverPCode + @"
                        ," + this.LineCode + @"
                        ," + this.EzamBe + @"
                        ," + this.BusCodeBeJa + @"
                        ," + this.NumOfSevice + @"
                        ,null
                        ,null
                        ,'" + this.StartTime + @"'
                        ,'" + this.FinishTime + @"'
                        ,1
                        ,GETDATE())
                INSERT INTO [dbo].[AutBusServices]
                        ([Date]
                        ,[BusNumber]
                        ,[FirstStationCode]
                        ,[FirstStationDate]
                        ,[LastStationCode]
                        ,[LastStationDate]
                        ,[DriverCardSerial]
                        ,[DriverPersonCode]
                        ,[InsertDate]
                        ,[FromConsole]
                        ,[IsOk]
                        ,[Deleted]
                        ,[NumOfService]
                        ,[EzamBeCode]
                        ,[LineNumber])
                    VALUES
                        ('" + this.StartTime.ToString("yyyy-MM-dd") + @"'
                        ,(SELECT BusNumber FROM AUTBus WHERE Code = (SELECT BusCode FROM AUTTAriff WHERE Code = " + this.TarrifCode + @"))
                        ,null
                        ,'" + this.StartTime + @"'
                        ,null
                        ,'" + this.FinishTime + @"'
                        ,null
                        ," + this.DriverPCode + @"
                        ,GETDATE()
                        ,0
                        ,4
                        ,0
                        ," + this.NumOfSevice + @"
                        ,@EzamBeCode
                        ,(Select LineNumber from AUTLine Where Code=" + this.LineCode + @" ))

					    declare @tarrif_code int = (select TarrifCode from AutTarrifEzamBe where code = @EzamBeCode)
					    if((select Status from AUTTariff where code = @tarrif_code) = 1)
					    begin
                            exec [dbo].[SP_TarrifeTaeeidByTarrifCode]
                            @tarif_code = @tarrif_code
					    end

                        SELECT @EzamBeCode";
            //,(SELECT BusNumber FROM AUTBus WHERE Code = " + (this.BusCodeBeJa > 0 ? this.BusCodeBeJa.ToString() : "(SELECT BusCode FROM AUTTAriff WHERE Code = " + this.TarrifCode + ")") + @")
            EzamBeTable AT = new EzamBeTable();

            ClassLibrary.JDataBase Db = new ClassLibrary.JDataBase();
            DataTable dt = new DataTable();

            Db.setQuery(Query);
            Db.beginTransaction("EzamBeInsert");
            try
            {
                dt   = Db.Query_DataTable();
                Code = Convert.ToInt32(dt.Rows[0][0]);
                Db.Commit();
            }
            catch (Exception ex)
            {
                ClassLibrary.JSystem.Except.AddException(ex);
                Db.Rollback("EzamBeInsert");
            }
            finally
            {
                Db.Dispose();
            }
            if (Code > 0 && !isWeb)
            {
                Nodes.DataTable.Merge(JEzamBes.GetDataTable(Code));
            }
            return(Code);
        }
예제 #2
0
        public bool Update(bool isWeb = false)
        {
            //if (!JPermission.CheckPermission("BusManagment.WorkOrder.JTariff.Update"))
            //    return false;
            string Query = @"
                    UPDATE [dbo].[AutTarrifEzamBe]
                    SET
                         DriverPCode = " + this.DriverPCode + @"
                        ,LineCode = " + this.LineCode + @"
                        ,EzamBe = " + this.EzamBe + @"
                        ,BusCodeBeJa = " + this.BusCodeBeJa + @"
                        ,NumOfSevice = " + this.NumOfSevice + @"
                        ,StartTime = '" + this.StartTime + @"'
                        ,FinishTime = '" + this.FinishTime + @"'
                    WHERE Code = " + Code + @"
                    UPDATE AutBusServices
                    SET
                         Date = '" + this.StartTime.ToString("yyyy-MM-dd") + @"'
                        ,FirstStationDate = '" + this.StartTime + @"'
                        ,LastStationDate = '" + this.FinishTime + @"'
                        ,DriverPersonCode = " + this.DriverPCode + @"
                        ,NumOfService = " + this.NumOfSevice + @"
                    WHERE Date = '" + this.StartTime.ToString("yyyy-MM-dd") + "' AND isok<>11 and EzamBeCode = " + Code + @"

					declare @tarrif_code int = (select TarrifCode from AutTarrifEzamBe where code = "                     + Code + @")
					if((select Status from AUTTariff where code = @tarrif_code) = 1)
					begin
                        exec [dbo].[SP_TarrifeTaeeidByTarrifCode]
                        @tarif_code = @tarrif_code
					end
					select 1"                    ;
            //,BusNumber = (SELECT BusNumber FROM AUTBus WHERE Code = " + (this.BusCodeBeJa > 0 ? this.BusCodeBeJa.ToString() : "(SELECT BusCode FROM AUTTAriff WHERE Code = " + this.TarrifCode + ")") + @")
            EzamBeTable AT = new EzamBeTable();

            ClassLibrary.JDataBase Db = new ClassLibrary.JDataBase();
            DataTable dt = new DataTable();

            Db.setQuery(Query);
            Db.beginTransaction("EzamBeUpdate");
            try
            {
                if (Convert.ToInt32(Db.Query_DataTable().Rows[0][0]) == 1)
                {
                    if (!isWeb)
                    {
                        Nodes.Refreshdata(Nodes.CurrentNode, JEzamBes.GetDataTable(Code).Rows[0]);
                    }
                    Db.Commit();
                    return(true);
                }
                else
                {
                    Db.Rollback("EzamBeUpdate");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ClassLibrary.JSystem.Except.AddException(ex);
                Db.Rollback("EzamBeUpdate");
                return(false);
            }
            finally { Db.Dispose(); }
        }