using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Entity;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Management;
using System.Media;
using System.Net;
using System.Net.Mail;
using System.Net.NetworkInformation;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using DevExpress.DataAccess.EntityFramework;
using DevExpress.DataAccess.Sql;
using DevExpress.Utils;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports;
using DevExpress.XtraReports.Parameters;
using DevExpress.XtraReports.UI;
using DevExpress.XtraSplashScreen;
using Microsoft.Win32;
using MrSales;
using MrSales.MrSControls;
using MrSales.MrSControls.E_Invoices;
using MrSales.MrSLanguages;
using MrSales.MrSModels;
using MrSales.MrSModels.dataObjects;
using MrSales.MrSReports;
using MrSales.MrSReports.R_Bonds;
using MrSales.MrSReports.R_Purchases;
using MrSales.MrSReports.R_Sales;
using MrSales.MrSViews;
using MrSales.MrSViews.Decomentations;
using MrSales.Properties;
using MySql.Data.MySqlClient;
using Newtonsoft.Json.Linq;
using WMPLib;

internal class Class67
{
	public static Font smethod_0()
	{
		Font result = new Font(Class60.string_0, (float)Class60.int_0);
		string languages = BasicVars.Languages;
		if (languages == "en")
		{
			result = new Font(Class60.string_0, (float)Class60.int_0);
		}
		else if (languages == "ar-EG")
		{
			result = new Font(Class60.string_1, (float)Class60.int_1);
		}
		return result;
	}

	public static void smethod_1(object object_0)
	{
		object_0.FormBorderStyle = FormBorderStyle.None;
		object_0.Top = 0;
		object_0.Left = 0;
		object_0.Width = Screen.PrimaryScreen.WorkingArea.Width;
		object_0.Height = Screen.PrimaryScreen.WorkingArea.Height;
	}

	public static string smethod_2()
	{
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(executingAssembly.Location);
		return versionInfo.FileVersion;
	}

	public static void smethod_3(string string_0)
	{
		if (!PathingVars.UpdatesInProgress)
		{
			Form parentForm = new Form();
			SplashScreenManager.ShowForm(parentForm, typeof(waitForm), true, true, false);
			try
			{
				SplashScreenManager.Default.SetWaitFormDescription(string.Format(strings.APPLY_IMPROVEMENTS, " " + string_0 + " ..."));
			}
			catch
			{
			}
			Thread.Sleep(1000);
			try
			{
				SplashScreenManager.Default.SetWaitFormDescription(string.Format(strings.PLEASE_WAIT, " 3 "));
			}
			catch
			{
			}
			Thread.Sleep(1000);
			try
			{
				SplashScreenManager.Default.SetWaitFormDescription(string.Format(strings.PLEASE_WAIT, " 2 "));
			}
			catch
			{
			}
			Thread.Sleep(1000);
			try
			{
				SplashScreenManager.Default.SetWaitFormDescription(string.Format(strings.PLEASE_WAIT, " 1 "));
			}
			catch
			{
			}
			Thread.Sleep(1000);
			try
			{
				SplashScreenManager.Default.SetWaitFormDescription(string.Format(strings.Updating_in_progress, " 1 "));
			}
			catch
			{
			}
			try
			{
				if (Settings.Default.UpgradeRequired)
				{
					Settings.Default.Upgrade();
					Settings.Default.UpgradeRequired = false;
					Settings.Default.Save();
				}
			}
			catch (Exception e)
			{
				LogWriter.errLog("Upgrade proprties file", e);
			}
		}
		PathingVars.UpdatesInProgress = true;
	}

	public static void smethod_4(string string_0)
	{
		Class67.smethod_32(string_0);
	}

	public static PopupFilterMode smethod_5(int int_0 = 0)
	{
		PopupFilterMode result = PopupFilterMode.Default;
		try
		{
			switch (int_0)
			{
			case 0:
				result = ((Settings.Default.items_PopupFilterMode == 0) ? PopupFilterMode.Default : ((Settings.Default.items_PopupFilterMode == 1) ? PopupFilterMode.Contains : PopupFilterMode.StartsWith));
				break;
			case 1:
				result = ((Settings.Default.people_PopupFilterMode == 0) ? PopupFilterMode.Default : ((Settings.Default.people_PopupFilterMode == 1) ? PopupFilterMode.Contains : PopupFilterMode.StartsWith));
				break;
			case 2:
				result = ((Settings.Default.emp_PopupFilterMode == 0) ? PopupFilterMode.Default : ((Settings.Default.emp_PopupFilterMode == 1) ? PopupFilterMode.Contains : PopupFilterMode.StartsWith));
				break;
			}
		}
		catch (Exception e)
		{
			LogWriter.errLog("Get Filter Mode", e);
		}
		return result;
	}

	public static bool smethod_6()
	{
		using (ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher("Select * from Win32_ComputerSystem"))
		{
			using (ManagementObjectCollection managementObjectCollection = managementObjectSearcher.Get())
			{
				foreach (ManagementBaseObject managementBaseObject in managementObjectCollection)
				{
					string text = managementBaseObject["Manufacturer"].ToString().ToLower();
					if ((text == "microsoft corporation" && managementBaseObject["Model"].ToString().ToUpperInvariant().Contains("VIRTUAL")) || text.Contains("vmware") || managementBaseObject["Model"].ToString() == "VirtualBox")
					{
						return true;
					}
				}
			}
		}
		return false;
	}

