Пример #1
0
        public static bool SetBusPosition(Int64 recordNumber, uint BusSerial, float Lat, float Lng, DateTime Date, ClassLibrary.JDataBase db)
        {
            //ClassLibrary.JDataBase db = new ClassLibrary.JDataBase();
            try
            {
                db.setQuery("Select * from AUTBusPosition where BusSerial = " + BusSerial);

                string date = Date.ToString("yyyy-MM-dd HH:mm:ss");
                if (db.Query_DataTable().Rows.Count > 0)
                {
                    db.setQuery(@"update AUTBusPosition set LastRecordNumber = " + recordNumber + @", Lat = '" + Lat.ToString() + "', Lng = '" + Lng.ToString() + "', Date = CAST('" + date + "' as datetime)" +
                                " where BusSerial = " + BusSerial + " and Date < CAST('" + date + "' as datetime)");
                    db.Query_Execute();
                    return(true);
                }
                else
                {
                    db.setQuery("insert into AUTBusPosition(Code, BusSerial, Lat, Lng, [Date], LastRecordNumber)" +
                                "VALUES(isnull((Select MAX(Code) From AUTBusPosition), 0) + 1, " + BusSerial + ", '" + Lat + "', '" + Lng + "', CAST('" + date + "' as datetime), " + recordNumber + ")");
                    if (db.Query_Execute() >= 0)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            finally
            {
                //db.Dispose();
            }
        }
Пример #2
0
 public static bool SendToOldDatabase(byte[] pData)
 {
     System.Data.SqlClient.SqlConnectionStringBuilder constr = new System.Data.SqlClient.SqlConnectionStringBuilder();
     constr.DataSource     = ".";
     constr.InitialCatalog = "BusAvlSendLogs";
     constr.UserID         = "sa";
     constr.Password       = "******";
     ClassLibrary.JDataBase db = new ClassLibrary.JDataBase(constr);
     try
     {
         db.setQuery("Insert into SendLogs(SendLog) VALUES(@SendLog)");
         db.AddParams("SendLog", pData);
         if (db.Query_Execute() >= 0)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         return(false);
     }
     finally
     {
         db.Dispose();
     }
 }
        public bool Save()
        {
            ClassLibrary.JDataBase db = new ClassLibrary.JDataBase();
//            db.setQuery(@"insert into ShareMessage([Code]
//                                              ,[SenderCode]
//                                              ,[ReceiverCode]
//                                              ,[sDate]
//                                              ,[Title]
//                                              ,[Body]
//                                              ,[Type]) values((select max(code)+1 from ShareMessage)," + WebClassLibrary.SessionManager.Current.MainFrame.CurrentPersonCode + @",
//                                                0
//                                                ,'" + ClassLibrary.JDateTime.FarsiDate(DateTime.Now).ToString() + @"'
//                                                ,'" + txtSubject.Text + @"'
//                                                 ,'" + txtBody.Text + @"',2)");

            db.setQuery(@"insert into ShareMessage([Code]
                            ,[SenderCode]
                            ,[ReceiverCode]
                            ,[sDate]
                            ,[Title]
                            ,[Body]
                            ,[Type])
                            select ROW_NUMBER() over (order by Code)+(select max(code) from ShareMessage)," + WebClassLibrary.SessionManager.Current.MainFrame.CurrentPersonCode + @"
                            ,pcode,'" + ClassLibrary.JDateTime.FarsiDate(DateTime.Now).ToString() + @"'
                            ,'" + txtSubject.Text + @"','" + txtBody.Text + @"',2
                            from users where guide is not null");
            return(db.Query_Execute() >= 0 ? true : false);
        }
Пример #4
0
        public bool Delete(bool isWeb = false)
        {
            if (!ClassLibrary.JPermission.CheckPermission("AVL.RegisterDevice.JRegisterDevice.Delete"))
            {
                return(false);
            }

            ClassLibrary.JDataBase DB = new ClassLibrary.JDataBase();
            DB.setQuery("delete from AVLCoordinate where DeviceCode=" + Code.ToString());
            DB.Query_Execute(true);

            JRegisterDeviceTable AT = new JRegisterDeviceTable();

            AT.SetValueProperty(this);
            if (AT.Delete())
            {
                if (!isWeb)
                {
                    Nodes.Delete(Nodes.CurrentNode);
                }
                ClassLibrary.JHistory jHistory = new ClassLibrary.JHistory();
                jHistory.Save("AVL.RegisterDevice.JRegisterDevice", AT.Code, 0, 0, 0, "حذف دستگاه", "", 0);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
 public void _SetForm()
 {
     if (Code > 0)
     {
         ClassLibrary.JDataBase DB = new ClassLibrary.JDataBase();
         DB.setQuery(@"delete from ShareMessage where code = " + Code);
         DB.Query_Execute();
     }
 }
Пример #6
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ClassLibrary.JDataBase Db = new ClassLibrary.JDataBase();
            if (Code > 0)
            {
                Db.setQuery(@"delete from [EntPicGalleryLvl2] where [Lvl1Code] = " + Code);
                Db.Query_Execute();
                // if ()
                //  {
                Db.setQuery(@"delete from EntPicGalleryLvl1 where Code = " + Code);

                if (Db.Query_Execute() >= 0)
                {
                    WebClassLibrary.JWebManager.RunClientScript("alert('با موفقیت حذف شد');", "OKDialog");
                }
                // }
            }
        }
Пример #7
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     //class not build 2014-06-16
     ClassLibrary.JDataBase db = new ClassLibrary.JDataBase();
     db.setQuery(@"delete from SharePrice where code = " + Code);
     if (db.Query_Execute() >= 0)
     {
         WebClassLibrary.JWebManager.CloseAndRefresh();
     }
 }
Пример #8
0
        public static bool UpdateLinePoints(int LineCode, List <JLinePoint> linePoints, bool isAutoOrderNo, int PathType = 0)
        {
            ClassLibrary.JDataBase db = new ClassLibrary.JDataBase();
            try
            {
                int order = 1;
                db.beginTransaction("linePoints");
                db.setQuery("Delete From AUTFleetLinePoints Where LineCode = " + LineCode + "And PathType = " + PathType);
                db.Query_Execute();
                string sql = @"declare @points table([LineCode] [int],
	                            [Latitude] [decimal](18, 14),
	                            [Longitude] [decimal](18, 14),
	                            [OrderNo] [smallint],
	                            [PathType] [tinyint],
								[DistanceLastPoint] [float] NOT NULL DEFAULT ((0)))"                                 + " \r\n";
                foreach (JLinePoint point in linePoints)
                {
                    sql += @"INSERT INTO @points(LineCode,Latitude,Longitude,OrderNo,PathType) VALUES
                             (" + point.LineCode + ", " + point.Latitude + ", " + point.Longitude + ", " + (isAutoOrderNo == true ? order : point.OrderNo) + ", " + PathType + ") \r\n";
                    order++;
                }
                sql += @"
                    update point2 set [DistanceLastPoint] = dbo.GetDistance2Points(point1.Longitude, point1.Latitude, point2.Longitude, point2.Latitude)
                    from @points point2
                    inner join @points point1 on point1.OrderNo = point2.OrderNo - 1

                    insert into AUTFleetLinePoints
                    select [LineCode], [Latitude], [Longitude], [OrderNo], [PathType], sum([DistanceLastPoint]) over (order by orderno) from @points";
                db.setQuery(sql);
                if (db.Query_Execute() >= 0)
                {
                    db.Commit();
                    return(true);
                }
                db.Rollback("linePoints");
                return(false);
            }
            finally
            {
                db.Dispose();
            }
        }
Пример #9
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     if (Code > 0)
     {
         ClassLibrary.JDataBase Db = new ClassLibrary.JDataBase();
         Db.setQuery(@"delete from [Android_Ground] where Code = " + Code);
         if (Db.Query_Execute() >= 0)
         {
             WebClassLibrary.JWebManager.CloseAndRefresh();
         }
     }
 }