	public static bool smethod_7()
	{
		string text = File.ReadAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "drivers/etc/hosts"));
		return text.Contains("vatoce.com") || text.Contains("www.vatoce.com");
	}

	public static async void smethod_8(int int_0, string string_0, string string_1 = "", int int_1 = 0, DateTime? nullable_0 = null)
	{
		if (nullable_0 != null)
		{
			nullable_0 = nullable_0;
		}
		else
		{
			nullable_0 = new DateTime?(DateTime.Now);
		}
		if (int_0 == 1 || int_0 == 2 || int_0 == 3)
		{
		}
		int QueryExcuteStatus = 0;
		if (int_0 == 0 && BasicVars.OCP_Show != 0)
		{
			QueryExcuteStatus = 1;
		}
		else if (int_0 != 1 || BasicVars.OCP_Insert == 0)
		{
			if (int_0 != 2 || BasicVars.OCP_Update == 0)
			{
				if (int_0 != 3 || BasicVars.OCP_Delete == 0)
				{
					if (int_0 == 4 && BasicVars.OCP_Print != 0)
					{
						QueryExcuteStatus = 1;
					}
				}
				else
				{
					QueryExcuteStatus = 1;
				}
			}
			else
			{
				QueryExcuteStatus = 1;
			}
		}
		else
		{
			QueryExcuteStatus = 1;
		}
		if (QueryExcuteStatus == 1)
		{
			mrsalesdbEntities MrSalesContext = ConnectionTools.OpenConn();
			MrSalesContext.ad_operations.Add(new ad_operations
			{
				ado_OperationName = string_0,
				ado_Date = nullable_0,
				ado_Status = new int?(1),
				Operation_Type = string_1,
				Operation_ID = new int?(int_1),
				r_user_ID = new int?(BasicVars.UserID),
				r_branche_ID = new int?(BasicVars.Branche),
				r_device_ID = new int?(BasicVars.Device),
				shift = new int?(BasicVars.Shift)
			});
			MrSalesContext.SaveChanges();
			MrSalesContext = null;
		}
	}

	public static void smethod_9(int int_0, string string_0, string string_1, int int_1, DateTime dateTime_0, DateTime dateTime_1, int int_2, decimal decimal_0, decimal decimal_1, decimal decimal_2, decimal decimal_3, string string_2)
	{
		mrsalesdbEntities mrsalesdbEntities = ConnectionTools.OpenConn();
		IQueryable<invoices_notices> source = from u in mrsalesdbEntities.invoices_notices
		where u.invoice_type == string_0 && u.mainID == (int?)int_1
		select u;
		if (source.Count<invoices_notices>() > 0)
		{
			dateTime_0 = (from o in source
			orderby o.id
			select o).FirstOrDefault<invoices_notices>().createdDate.Value;
			decimal value = (from o in source
			orderby o.id descending
			select o).FirstOrDefault<invoices_notices>().netvalue.Value;
			decimal value2 = (from o in source
			orderby o.id descending
			select o).FirstOrDefault<invoices_notices>().taxvlaue.Value;
			if (string_0 == "SALES")
			{
				if (string_1 == "UPDATE_SALES_INVOICE")
				{
					int_0 = ((value > decimal_0) ? 1 : 0);
				}
				else if (string_1 == "RETURN_ITEM")
				{
					int_0 = 1;
					decimal_0 = value - decimal_0;
					decimal_1 = value2 - decimal_1;
				}
			}
		}
		invoices_notices invoices_notices = new invoices_notices();
		invoices_notices.notice_type = new sbyte?((sbyte)int_0);
		invoices_notices.invoice_type = string_0;
		invoices_notices.reason = string_1;
		invoices_notices.mainID = new int?(int_1);
		invoices_notices.createdDate = new DateTime?(dateTime_0);
		invoices_notices.updateDate = new DateTime?(dateTime_1);
		invoices_notices.status = new sbyte?((sbyte)int_2);
		invoices_notices.netvalue = new decimal?(decimal_0);
		invoices_notices.taxvlaue = new decimal?(decimal_1);
		invoices_notices.paidvalue = new decimal?(decimal_2);
		invoices_notices.resetvalue = new decimal?(decimal_3);
		invoices_notices.itemsnotes = string_2;
		invoices_notices.r_branche_ID = new int?(BasicVars.Branche);
		invoices_notices.r_device_ID = new int?(BasicVars.Device);
		invoices_notices.r_user_ID = new int?(BasicVars.UserID);
		invoices_notices.r_shift_ID = new int?(BasicVars.Shift);
		mrsalesdbEntities.invoices_notices.Add(invoices_notices);
		mrsalesdbEntities.SaveChanges();
	}

	public static IEnumerable<FileInfo> smethod_10(DirectoryInfo directoryInfo_0, params string[] extensions)
	{
		Class67.<>c__DisplayClass10_0 CS$<>8__locals1 = new Class67.<>c__DisplayClass10_0();
		CS$<>8__locals1.string_0 = extensions;
		if (CS$<>8__locals1.string_0 == null)
		{
			throw new ArgumentNullException("extensions");
		}
		IEnumerable<FileInfo> source = directoryInfo_0.EnumerateFiles();
		return source.Where(new Func<FileInfo, bool>(CS$<>8__locals1.method_0));
	}

	public static void smethod_11(string string_0)
	{
		try
		{
			if (checkWavFile.isWave(string_0))
			{
				SoundPlayer soundPlayer = new SoundPlayer(string_0);
				soundPlayer.Play();
			}
			else
			{
				WindowsMediaPlayer windowsMediaPlayer = (WindowsMediaPlayer)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("6BF52A52-394A-11D3-B153-00C04F79FAA6")));
				windowsMediaPlayer.URL = string_0;
				windowsMediaPlayer.controls.play();
			}
		}
		catch
		{
		}
	}

	public static string smethod_12()
	{
		string result = "";
		using (System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog())
		{
			openFileDialog.Filter = "wav files (*.wav)|*.wav";
			openFileDialog.FilterIndex = 2;
			openFileDialog.RestoreDirectory = true;
			if (openFileDialog.ShowDialog() == DialogResult.OK)
			{
				result = openFileDialog.FileName;
			}
		}
		return result;
	}

	public static decimal smethod_13(object object_0, int int_0, int int_1, DateTime dateTime_0)
	{
		Class67.<>c__DisplayClass13_0 CS$<>8__locals1 = new Class67.<>c__DisplayClass13_0();
		CS$<>8__locals1.int_0 = int_1;
		CS$<>8__locals1.dateTime_0 = dateTime_0;
		CS$<>8__locals1.nullable_0 = new int?[]
		{
			new int?(MainAccountsIDs.CUSTOMERS),
			new int?(MainAccountsIDs.VENDOR),
			new int?(MainAccountsIDs.MixPeople)
		};
		mrsalesdbEntities mrsalesdbEntities = ConnectionTools.OpenConn();
		ParameterExpression parameterExpression;
		List<Class44> list = (from u in mrsalesdbEntities.view_accounts_allrecords
		where CS$<>8__locals1.nullable_0.Contains(u.accitem_AccID) && u.accitem_PeplID == (int?)CS$<>8__locals1.int_0
		select u).Select(Expression.Lambda<Func<view_accounts_allrecords, Class44>>(Expression.MemberInit(Expression.New(typeof(Class44)), new MemberBinding[]
		{
			Expression.Bind(methodof(Class44.set_accitem_AccID(int?)), Expression.Property(parameterExpression, methodof(view_accounts_allrecords.get_accitem_AccID()))),
			Expression.Bind(methodof(Class44.set_accm_ID(int?)), Expression.Property(parameterExpression, methodof(view_accounts_allrecords.get_accm_ID()))),
			Expression.Bind(methodof(Class44.set_accitem_PeplID(int?)), Expression.Property(parameterExpression, methodof(view_accounts_allrecords.get_accitem_PeplID()))),
			Expression.Bind(methodof(Class44.set_accitem_DealType(string)), Expression.Property(parameterExpression, methodof(view_accounts_allrecords.get_accitem_DealType()))),
			Expression.Bind(methodof(Class44.set_accitem_DealID(int?)), Expression.Property(parameterExpression, methodof(view_accounts_allrecords.get_accitem_DealID()))),
			Expression.Bind(methodof(Class44.set_currID(int?)), Expression.Property(parameterExpression, methodof(view_accounts_allrecords.get_SecCurrency_ID()))),
			Expression.Bind(methodof(Class44.set_accitem_Debit(decimal?)), Expression.Property(parameterExpression, methodof(view_accounts_allrecords.get_accitem_Debit_SecCurrency()))),
			Expression.Bind(methodof(Class44.set_accitem_Credit(decimal?)), Expression.Property(parameterExpression, methodof(view_accounts_allrecords.get_accitem_Credit_SecCurrency()))),
			Expression.Bind(methodof(Class44.set_accitem_Date(DateTime?)), Expression.Property(parameterExpression, methodof(view_accounts_allrecords.get_accitem_Date()))),
			Expression.Bind(methodof(Class44.set_pepole_Name(string)), Expression.Property(parameterExpression, methodof(view_accounts_allrecords.get_pepole_Name())))
		}), new ParameterExpression[]
		{
			parameterExpression
		})).ToList<Class44>();
		using (List<Class44>.Enumerator enumerator = list.GetEnumerator())
		{
			while (enumerator.MoveNext())
			{
				Class67.<>c__DisplayClass13_1 CS$<>8__locals2 = new Class67.<>c__DisplayClass13_1();
				CS$<>8__locals2.class44_0 = enumerator.Current;
				decimal value = AddationalCurrencies.usedCurrencies.Where(new Func<ad_additional_currencies, bool>(CS$<>8__locals2.method_0)).FirstOrDefault<ad_additional_currencies>().value.Value;
				CS$<>8__locals2.class44_0.accitem_Debit = new decimal?((CS$<>8__locals2.class44_0.accitem_Debit * value).Value.GetDecimalParts(false, 0));
				CS$<>8__locals2.class44_0.accitem_Credit = new decimal?((CS$<>8__locals2.class44_0.accitem_Credit * value).Value.GetDecimalParts(false, 0));
			}
		}
		decimal result;
		try
		{
			decimal d = list.Where(new Func<Class44, bool>(CS$<>8__locals1.method_0)).Sum(new Func<Class44, decimal>(Class67.<>c.<>c_0.method_0));
			decimal d2 = list.Where(new Func<Class44, bool>(CS$<>8__locals1.method_1)).Sum(new Func<Class44, decimal>(Class67.<>c.<>c_0.method_1));
			result = (d - d2).GetDecimalParts(false, 0);
		}
		catch (Exception)
		{
			result = 0m;
		}
		return result;
	}

	public static view_customers_balance smethod_14(int int_0)
	{
		view_customers_balance view_customers_balance = new view_customers_balance();
		try
		{
			int?[] array = new int?[]
			{
				new int?(MainAccountsIDs.CUSTOMERS),
				new int?(MainAccountsIDs.VENDOR),
				new int?(MainAccountsIDs.MixPeople)
			};
			CurrencyInfo.currencyShortcut();
			mrsalesdbEntities mrsalesdbEntities = ConnectionTools.OpenConn();
			ParameterExpression parameterExpression;
			Class57 @class = (from u in mrsalesdbEntities.view_customers_balance
			where u.pepole_ID == int_0
			select u into s
			group s by new
			{
				s.pepole_ID
			}).Select(Expression.Lambda(Expression.MemberInit(Expression.New(typeof(Class57)), new MemberBinding[]
			{
				Expression.Bind(methodof(Class57.set_pepole_ID(int)), Expression.Property(Expression.Property(parameterExpression, methodof(IGrouping<<>f__AnonymousType6<int>, view_customers_balance>.get_Key())), methodof(<>f__AnonymousType6<int>.get_pepole_ID()))),
				Expression.Bind(methodof(Class57.set_credit(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
				{
					parameterExpression,
					(view_customers_balance f) => f.credit * (decimal?)f.Factor.Value
				})),
				Expression.Bind(methodof(Class57.set_debit(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
				{
					parameterExpression,
					(view_customers_balance f) => f.debit * (decimal?)f.Factor.Value
				})),
				Expression.Bind(methodof(Class57.set_balance(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
				{
					parameterExpression,
					(view_customers_balance f) => f.balance * (decimal?)f.Factor.Value
				}))
			}), new ParameterExpression[]
			{
				parameterExpression
			})).FirstOrDefault<Class57>();
			view_customers_balance.balance = new decimal?(@class.balance.Value.GetDecimalParts(false, 0));
			view_customers_balance.credit = new decimal?(@class.credit.Value.GetDecimalParts(false, 0));
			view_customers_balance.debit = new decimal?(@class.debit.Value.GetDecimalParts(false, 0));
		}
		catch (Exception)
		{
			view_customers_balance.balance = new decimal?(0m);
			view_customers_balance.credit = new decimal?(0m);
			view_customers_balance.debit = new decimal?(0m);
		}
		return view_customers_balance;
	}

	public static List<view_customers_balance> smethod_15(int int_0)
	{
		List<view_customers_balance> result = new List<view_customers_balance>();
		try
		{
			int?[] array = new int?[]
			{
				new int?(MainAccountsIDs.CUSTOMERS),
				new int?(MainAccountsIDs.VENDOR),
				new int?(MainAccountsIDs.MixPeople)
			};
			CurrencyInfo.currencyShortcut();
			mrsalesdbEntities mrsalesdbEntities = ConnectionTools.OpenConn();
			ParameterExpression parameterExpression;
			List<Class57> list = (from u in mrsalesdbEntities.view_customers_balance
			where u.pepole_ID == int_0
			select u into s
			group s by new
			{
				s.pepole_ID,
				s.Currency_ID,
				s.Currency_Index,
				s.Factor
			}).Select(Expression.Lambda(Expression.MemberInit(Expression.New(typeof(Class57)), new MemberBinding[]
			{
				Expression.Bind(methodof(Class57.set_pepole_ID(int)), Expression.Property(Expression.Property(parameterExpression, methodof(IGrouping<<>f__AnonymousType7<int, int?, int?, decimal?>, view_customers_balance>.get_Key())), methodof(<>f__AnonymousType7<int, int?, int?, decimal?>.get_pepole_ID()))),
				Expression.Bind(methodof(Class57.set_Currency_ID(int?)), Expression.Property(Expression.Property(parameterExpression, methodof(IGrouping<<>f__AnonymousType7<int, int?, int?, decimal?>, view_customers_balance>.get_Key())), methodof(<>f__AnonymousType7<int, int?, int?, decimal?>.get_Currency_ID()))),
				Expression.Bind(methodof(Class57.set_Currency_Index(int?)), Expression.Property(Expression.Property(parameterExpression, methodof(IGrouping<<>f__AnonymousType7<int, int?, int?, decimal?>, view_customers_balance>.get_Key())), methodof(<>f__AnonymousType7<int, int?, int?, decimal?>.get_Currency_Index()))),
				Expression.Bind(methodof(Class57.set_credit(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
				{
					parameterExpression,
					(view_customers_balance f) => f.credit
				})),
				Expression.Bind(methodof(Class57.set_debit(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
				{
					parameterExpression,
					(view_customers_balance f) => f.debit
				})),
				Expression.Bind(methodof(Class57.set_balance(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
				{
					parameterExpression,
					(view_customers_balance f) => f.balance
				}))
			}), new ParameterExpression[]
			{
				parameterExpression
			})).ToList<Class57>();
			list.Count<Class57>();
			foreach (Class57 @class in list)
			{
				int id = AddationalCurrencies.usedCurrencies.Where(new Func<ad_additional_currencies, bool>(Class67.<>c.<>c_0.method_2)).FirstOrDefault<ad_additional_currencies>().id;
				int currID = (@class.Currency_ID == null) ? id : @class.Currency_ID.Value;
				if (@class.Currency_ID != null)
				{
					int value = @class.Currency_Index.Value;
				}
				@class.credit = new decimal?(@class.credit.Value.GetDecimalParts(false, currID));
				@class.debit = new decimal?(@class.debit.Value.GetDecimalParts(false, currID));
				@class.balance = new decimal?(@class.balance.Value.GetDecimalParts(false, currID));
			}
			result = list.Select(new Func<Class57, view_customers_balance>(Class67.<>c.<>c_0.method_3)).ToList<view_customers_balance>();
		}
		catch (Exception ex)
		{
			MessageBox.Show(ex.Message.ToString());
		}
		return result;
	}

	public static string smethod_16(int int_0)
	{
		string text = "";
		foreach (view_customers_balance view_customers_balance in Class67.smethod_15(int_0))
		{
			text += ((text != "") ? " ," : "");
			ad_additional_currencies ad_additional_currencies = AddationalCurrencies.usedCurrencies.Where(new Func<ad_additional_currencies, bool>(Class67.<>c.<>c_0.method_4)).FirstOrDefault<ad_additional_currencies>();
			decimal value = view_customers_balance.balance.Value;
			int int_ = (view_customers_balance.Currency_ID != null) ? view_customers_balance.Currency_ID.Value : ad_additional_currencies.id;
			int id = (view_customers_balance.Currency_Index == null) ? ad_additional_currencies.CurrencyID.Value : view_customers_balance.Currency_Index.Value;
			text += ((value > 0m) ? string.Concat(new object[]
			{
				Class67.smethod_41(value, false, int_),
				" ",
				CurrencyInfo.currencyShortcutByID(id),
				" [ ",
				strings.CREDIT,
				" ] "
			}) : string.Concat(new object[]
			{
				Class67.smethod_41(-1m * value, false, int_),
				" ",
				CurrencyInfo.currencyShortcutByID(id),
				" [ ",
				strings.DEBIT,
				" ] "
			}));
		}
		return text;
	}

	public static List<view_customers_balance> smethod_17(int[] int_0 = null)
	{
		int[] array = new int[]
		{
			1,
			2,
			3
		};
		int_0 = ((int_0 == null) ? array : int_0);
		mrsalesdbEntities mrsalesdbEntities = ConnectionTools.OpenConn();
		ParameterExpression parameterExpression;
		List<Class57> source = (from u in mrsalesdbEntities.view_customers_balance
		where u.pepole_Statues == (int?)1 && !int_0.Contains(u.pepole_ID)
		select u into s
		group s by new
		{
			s.pepole_ID,
			s.pepole_Name,
			s.pepole_Code,
			s.pepole_Mobile,
			s.pepole_CreditLimit
		}).Select(Expression.Lambda(Expression.MemberInit(Expression.New(typeof(Class57)), new MemberBinding[]
		{
			Expression.Bind(methodof(Class57.set_pepole_ID(int)), Expression.Property(Expression.Property(parameterExpression, methodof(IGrouping<<>f__AnonymousType8<int, string, string, string, decimal?>, view_customers_balance>.get_Key())), methodof(<>f__AnonymousType8<int, string, string, string, decimal?>.get_pepole_ID()))),
			Expression.Bind(methodof(Class57.set_pepole_Name(string)), Expression.Property(Expression.Property(parameterExpression, methodof(IGrouping<<>f__AnonymousType8<int, string, string, string, decimal?>, view_customers_balance>.get_Key())), methodof(<>f__AnonymousType8<int, string, string, string, decimal?>.get_pepole_Name()))),
			Expression.Bind(methodof(Class57.set_pepole_Code(string)), Expression.Property(Expression.Property(parameterExpression, methodof(IGrouping<<>f__AnonymousType8<int, string, string, string, decimal?>, view_customers_balance>.get_Key())), methodof(<>f__AnonymousType8<int, string, string, string, decimal?>.get_pepole_Code()))),
			Expression.Bind(methodof(Class57.set_pepole_Mobile(string)), Expression.Property(Expression.Property(parameterExpression, methodof(IGrouping<<>f__AnonymousType8<int, string, string, string, decimal?>, view_customers_balance>.get_Key())), methodof(<>f__AnonymousType8<int, string, string, string, decimal?>.get_pepole_Mobile()))),
			Expression.Bind(methodof(Class57.set_pepole_CreditLimit(decimal?)), Expression.Property(Expression.Property(parameterExpression, methodof(IGrouping<<>f__AnonymousType8<int, string, string, string, decimal?>, view_customers_balance>.get_Key())), methodof(<>f__AnonymousType8<int, string, string, string, decimal?>.get_pepole_CreditLimit()))),
			Expression.Bind(methodof(Class57.set_credit(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
			{
				parameterExpression,
				(view_customers_balance f) => f.credit * (decimal?)f.Factor.Value
			})),
			Expression.Bind(methodof(Class57.set_debit(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
			{
				parameterExpression,
				(view_customers_balance f) => f.debit * (decimal?)f.Factor.Value
			})),
			Expression.Bind(methodof(Class57.set_balance(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
			{
				parameterExpression,
				(view_customers_balance f) => f.balance * (decimal?)f.Factor.Value
			}))
		}), new ParameterExpression[]
		{
			parameterExpression
		})).ToList<Class57>();
		return source.Select(new Func<Class57, view_customers_balance>(Class67.<>c.<>c_0.method_5)).ToList<view_customers_balance>();
	}

	public static List<view_customers_balance> smethod_18(int int_0)
	{
		RuntimeHelpers.InitializeArray(new int[3], fieldof(<PrivateImplementationDetails>.E429CCA3F703A39CC5954A6572FEC9086135B34E).FieldHandle);
		mrsalesdbEntities mrsalesdbEntities = ConnectionTools.OpenConn();
		ParameterExpression parameterExpression;
		return (from u in mrsalesdbEntities.view_customers_balance
		where u.pepole_Statues == (int?)1 && u.pepole_ID == int_0
		select u into s
		group s by new
		{
			s.pepole_ID
		}).Select(Expression.Lambda(Expression.MemberInit(Expression.New(typeof(view_customers_balance)), new MemberBinding[]
		{
			Expression.Bind(methodof(view_customers_balance.set_pepole_ID(int)), Expression.Property(Expression.Property(parameterExpression, methodof(IGrouping<<>f__AnonymousType6<int>, view_customers_balance>.get_Key())), methodof(<>f__AnonymousType6<int>.get_pepole_ID()))),
			Expression.Bind(methodof(view_customers_balance.set_credit(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
			{
				parameterExpression,
				(view_customers_balance f) => f.credit * (decimal?)f.Factor.Value
			})),
			Expression.Bind(methodof(view_customers_balance.set_debit(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
			{
				parameterExpression,
				(view_customers_balance f) => f.debit * (decimal?)f.Factor.Value
			})),
			Expression.Bind(methodof(view_customers_balance.set_balance(decimal?)), Expression.Call(null, methodof(IEnumerable<!!0>.Sum(Func<!!0, decimal?>)), new Expression[]
			{
				parameterExpression,
				(view_customers_balance f) => f.balance * (decimal?)f.Factor.Value
			}))
		}), new ParameterExpression[]
		{
			parameterExpression
		})).ToList<view_customers_balance>();
	}

	public static bool smethod_19()
	{
		Ping ping = new Ping();
		PingReply pingReply = ping.Send(SysPlugins.HelpDomainUrlQ);
		return pingReply.Status == IPStatus.Success;
	}

	public static bool smethod_20(string string_0)
	{
		bool result;
		try
		{
			Ping ping = new Ping();
			PingReply pingReply = ping.Send(string_0);
			if (pingReply.Status != IPStatus.Success)
			{
				result = false;
			}
			else
			{
				result = true;
			}
		}
		catch (Exception ex)
		{
			MessageBox.Show("Error occurred: " + ex.Message);
			result = false;
		}
		return result;
	}

	public static string smethod_21()
	{
		mrsalesdbEntities mrsalesdbEntities = ConnectionTools.OpenConn();
		string string_0 = Class67.smethod_75().ToString();
		IQueryable<ad_softver> queryable = from u in mrsalesdbEntities.ad_softver
		where u.CPU_Serial == string_0
		select u;
		string result = (queryable.FirstOrDefault<ad_softver>().SoftName.ToString() == "") ? "" : queryable.FirstOrDefault<ad_softver>().SoftName;
		mrsalesdbEntities.ad_softver.RemoveRange(queryable);
		mrsalesdbEntities.SaveChanges();
		return result;
	}

	public static Class67.Class68 activate_license(string key)
	{
		DateTime now = DateTime.Now;
		string string_0 = Class67.smethod_75().ToString();
		Class67.Class68 result;
		if (!(string_0 == "NULL"))
		{
			if (Class67.smethod_7())
			{
				Class67.Class68 @class = new Class67.Class68(string.Format(strings.CAN_NOT_ACTIVATE, " VX0102"), 0, strings.Alerts, 0);
				result = @class;
			}
			else
			{
				string string_ = strings.UNABLE_CONNECT_HOST;
				string text = "";
				string string_0 = "";
				string companyName = "";
				string softID = "";
				string activate = MainEDD.GetActivate(key, "activate_license", "");
				int int_;
				string string_3;
				int int_2;
				if (!(activate == "false"))
				{
					JObject jobject = JObject.Parse(activate);
					string_0 = (string)jobject["license"];
					string a = (string)jobject["item_name"];
					string text2 = ((string)jobject["error"] == "disabled") ? "Lic_disabled" : (((string)jobject["error"] == "expired") ? "Lic_expired" : ((string)jobject["error"]));
					text = ((text2 != null) ? (strings.ERROR + ": " + strings.ResourceManager.GetString(text2, strings.Culture)) : "");
					mrsalesdbEntities mrsalesdbEntities = ConnectionTools.OpenConn();
					if (!(a == ""))
					{
						if (string_0 != "valid")
						{
							string_0 = Class67.smethod_58((string)jobject["license"]);
							try
							{
								companyName = ((!((string)jobject["company_name"] == "")) ? Class67.smethod_58((string)jobject["company_name"]) : Class67.smethod_58("null"));
							}
							catch
							{
								companyName = Class67.smethod_58("null");
							}
							string string_2 = key;
							softID = Class67.smethod_58(SysPlugins.ProductIDOnServer.ToString());
							if ((from u in mrsalesdbEntities.ad_softver
							where u.CPU_Serial == string_0
							select u).Count<ad_softver>() > 0)
							{
								mrsalesdbEntities mrsalesdbEntities2 = ConnectionTools.OpenConn();
								ad_softver ad_softver = (from u in mrsalesdbEntities2.ad_softver
								where u.CPU_Serial == string_0
								select u).FirstOrDefault<ad_softver>();
								ad_softver.Valid = string_0;
								ad_softver.SoftName = key;
								mrsalesdbEntities2.SaveChanges();
								int num = Convert.ToInt32(Class67.smethod_44(FoldersPaths.ConfigFilePath, "DEVICE"));
								ad_device_info ad_device_info = mrsalesdbEntities2.ad_device_info.Find(new object[]
								{
									num
								});
								ad_device_info.ServerValid = Class67.smethod_58(0.ToString());
								mrsalesdbEntities2.SaveChanges();
							}
							else
							{
								mrsalesdbEntities mrsalesdbEntities3 = ConnectionTools.OpenConn();
								string serverValid = Class67.smethod_58("0");
								int num2 = Convert.ToInt32(Class67.smethod_44(FoldersPaths.ConfigFilePath, "DEVICE"));
								ad_device_info ad_device_info2 = mrsalesdbEntities3.ad_device_info.Find(new object[]
								{
									num2
								});
								ad_device_info2.ServerValid = serverValid;
								mrsalesdbEntities3.SaveChanges();
							}
							string_ = text;
							int_ = 1;
							string_3 = strings.ERROR;
							int_2 = 0;
						}
						else
						{
							string_0 = Class67.smethod_58((string)jobject["license"]);
							try
							{
								companyName = ((!((string)jobject["company_name"] == "")) ? Class67.smethod_58((string)jobject["company_name"]) : Class67.smethod_58("null"));
							}
							catch
							{
								companyName = Class67.smethod_58("null");
							}
							string text3 = ((string)jobject["license_limit"] == "0") ? "1" : ((string)jobject["license_limit"]);
							string licNum = Class67.smethod_58((!(text3 == "")) ? text3 : "1");
							string startDate = Class67.smethod_58(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
							string endDate = Class67.smethod_58((string)jobject["expires"]);
							string supportEndDate = Class67.smethod_58((string)jobject["expires"]);
							string username = Class67.smethod_58((string)jobject["customer_name"]);
							string string_2 = key;
							string text4 = Class67.smethod_58((string)jobject["price_id"]);
							int value = Convert.ToInt32(jobject["payment_id"]);
							Class67.smethod_59(text4);
							(from u in mrsalesdbEntities.ad_softver
							where u.CPU_Serial != string_0 && u.Valid == string_0 && u.SoftName == key
							select u).Count<ad_softver>();
							if ((from u in mrsalesdbEntities.ad_softver
							where u.CPU_Serial == string_0
							select u).Count<ad_softver>() <= 0)
							{
								mrsalesdbEntities mrsalesdbEntities4 = ConnectionTools.OpenConn();
								ad_softver ad_softver2 = new ad_softver();
								ad_softver2.companyName = companyName;
								ad_softver2.LicNum = licNum;
								ad_softver2.StartDate = startDate;
								ad_softver2.EndDate = endDate;
								ad_softver2.SupportEndDate = supportEndDate;
								ad_softver2.Username = username;
								ad_softver2.SoftName = string_2;
								ad_softver2.SoftID = softID;
								ad_softver2.SoftOptions = text4;
								ad_softver2.Valid = string_0;
								ad_softver2.CPU_Serial = string_0;
								ad_softver2.PurchasesID = new int?(value);
								ad_softver2.LastCheckDate = new DateTime?(now);
								mrsalesdbEntities4.ad_softver.Add(ad_softver2);
								mrsalesdbEntities4.SaveChanges();
								mrsalesdbEntities mrsalesdbEntities5 = ConnectionTools.OpenConn();
								ad_device_info ad_device_info3;
								for (;;)
								{
									int num3 = Convert.ToInt32(Class67.smethod_44(FoldersPaths.ConfigFilePath, "DEVICE"));
									ad_device_info3 = mrsalesdbEntities5.ad_device_info.Find(new object[]
									{
										num3
									});
									if (ad_device_info3 != null)
									{
										break;
									}
									Class67.smethod_47();
								}
								ad_device_info3.ServerValid = Class67.smethod_58(1.ToString());
								mrsalesdbEntities5.SaveChanges();
							}
							else
							{
								mrsalesdbEntities mrsalesdbEntities6 = ConnectionTools.OpenConn();
								ad_softver ad_softver3 = (from u in mrsalesdbEntities6.ad_softver
								where u.CPU_Serial == string_0
								select u).FirstOrDefault<ad_softver>();
								ad_softver3.companyName = companyName;
								ad_softver3.LicNum = licNum;
								ad_softver3.EndDate = endDate;
								ad_softver3.SupportEndDate = supportEndDate;
								ad_softver3.Username = username;
								ad_softver3.SoftName = string_2;
								ad_softver3.SoftID = softID;
								ad_softver3.SoftOptions = text4;
								ad_softver3.Valid = string_0;
								ad_softver3.PurchasesID = new int?(value);
								ad_softver3.LastCheckDate = new DateTime?(now);
								mrsalesdbEntities6.SaveChanges();
								mrsalesdbEntities mrsalesdbEntities7 = ConnectionTools.OpenConn();
								int num4 = Convert.ToInt32(Class67.smethod_44(FoldersPaths.ConfigFilePath, "DEVICE"));
								ad_device_info ad_device_info4 = mrsalesdbEntities7.ad_device_info.Find(new object[]
								{
									num4
								});
								ad_device_info4.ServerValid = Class67.smethod_58(1.ToString());
								mrsalesdbEntities7.SaveChanges();
							}
							mrsalesdbEntities mrsalesdbEntities8 = ConnectionTools.OpenConn();
							string value2 = Class67.smethod_44(FoldersPaths.ConfigFilePath, "DEVICE");
							int num5 = Convert.ToInt32(value2);
							ad_device_info ad_device_info5 = mrsalesdbEntities8.ad_device_info.Find(new object[]
							{
								num5
							});
							ad_device_info5.ServerValid = Class67.smethod_58(1.ToString());
							mrsalesdbEntities8.SaveChanges();
							string_ = strings.SUCCESSFULLY_LICENSED_TO + jobject["company_name"];
							int_ = 2;
							SysPlugins.fakeactivate = false;
							SysPlugins.activate = 1;
							string_3 = strings.SUCCESS;
							int_2 = 1;
						}
					}
					else
					{
						string_0 = Class67.smethod_58("invalid");
						mrsalesdbEntities mrsalesdbEntities9 = ConnectionTools.OpenConn();
						int num6 = Convert.ToInt32(Class67.smethod_44(FoldersPaths.ConfigFilePath, "DEVICE"));
						ad_device_info ad_device_info6 = mrsalesdbEntities9.ad_device_info.Find(new object[]
						{
							num6
						});
						ad_device_info6.ServerValid = Class67.smethod_58(0.ToString());
						mrsalesdbEntities9.SaveChanges();
						ad_softver ad_softver4 = (from u in mrsalesdbEntities9.ad_softver
						where u.CPU_Serial == string_0
						select u).FirstOrDefault<ad_softver>();
						ad_softver4.Valid = string_0;
						ad_softver4.SoftName = key;
						mrsalesdbEntities9.SaveChanges();
						string_ = text;
						int_ = 0;
						string_3 = strings.ERROR;
						int_2 = 0;
					}
				}
				else
				{
					string_ = strings.UNABLE_CONNECT_HOST;
					int_ = -1;
					string_3 = strings.ERROR;
					int_2 = 0;
				}
				Class67.Class68 class2 = new Class67.Class68(string_, int_, string_3, int_2);
				result = class2;
			}
		}
		else
		{
			Class67.Class68 class3 = new Class67.Class68(string.Format(strings.CAN_NOT_FIND_DEVICE_SERIAL, " VX0103"), 0, strings.Alerts, 0);
			result = class3;
		}
		return result;
	}

	public static Class67.Class68 deactivate_license(string key, string Serial = "")
	{
		Class67.Class68 result;
		if (Class67.smethod_7())
		{
			Class67.Class68 @class = new Class67.Class68(string.Format(strings.CAN_NOT_ACTIVATE, " VX0102"), 0, strings.Alerts, 0);
			result = @class;
		}
		else if (!Class67.smethod_6())
		{
			int int_ = 0;
			string unable_CONNECT_HOST = strings.UNABLE_CONNECT_HOST;
			string string_ = "";
			int int_2 = 0;
			string string_0 = (Serial != "") ? Serial : Class67.smethod_75().ToString();
			string activate = MainEDD.GetActivate(key, "deactivate_license", string_0);
			if (activate == "false")
			{
				unable_CONNECT_HOST = strings.UNABLE_CONNECT_HOST;
				int_ = -1;
				string_ = strings.ERROR;
				int_2 = 0;
			}
			else
			{
				JObject jobject = JObject.Parse(activate);
				string valid = (string)jobject["license"];
				string text = (!((string)jobject["error"] == "disabled")) ? (((string)jobject["error"] == "expired") ? "Lic_expired" : ((string)jobject["error"])) : "Lic_disabled";
				if (text != null)
				{
					strings.ERROR + ": " + strings.ResourceManager.GetString(text, strings.Culture);
				}
				mrsalesdbEntities mrsalesdbEntities = ConnectionTools.OpenConn();
				try
				{
					ad_softver ad_softver = (from u in mrsalesdbEntities.ad_softver
					where u.CPU_Serial == string_0
					select u).FirstOrDefault<ad_softver>();
					ad_softver.Valid = valid;
					ad_softver.SoftName = "";
					mrsalesdbEntities.SaveChanges();
				}
				catch
				{
				}
			}
			Class67.Class68 class2 = new Class67.Class68(unable_CONNECT_HOST, int_, string_, int_2);
			result = class2;
		}
		else
		{
			Class67.Class68 class3 = new Class67.Class68(string.Format(strings.CAN_NOT_ACTIVATE, " VX0101"), 0, strings.Alerts, 0);
			result = class3;
		}
		return result;
	}