Пример #10
0
        public static bool AddAVL(DataTable pDT, string pErrorCommand)
        {
            if (pDT == null || pDT.Rows.Count == 0)
            {
                return(true);
            }
            string fileName = Guid.NewGuid().ToString();

            BusManagment.Transaction.JTicketTransactions.WriteDataTableToFile(pDT, fileName, false);

            ClassLibrary.JDataBase db = new ClassLibrary.JDataBase();
            int BusSerial             = 0;

            try
            {
                if (pDT.Rows.Count >= 1)
                {
                    int.TryParse(pDT.Rows[0]["BusSerial"].ToString(), out BusSerial);
                }
                if (BusSerial > 0 && BusSerial < 10000)
                {
                    if (semaphore[BusSerial] == null)
                    {
                        semaphore[BusSerial] = new Semaphore(1, 1);
                    }
                    semaphore[BusSerial].WaitOne();
                }
                db.DataTypesName = "dbo.AVLPointList";
                db.setQuery(@"EXEC SP_InsertAUTAvlTransactionWithDataTable @List");
                db.AddParams("@List", pDT);

                db.CommandTimeout = 60 * pDT.Rows.Count;
                db.Query_Execute();
                if (!db.Error)
                {
                    BusManagment.Transaction.JTicketTransactions.Deleted(fileName, false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                if (BusSerial > 0 && BusSerial < 10000)
                {
                    semaphore[BusSerial].Release();
                }
                db.Dispose();
            }
        }
Пример #11
0
 public bool OrderDown(int pCode)
 {
     ClassLibrary.JDataBase DB = new ClassLibrary.JDataBase();
     try
     {
         DB.setQuery("update ReferOrderUsers set Orderd=Orderd-1 where PostCode=" + ClassLibrary.JMainFrame.CurrentPostCode + " and PostCodeUser=" + pCode);
         return(DB.Query_Execute() >= 0);
     }
     finally
     {
         DB.Dispose();
     }
 }
Пример #12
0
 public bool Save()
 {
     if (Code > 0)
     {
         ClassLibrary.JDataBase db = new ClassLibrary.JDataBase();
         db.setQuery(@"update entSharePriceText set Text=N'" + txtText.Text + @"' where Code = " + Code);
         return(db.Query_Execute() >= 0 ? true : false);
     }
     else
     {
         return(false);
     }
 }
Пример #13
0
 public bool Save()
 {
     ClassLibrary.JDataBase Db = new ClassLibrary.JDataBase();
     Db.setQuery(@"UPDATE [dbo].[Andorid_Request]
                     SET [Status] = " + cmbStatus.SelectedItem.Value + @" where Code = " + Code);
     if (Db.Query_Execute() >= 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #14
0
 public bool Save()
 {
     ClassLibrary.JDataBase Db = new ClassLibrary.JDataBase();
     if (Code > 0)
     {
         Db.setQuery(@"UPDATE [dbo].[Android_Ground]
                            SET [Metraj] = N'" + txtMetarj.Text + @"'
                               ,[Abad] = N'" + txtAbad.Text + @"'
                               ,[MogheeyatJoghrafi] = N'" + txtMogheyatJoghrafi.Text + @"'
                               ,[MogheeyatMakani] = N'" + txtMogheyatMakani.Text + @"'
                               ,[Address] = N'" + txtAddress.Text + @"'
                               ,[Sanad] = N'" + txtSanad.Text + @"'
                               ,[TedadShoraka] = N'" + txtTedadeShoraka.Text + @"'
                               ,[Tozihat] = N'" + txtTozihat.Text + @"'
                               ,[Gheymat] = N'" + txtGheymat.Text + @"'
                                where Code = " + Code);
     }
     else
     {
         Db.setQuery(@"INSERT INTO [dbo].[Android_Ground]
                             ([Metraj]
                             ,[Abad]
                             ,[MogheeyatJoghrafi]
                             ,[MogheeyatMakani]
                             ,[Address]
                             ,[Sanad]
                             ,[TedadShoraka]
                             ,[Tozihat]
                             ,[Gheymat])
                         VALUES
                             (N'" + txtMetarj.Text + @"'
                             ,N'" + txtAbad.Text + @"'
                             ,N'" + txtMogheyatJoghrafi.Text + @"'
                             ,N'" + txtMogheyatMakani.Text + @"'
                             ,N'" + txtAddress.Text + @"'
                             ,N'" + txtSanad.Text + @"'
                             ,N'" + txtTedadeShoraka.Text + @"'
                             ,N'" + txtTozihat.Text + @"'
                             ,N'" + txtGheymat.Text + @"')");
     }
     if (Db.Query_Execute() >= 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #15
0
 public bool Save()
 {
     ClassLibrary.JDataBase db = new ClassLibrary.JDataBase();
     db.setQuery(@"insert into ShareMessage([Code]
                                       ,[SenderCode]
                                       ,[ReceiverCode]
                                       ,[sDate]
                                       ,[Title]
                                       ,[Body]
                                       ,[Type]) values((select max(code)+1 from ShareMessage)," + WebClassLibrary.SessionManager.Current.MainFrame.CurrentPersonCode + @",
                                         " + ((WebControllers.MainControls.JCustomListSelectorControl)JSearchPersonControlInstaller).Code + @"
                                         ,'" + ClassLibrary.JDateTime.FarsiDate(DateTime.Now).ToString() + @"'
                                         ,'" + txtSubject.Text + @"'
                                          ,'" + txtBody.Text + @"',2)");
     return(db.Query_Execute() >= 0 ? true : false);
 }
Пример #16
0
 public static void DeleteByGroupName(int pPostCode, string pGroupName)
 {
     ClassLibrary.JDataBase DB = new ClassLibrary.JDataBase();
     try
     {
         DB.setQuery("delete from refGroupname where postCode=" + pPostCode + " and Groupname=N'" + pGroupName + "'");
         DB.Query_Execute();
     }
     catch
     {
     }
     finally
     {
         DB.Dispose();
     }
 }
Пример #17
0
 public bool Proceced(int Code)
 {
     ClassLibrary.JDataBase db = ClassLibrary.JGlobal.MainFrame.GetDBO();
     try
     {
         db.setQuery("UPDATE [AVLArea] SET [IsProceced]='true' WHERE [Code] = " + Code);
         if (db.Query_Execute() >= 0)
         {
             return(true);
         }
         return(false);
     }
     finally
     {
         db.Dispose();
     }
 }
Пример #18
0
 public bool Remove()
 {
     ClassLibrary.JDataBase db = ClassLibrary.JGlobal.MainFrame.GetDBO();
     try
     {
         db.setQuery("DELETE FROM [AVLArea] WHERE [code] = " + this.code + " AND personCode=" + this.personCode);
         if (db.Query_Execute() > 0)
         {
             return(true);
         }
         return(false);
     }
     finally
     {
         db.Dispose();
     }
 }
Пример #19
0
        public bool Save()
        {
            ClassLibrary.JDataBase Db = new ClassLibrary.JDataBase();
            int CuArchiveCode         = 0;

            if (FileUpload.HasFile)
            {
                int ArchiveCode = 0;

                string[] segments = FileUpload.FileName.Split(new char[] { '.' });
                string   fileExt  = segments[segments.Length - 1];

                ArchivedDocuments.JArchiveDocument archive = new ArchivedDocuments.JArchiveDocument(ArchivedDocuments.JConstantArchiveSubjects.ImagesArchiveCode.GetHashCode(), ArchivedDocuments.JConstantArchivePalces.GeneralArchive.GetHashCode());
                ClassLibrary.JFile jFile = new ClassLibrary.JFile();
                jFile.Content   = FileUpload.FileBytes;
                jFile.FileName  = FileUpload.FileName;
                jFile.Extension = ".jpg";

                jFile.FileText = jFile.FileName;

                ArchiveCode = archive.ArchiveDocument(jFile, "AndroidElahiye", WebClassLibrary.SessionManager.Current.MainFrame.CurrentUserCode, "EntPicGalleryLvl1", true);

                CuArchiveCode = ArchiveCode;
            }

            if (Code > 0)
            {
                Db.setQuery(@"update EntPicGalleryLvl1 set Name = N'" + txtTitle.Text + "' ,ArchiveCode=" + CuArchiveCode + " where Code = " + Code);
            }
            else
            {
                Db.setQuery(@"INSERT INTO [EntPicGalleryLvl1] ([Name],[ArchiveCode]) VALUES (N'" + txtTitle.Text + @"'," + CuArchiveCode.ToString() + ") ");
            }

            if (Db.Query_Execute() >= 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #20
0
        public bool Updateit1() //update insert field of database in autbazrasservice for bazrasservicereport
        {
            ClassLibrary.JDataBase DB = new ClassLibrary.JDataBase();
            try
            {
                DB.setQuery(@"
                    update AUTBazRasService Set InsertDate=getdate()
                    where code=" + Code + "");
                DB.Query_Execute();
            }
            finally
            {
                DB.Dispose();
            }
            JBazRasServiceTable BST = new JBazRasServiceTable();

            BST.SetValueProperty(this);
            return(BST.Update());
        }
Пример #21
0
 public bool UpdateDetails(string IMEI, string Factory, string Model, string OsVersion)
 {
     ClassLibrary.JDataBase db = ClassLibrary.JGlobal.MainFrame.GetDBO();
     try
     {
         db.setQuery(string.Format("UPDATE [AVLDevice] SET Factory={0},Model={1},OSVersion={2} WHERE [IMEI] = {3}",
                                   Factory,
                                   Model,
                                   OsVersion,
                                   IMEI));
         if (db.Query_Execute() >= 0)
         {
             return(true);
         }
         return(false);
     }
     finally
     {
         db.Dispose();
     }
 }
Пример #22
0
 public static bool DeleteLinePoints(int LineCode, int PathType = 0)
 {
     ClassLibrary.JDataBase db = new ClassLibrary.JDataBase();
     try
     {
         int order = 1;
         db.beginTransaction("linePointsDel");
         db.setQuery("Delete From AUTFleetLinePoints Where LineCode = " + LineCode + " And PathType = " + PathType);
         if (db.Query_Execute() >= 0)
         {
             db.Commit();
             return(true);
         }
         db.Rollback("linePointsDel");
         return(false);
     }
     finally
     {
         db.Dispose();
     }
 }
Пример #23
0
        public bool Update(bool RefershAgain)
        {
            if (RefershAgain)
            {
                ClassLibrary.JDataBase DB = new ClassLibrary.JDataBase();
                try
                {
                    DB.setQuery(@"delete from AutBusServices where ISOK = 11 and EzamBeCode = " + Code);
                    // exec[SP_UpdateBazrasService] '" + MoveDate.ToString("yyyy-MM-dd") + "'");
                    DB.Query_Execute(true);
                }
                catch
                {
                }
                finally
                {
                    // DB.Dispose();
                }
            }
            else
            {
                ClassLibrary.JDataBase DB = new ClassLibrary.JDataBase();
                try
                {
                    DB.setQuery(@"delete from AutBusServices where ISOK = 11 and  EzamBeCode = " + Code);
                    DB.Query_Execute(true);
                }
                catch
                {
                }
                finally
                {
                    // DB.Dispose();
                }
            }
            JBazRasServiceTable BST = new JBazRasServiceTable();

            BST.SetValueProperty(this);
            return(BST.Update());
        }
Пример #24
0
 public static bool Set(string KeyName, object KeyValue)
 {
     ClassLibrary.JDataBase db = new ClassLibrary.JDataBase();
     try
     {
         db.setQuery("Select * from AUTSettings Where KeyName = N'" + KeyName + "'");
         if (db.Query_DataReader() && db.DataReader.Read())
         {
             db.setQuery("Update AUTSettings SET KeyValue = N'" + KeyValue + "' Where KeyName=N'" + KeyName + "'");
         }
         else
         {
             db.setQuery("Insert into AUTSettings (KeyName, KeyValue) VALUES(N'" + KeyName + "', N'" + KeyValue + "')");
         }
         db.DataReader.Close();
         return(db.Query_Execute() >= 0 ? true : false);
     }
     finally
     {
         db.Dispose();
     }
 }
Пример #25
0
        public bool Update()
        {
            //JPersonAddressTable addressTable = new JPersonAddressTable();
            //addressTable.SetValueProperty(this);
            //return addressTable.Update();
            ClassLibrary.JDataBase db = ClassLibrary.JGlobal.MainFrame.GetDBO();
            try
            {
                db.setQuery(@"UPDATE AVLUserVarify SET
                email=@email , phonenumber = @phonenumber, phoneVarified = @phoneVarified, emailVarified = @emailVarified 
 WHERE userID=@userID");
                db.AddParams("@email", this.email);
                db.AddParams("@phonenumber", this.phonenumber);
                db.AddParams("@phoneVarified", this.phoneVarified);
                db.AddParams("@emailVarified", this.emailVarified);
                db.AddParams("@userID", this.userID);
                db.beginTransaction("UpdateAVLUserVarify");
                if (db.Query_Execute() > -1)
                {
                    if (db.Commit())
                    {
                        return(true);
                    }
                }
                db.Rollback("UpdateAVLUserVarify");
                return(false);
            }
            catch (Exception ex)
            {
                ClassLibrary.JSystem.Except.AddException(ex);
                db.Rollback("UpdateAVLUserVarify");
                return(false);
            }
            finally
            {
                db.Dispose();
            }
        }
Пример #26
0
        public static bool DistanceMeasurement(ClassLibrary.JDataBase db)
        {
            double Distance = 0;

            try
            {
                if (db.datatable != null)
                {
                    db.datatable.Clear();
                }
                db.setQuery(@"SELECT TOP 1 BusCode,[Date]EDate FROM dbo.AUTDailyAvlPerformanceRportOnBus 
                                WHERE IsProceced = 0 --AND [Date] < Cast(GETDATE() AS Date)
                                GROUP BY BusCode,[Date]
                                ORDER BY BusCode,EDate");
                DataTable Dt = db.Query_DataTable();
                if (Dt != null)
                {
                    if (Dt.Rows.Count > 0)
                    {
                        db.setQuery(@"SELECT EventDate,Latitude,Longitude FROM dbo.AUTAvlTransaction 
                                        WHERE BusCode = " + Dt.Rows[0]["BusCode"].ToString() + @" AND
                                              CAST(EventDate AS DATE) = cast('" + Dt.Rows[0]["EDate"].ToString() + @"' as Date)
                                        GROUP BY EventDate,Latitude,Longitude
                                        ORDER BY EventDate");
                        DataTable DtTransactions = db.Query_DataTable();
                        if (DtTransactions != null)
                        {
                            if (DtTransactions.Rows.Count > 1)
                            {
                                Distance = GetDistance(DtTransactions, MeasureUnits.Kilometers);
                                db.setQuery(@"Update [dbo].[AUTDailyAvlPerformanceRportOnBus] set [IsProceced] = 1,[Distance] = " + Distance.ToString() + @"
                                                        ,[ProcessDate] = getdate()
                                                        where BusCode = " + Dt.Rows[0]["BusCode"].ToString() + @" and [Date] = cast('"
                                            + Dt.Rows[0]["EDate"].ToString() + @"' as date)");
                                db.Query_Execute();
                                return(true);
                            }
                            else
                            {
                                if (DtTransactions.Rows.Count == 1)
                                {
                                    db.setQuery(@"Update [dbo].[AUTDailyAvlPerformanceRportOnBus] set [IsProceced] = 1,[Distance] = 0,[ProcessDate] = getdate()
                                                        where BusCode = " + Dt.Rows[0]["BusCode"].ToString() + @" and [Date] = cast('"
                                                + Dt.Rows[0]["EDate"].ToString() + @"' as date)");
                                    db.Query_Execute();
                                }
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
Пример #27
0
        public static bool AddAVL(TransactionPublic.JTransactionAVLHeader AH, TransactionPublic.JTransactionAVL AVL, Int64 recordNumber, string Header_IMEI, float Header_BusSerial, byte[] Header_Version, ClassLibrary.JDataBase db)
        {
            if (db == null || AH == null || AVL == null)
            {
                return(false);
            }
            db.Params.Clear();
            if (db.Params.Count > 0)
            {
                try
                {
                    db.Params.Remove("Longitude");
                    db.Params.Remove("Latitude");
                    db.Params.Remove("Altitude");
                    db.Params.Remove("Speed");
                    db.Params.Remove("Course");
                    db.Params.Remove("EventDate");
                    db.Params.Remove("SimCardCharge");
                    db.Params.Remove("BusSerial");
                    db.Params.Remove("IMEI");
                    db.Params.Remove("Version");
                    db.Params.Remove("BatteryCharge");
                    db.Params.Remove("GpsAnt");
                    db.Params.Remove("GsmAnt");
                    db.Params.Remove("recordNumber");
                    db.Params.Remove("TransactionID");
                    db.Params.Remove("Dir");
                }
                catch
                {
                }
            }

            DateTime dtemp;
            string   date = (new DateTime(AH.DATE.Year, AH.DATE.Month, AH.DATE.Day, AVL.Time[0], AVL.Time[1], AVL.Time[2])).ToString("yyyy-MM-dd HH:mm:ss");

            if (DateTime.TryParse(date, out dtemp) & AH.DATE.Year >= 2015)
            {
            }
            else
            {
                date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            }
            db.setQuery(@"EXEC SP_InsertAUTAvlTransaction_Zarrin_Save_Just_Point
	                    @Longitude,
	                    @Latitude,
	                    @Altitude,
	                    @Speed,
	                    @Course,
	                    @EventDate,
	                    @SimCardCharge,
	                    @BusSerial,
	                    @IMEI,
	                    @Version,
	                    @BatteryCharge,
	                    @GpsAnt,
	                    @GsmAnt,
	                    @recordNumber,
	                    @TransactionID,
                        @Dir");
            db.AddParams("Longitude", AVL.Lon);
            db.AddParams("Latitude", AVL.Lat);
            db.AddParams("Altitude", AVL.Alt.ToString());
            db.AddParams("Speed", AVL.Speed.ToString());
            db.AddParams("Course", AVL.Cource.ToString());
            db.AddParams("EventDate", date);
            db.AddParams("SimCardCharge", AH.SimCharge.ToString());
            db.AddParams("BusSerial", AH.busSerial.ToString());
            db.AddParams("IMEI", Header_IMEI.ToString());
            db.AddParams("Version", Header_Version);
            db.AddParams("BatteryCharge", AH.Battryvoltvalue.ToString());
            db.AddParams("GpsAnt", AH.GpsAnttena.ToString());
            db.AddParams("GsmAnt", AH.GsmAnttena.ToString());
            db.AddParams("recordNumber", recordNumber.ToString());
            db.AddParams("TransactionID", AVL.transactionid.ToString());
            db.AddParams("Dir", AVL.Dir.ToString());
            db.CommandTimeout = 60;
            if (db.Query_Execute() >= 0)
            {
                db.Params.Clear();
                return(true);
            }
            return(true);
        }
Пример #28
0
        public bool Save()
        {
            ClassLibrary.JDataBase Db = new ClassLibrary.JDataBase();

            int CuArchiveCode = 0;

            if (FileUpload.HasFile)
            {
                int ArchiveCode = 0;

                string[] segments = FileUpload.FileName.Split(new char[] { '.' });
                string   fileExt  = segments[segments.Length - 1];

                ArchivedDocuments.JArchiveDocument archive = new ArchivedDocuments.JArchiveDocument(ArchivedDocuments.JConstantArchiveSubjects.ImagesArchiveCode.GetHashCode(), ArchivedDocuments.JConstantArchivePalces.GeneralArchive.GetHashCode());
                ClassLibrary.JFile jFile = new ClassLibrary.JFile();
                jFile.Content   = FileUpload.FileBytes;
                jFile.FileName  = FileUpload.FileName;
                jFile.Extension = ".jpg";

                jFile.FileText = jFile.FileName;

                ArchiveCode = archive.ArchiveDocument(jFile, "AndroidElahiye", WebClassLibrary.SessionManager.Current.MainFrame.CurrentUserCode, "EntProjects", true);

                CuArchiveCode = ArchiveCode;
            }

            if (Code > 0)
            {
                Db.setQuery(@"Update [dbo].[Android_Apartments] Set 
                                           [ProjectName] = N'" + txtTitle.Text + @"' , 
                                           [Metraj] = N'" + txtMetraj.Text + @"' , 
                                           [TedadeVahed] = N'" + txtTedadVahed.Text + @"' , 
                                           [TedadKhab] = N'" + txtTedadKhab.Text + @"' , 
                                           [ShomareVahed] = N'" + txtShomareVahed.Text + @"' , 
                                           [Tabaghe] = N'" + txtTabaghe.Text + @"' , 
                                           [Emkanat] = N'" + txtEmkanat.Text + @"' , 
                                           [Gheymat] = N'" + txtGheymat.Text + @"' 
                                            ,ArchiveCode=" + CuArchiveCode + @"
                                           where Code = " + Code);
            }
            else
            {
                Db.setQuery(@"INSERT INTO [dbo].[Android_Apartments]
                               ([ProjectName]
                               ,[Metraj]
                               ,[TedadeVahed]
                               ,[TedadKhab]
                               ,[ShomareVahed]
                               ,[Tabaghe]
                               ,[Emkanat]
                               ,[Gheymat],ArchiveCode)
                         VALUES
                               (N'" + txtTitle.Text + @"'
                               ,N'" + txtMetraj.Text + @"'
                               ,N'" + txtTedadVahed.Text + @"'
                               ,N'" + txtTedadKhab.Text + @"'
                               ,N'" + txtShomareVahed.Text + @"'
                               ,N'" + txtTabaghe.Text + @"'
                               ,N'" + txtEmkanat.Text + @"'
                               ,N'" + txtGheymat.Text + @"'," + CuArchiveCode + @")");
            }
            if (Db.Query_Execute() >= 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #29
0
        public static bool AddAVL(Transaction.JTransactionAVLHeader AH, Transaction.JTransactionAVL AVL, Int64 recordNumber, string Header_IMEI, float Header_BusSerial, byte[] Header_Version, ClassLibrary.JDataBase pdb, string pErrorCommand)
        {
            if (AH == null || AVL == null)
            {
                return(false);
            }

            ClassLibrary.JDataBase db = new ClassLibrary.JDataBase();
            db.Params.Clear();
            //if(AH.busSerial == 2122)
            //    db.Params.Clear();
            if (db.Params.Count > 0)
            {
                try
                {
                    db.Params.Remove("Longitude");
                    db.Params.Remove("Latitude");
                    db.Params.Remove("Altitude");
                    db.Params.Remove("Speed");
                    db.Params.Remove("Course");
                    db.Params.Remove("EventDate");
                    db.Params.Remove("SimCardCharge");
                    db.Params.Remove("BusSerial");
                    db.Params.Remove("IMEI");
                    db.Params.Remove("Version");
                    db.Params.Remove("BatteryCharge");
                    db.Params.Remove("GpsAnt");
                    db.Params.Remove("GsmAnt");
                    db.Params.Remove("recordNumber");
                    db.Params.Remove("TransactionID");
                    db.Params.Remove("Dir");
                    db.Params.Remove("BusLine");
                }
                catch
                {
                }
            }

            string date = (new DateTime(AH.DATE.Year, AH.DATE.Month, AH.DATE.Day, AVL.Time[0], AVL.Time[1], AVL.Time[2])).ToString("yyyy-MM-dd HH:mm:ss");

            db.setQuery(@"EXEC SP_InsertAUTAvlTransaction_Zarrin_Save_Just_Point
	                    @Longitude,
	                    @Latitude,
	                    @Altitude,
	                    @Speed,
	                    @Course,
	                    @EventDate,
	                    @SimCardCharge,
	                    @BusSerial,
	                    @IMEI,
	                    @Version,
	                    @BatteryCharge,
	                    @GpsAnt,
	                    @GsmAnt,
	                    @recordNumber,
	                    @TransactionID,
                        @Dir,
                        @BusLine");
            db.AddParams("Longitude", AVL.Lon);
            db.AddParams("Latitude", AVL.Lat);
            db.AddParams("Altitude", AVL.Alt.ToString());
            db.AddParams("Speed", AVL.Speed.ToString());
            db.AddParams("Course", AVL.Cource.ToString());
            db.AddParams("EventDate", date);
            db.AddParams("SimCardCharge", AH.SimCharge.ToString());
            db.AddParams("BusSerial", AH.busSerial.ToString());
            db.AddParams("IMEI", Header_IMEI.ToString());
            db.AddParams("Version", Header_Version);
            db.AddParams("BatteryCharge", AH.Battryvoltvalue.ToString());
            db.AddParams("GpsAnt", AH.GpsAnttena.ToString());
            db.AddParams("GsmAnt", AH.GsmAnttena.ToString());
            db.AddParams("recordNumber", recordNumber.ToString());
            db.AddParams("TransactionID", AVL.transactionid.ToString());
            db.AddParams("Dir", AVL.Dir.ToString());
            db.AddParams("BusLine", AH.busLine.ToString());
            DataTable dt;

            try
            {
                db.CommandTimeout = 60;
                db.Query_Execute(true, pErrorCommand, false);
                //db.Dispose();
                return(true);
                //dt = db.Query_DataTable();
                //if (dt != null && dt.Rows.Count > 0 && Convert.ToInt32(dt.Rows[0][0]) > 0)
                //{
                //    db.Params.Clear();
                //    return true;
                //}
                //else
                //    return false;
            }
            catch (Exception ex)
            {
                return(false);
            }
        }