public override View GetView(int position, View convertView, ViewGroup parent)
        {
            // Get our object for position
            var item = MainDatabase.GetItem <Contract>(ContractDatas[position].Contract);

            var view = (convertView ?? Context.LayoutInflater.Inflate(Resource.Layout.ContractTableItem, parent, false)
                        ) as LinearLayout;

            view.SetTag(Resource.String.ContractDataUUID, ContractDatas[position].UUID);

            view.FindViewById <TextView>(Resource.Id.ctiNameTV).Text        = item.name;
            view.FindViewById <TextView>(Resource.Id.ctiTimeTV).Text        = @"<пусто>";
            view.FindViewById <TextView>(Resource.Id.ctiDescriptionTV).Text = item.description;
            if (!string.IsNullOrEmpty(item.FilePath))
            {
                if (System.IO.File.Exists(item.FilePath))
                {
                    view.FindViewById <ImageView>(Resource.Id.ctiCanShowFileIV).SetImageResource(Resource.Drawable.ic_visibility_black_36dp);
                }
            }

            var del = view.FindViewById <RelativeLayout>(Resource.Id.ctiDeleteRL);

            del.Click -= Del_Click;
            del.Click += Del_Click;

            return(view);
        }
 private void ReInitializeUpdateForm(ComboBox cb1, TextBox tb1, TextBox tb2, ComboBox cb2)
 {
     string[][] res = new MainDatabase().InteractDB_AllDiscVat();
     tb1.Text          = res[cb1.SelectedIndex][1];
     tb2.Text          = Convert.ToString(Convert.ToDouble(res[cb1.SelectedIndex][2]) * 100);
     cb2.SelectedIndex = TypeTranslator_StringToIndex(res[cb1.SelectedIndex][5]);
 }
        public dynamic Insert(Guid appId, Dictionary <Guid, object> obj)
        {
            SetData(appId);
            var columns       = fields.Select(x => x.DBColumnName);
            var fullTableName = $"{database.DBSchema}.{application.TableName}";

            using (var db = new MainDatabase().Get)
            {
                var(primaryKey, primaryKeyField) = TryGetPrimaryKeyData(db);

                var inserts = fields.Where(x => x.DBColumnName != primaryKey)
                              .Select(x => $"@{x.DBColumnName}");

                var param = new DynamicParameters();
                foreach (var field in fields)
                {
                    if (obj.ContainsKey(field.ID))
                    {
                        param.Add($"@{field.DBColumnName}", obj[field.ID]);
                    }
                }

                return(db.QuerySingle($"INSERT INTO {fullTableName} ({string.Join(", ", fields.Where(x => x.DBColumnName != primaryKey).Select(x => x.DBColumnName))}) OUTPUT INSERTED.* VALUES ({string.Join(", ", inserts)})", param));
            }
        }
Beispiel #4
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var item = HospitalDatas[position];

            var view = (convertView ??
                        Context.LayoutInflater.Inflate(Resource.Layout.HospitalTableItem, parent, false)
                        ) as LinearLayout;

            view.SetTag(Resource.String.HospitalDataUUID, item.UUID);

            if (string.IsNullOrEmpty(item.ListedHospital))
            {
                var hospital = MainDatabase.GetEntity <Hospital>(item.Hospital);
                view.FindViewById <TextView>(Resource.Id.htiNameTV).Text =
                    string.IsNullOrEmpty(hospital.Name) ? "<пусто>" : hospital.Name;
                view.FindViewById <TextView>(Resource.Id.htiAddressTV).Text =
                    string.IsNullOrEmpty(hospital.Address) ? "<пусто>" : hospital.Address;
            }
            else
            {
                var listedHospital = MainDatabase.GetItem <ListedHospital>(item.ListedHospital);
                view.FindViewById <TextView>(Resource.Id.htiNameTV).Text =
                    string.IsNullOrEmpty(listedHospital.name) ? "<пусто>" : listedHospital.name;
                view.FindViewById <TextView>(Resource.Id.htiAddressTV).Text =
                    string.IsNullOrEmpty(listedHospital.address) ? "<пусто>" : listedHospital.address;
            }

            var del = view.FindViewById <RelativeLayout>(Resource.Id.htiDeleteRL);

            del.Click -= Del_Click;
            del.Click += Del_Click;

            return(view);
        }
Beispiel #5
0
        void Del_Click(object sender, System.EventArgs e)
        {
            if (sender is RelativeLayout)
            {
                var row = ((RelativeLayout)sender).Parent as LinearLayout;
                var hospitalDataUUID = (string)row.GetTag(Resource.String.HospitalDataUUID);
                if (string.IsNullOrEmpty(hospitalDataUUID))
                {
                    return;
                }

                foreach (var item in HospitalDatas)
                {
                    if (item.UUID == hospitalDataUUID)
                    {
                        HospitalDatas.Remove(item);
                        break;
                    }
                }

                MainDatabase.DeleteEntity <HospitalData>(hospitalDataUUID);

                NotifyDataSetChanged();
            }
        }
        public void Update(Guid appId, Dictionary <Guid, object> obj)
        {
            SetData(appId);
            var columns       = fields.Select(x => x.DBColumnName);
            var fullTableName = $"{database.DBSchema}.{application.TableName}";

            using (var db = new MainDatabase().Get)
            {
                var(primaryKey, primaryKeyField) = TryGetPrimaryKeyData(db);

                var updates = fields.Where(x => x.DBColumnName != primaryKey)
                              .Where(x => x.Editable)
                              .Select(x => $"{x.DBColumnName} = @{x.DBColumnName}");

                var param = new DynamicParameters();
                foreach (var field in fields)
                {
                    if (obj.ContainsKey(field.ID) && field.Editable || field.DBColumnName == primaryKey)
                    {
                        param.Add($"@{field.DBColumnName}", obj[field.ID]);
                    }
                }

                // TODO - Update this query to have update concurrency protection
                db.Execute($"UPDATE {fullTableName} SET {string.Join(", ", updates)} WHERE {primaryKeyField.DBColumnName} = @{primaryKeyField.DBColumnName}", param);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Provides easy access to the root frame of the Phone Application.
        /// </summary>



        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are being GPU accelerated with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;
            }

            // Standard Silverlight initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();
            // create database **Very Importance**

            MainDatabase.CreateDataBase();
        }
 private void textBox1_KeyType(object sender, KeyEventArgs e)
 {
     new IntegerOnly().integer_validator(e, textBox1);
     if ((textBox1.Text != "") && (label6.Text == "2"))
     {
         string[] results = new MainDatabase().InteractDB_DisplayUpdate(Convert.ToInt32(textBox1.Text));
         textBox2.Text = Convert.ToString(results[1]);
         textBox3.Text = String.Format("{0:0.00}", results[2]);
     }
 }
        public IEnumerable <dynamic> GetAll(Guid appId)
        {
            SetData(appId);
            var columns = fields.Select(x => x.DBColumnName);

            using (var db = new MainDatabase().Get)
            {
                return(db.Query($"SELECT {string.Join(", ", columns)} FROM {database.DBSchema}.{application.TableName}"));
            }
        }
Beispiel #10
0
        public static DataTable SimpleExecuteDataTable(string SQLString, CommandType CType = CommandType.Text)
        {
            DataSet ds = MainDatabase.ExecuteDataSet(CType, SQLString);

            if (ds != null && ds.Tables.Count > 0)
            {
                return(ds.Tables[0]);
            }
            return(null);
        }
Beispiel #11
0
        void LoadPromotions(RestClient client)
        {
            var request  = new RestRequest(@"Promotion?limit=300&populate=false", Method.GET);
            var response = client.Execute <List <Promotion> >(request);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                SD.Debug.WriteLine(string.Format(@"Получено Promotion {0}", response.Data.Count));
                MainDatabase.SaveItems(response.Data);
            }
        }
Beispiel #12
0
        void LoadDrugBrands(RestClient client)
        {
            var request  = new RestRequest(@"DrugBrand?limit=300&populate=false", Method.GET);
            var response = client.Execute <List <DrugBrand> >(request);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                SD.Debug.WriteLine(response.Data.Count);
                MainDatabase.SaveDrugBrands(response.Data);
            }
        }
Beispiel #13
0
        void LoadCategories(RestClient client)
        {
            var request  = new RestRequest(@"Category?limit=300", Method.GET);
            var response = client.Execute <List <Category> >(request);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                SD.Debug.WriteLine(response.Data.Count);
                MainDatabase.SaveCategories(response.Data);
            }
        }
Beispiel #14
0
    public WeekController(String userid)
    {
        m_pDb = MainDatabaseManager.GetDatabase(userid);

        DateTime          time     = DateTime.Now;
        GregorianCalendar calendar = new GregorianCalendar();
        int    weekOfYears         = calendar.GetWeekOfYear(time, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
        String weekKey             = time.Year + "-" + weekOfYears;

        m_pModel = m_pDb.GetWeekyState(weekKey);
    }
Beispiel #15
0
        void Save_Click(object sender, EventArgs e)
        {
            using (var trans = MainDatabase.BeginTransaction()) {
                var message = MainDatabase.Create2 <Entities.Message>();
                message.Text = Text.Text;
                trans.Commit();
            }

            OnAfterSaved(EventArgs.Empty);

            Dismiss();
        }
        public void Delete(Guid appId, object recordKey)
        {
            SetData(appId);
            var columns       = fields.Select(x => x.DBColumnName);
            var fullTableName = $"{database.DBSchema}.{application.TableName}";

            using (var db = new MainDatabase().Get)
            {
                var(primaryKey, primaryKeyField) = TryGetPrimaryKeyData(db);

                db.Execute($"DELETE FROM {fullTableName} WHERE {primaryKey} = @recordKey", new { recordKey });
            }
        }
        private void CallVSU_AE()
        {
            Hide();
            string[] res = new MainDatabase().InteractDB_DisplayUpdate(Convert.ToInt32(textBox1.Text));
            Alert_AlreadyRegistered aae = new Alert_AlreadyRegistered();
            int    A = Convert.ToInt32(res[0]);
            string B = res[1];
            double C = Convert.ToDouble(res[2]);

            aae.InitLabels(A, B, C);
            aae.ShowDialog();
            Show();
        }
Beispiel #18
0
        public static void CreateEmptyDatabase()
        {
            if (!Directory.Exists(WorkspaceFolder))
            {
                Directory.CreateDirectory(WorkspaceFolder);
            }
            var builder = new DbContextOptionsBuilder();

            builder.UseSqlite(MainDatabaseConnectionString);
            var db = new MainDatabase(builder.Options);

            db.Database.EnsureCreated();
        }
Beispiel #19
0
        private void PopulateTable(DataGridView dgv1)
        {
            dgv1.Rows.Clear();
            string[][] results = new MainDatabase().InteractDB_SearchProduct(textBox1.Text, SearchCommand());
            int        rows    = results.Length;

            for (int i = 0; i < rows; i++)
            {
                dgv1.Rows.Add();
                dgv1.Rows[i].Cells[0].Value = results[i][0];
                dgv1.Rows[i].Cells[1].Value = results[i][1];
                dgv1.Rows[i].Cells[2].Value = results[i][2];
            }
        }
Beispiel #20
0
        private void button3_Click(object sender, EventArgs e) => Close(); //Exit

        private void button2_Click(object sender, EventArgs e)             // Pay
        {
            if (dataGridView1.RowCount > 0)
            {
                while (true)
                {
                    PaymentWindow source = new PaymentWindow();
                    source.UpdateTotal(String.Format("{0:0.00}", new Calculator().UpdatePayment(label6, label4)));
                    source.ShowDialog();
                    if (source.getPayment() != "0.00")
                    {
                        label4.Text = new Calculator().AddPrevPayment(Convert.ToDouble(label4.Text), Convert.ToDouble(source.getPayment()));
                        label6.Text = source.getDiscountedPrice();
                    }
                    if (source.discountMode() == false)
                    {
                        Show();
                        break;
                    }
                    else
                    {
                        Hide();
                        DiscountPicker discPick = new DiscountPicker();
                        discPick.ShowDialog();
                        Show();
                    }
                }

                double change = new Calculator().ChangeCalculation(Convert.ToDouble(label4.Text), Convert.ToDouble(label6.Text));
                label8.Text = String.Format("{0:0.00}", change);

                if (change >= 0.00)
                {
                    string ORNOgenerated = new ORNOGEN().ORNOGENstring();
                    string Salesperson   = new MainDatabase().InteractDB_getCurrentSalesPerson();
                    inventorySub();
                    logSales(ORNOgenerated);
                    ReceiptWindow rw = new ReceiptWindow();
                    rw.setContents(dataGridView1);
                    string   VATpercent      = Convert.ToString(Convert.ToDouble(getVatPercentage()) * 100);
                    string   DiscountPercent = getDiscPercentage();
                    double[] PriceList       = getUpdatedValues();
                    rw.setTransactionDetails(ORNOgenerated, Salesperson, label4, label8, VATpercent, DiscountPercent, PriceList[0], PriceList[1], PriceList[2]);
                    Hide();
                    rw.ShowDialog();
                    Show();
                    ClearAll();
                }
            }
        }
Beispiel #21
0
        private void logSales(string ORNO)
        {
            int RowCount        = dataGridView1.RowCount;
            int indexID         = 0;
            int indexName       = 1;
            int indexQuan       = 2;
            int indexPriceTotal = 4;

            for (int i = 0; i < RowCount; i++)
            {
                int    ID         = Convert.ToInt32(dataGridView1.Rows[i].Cells[indexID].Value);
                string Name       = Convert.ToString(dataGridView1.Rows[i].Cells[indexName].Value);
                int    Quan       = Convert.ToInt32(dataGridView1.Rows[i].Cells[indexQuan].Value);
                double priceTotal = Convert.ToDouble(dataGridView1.Rows[i].Cells[indexPriceTotal].Value);
                new MainDatabase().InteractDB_logSales(ID, Name, Quan, priceTotal, ORNO);
            }
            double remainingBalance   = new Calculator().UpdateTotal(dataGridView1, 4);
            double totalDiscounts     = 0;
            double discountPercentage = 0;

            string[][] ActiveDiscounts = new MainDatabase().InteractDB_ActiveDisc();
            int        activeCount     = ActiveDiscounts.Length;

            for (int i = 0; i < activeCount; i++)
            {
                int    ID         = Convert.ToInt32(ActiveDiscounts[i][0]);
                string Name       = Convert.ToString(ActiveDiscounts[i][1]);
                int    Quan       = 1;
                double priceTotal = -(new Calculator().UpdateTotal(dataGridView1, 4) * Convert.ToDouble(ActiveDiscounts[i][2]));
                remainingBalance   = remainingBalance + priceTotal;
                totalDiscounts     = totalDiscounts + priceTotal;
                discountPercentage = discountPercentage + Convert.ToDouble(ActiveDiscounts[i][2]);
                new MainDatabase().InteractDB_logSales(ID, Name, Quan, priceTotal, ORNO);
            }
            string[] VATdetails   = new MainDatabase().InteractDB_GetVat();
            int      ID_VAT       = Convert.ToInt32(VATdetails[0]);
            string   Name_VAT     = Convert.ToString(VATdetails[1]);
            double   VatDeduction = -(remainingBalance * (Convert.ToDouble(VATdetails[2])));

            new MainDatabase().InteractDB_logSales(ID_VAT, Name_VAT, 1, VatDeduction, ORNO);

            double V1 = remainingBalance + VatDeduction;
            double V2 = totalDiscounts;
            double V3 = -(VatDeduction);
            string VP = Convert.ToString(VATdetails[2]);
            string DP = Convert.ToString(discountPercentage * 100);

            setUpdatedValues(VP, DP, V1, V2, V3);
        }
Beispiel #22
0
        public void UpdateTotal(string total)
        {
            string[][] ActiveDiscounts = new MainDatabase().InteractDB_ActiveDisc();
            int        activeCount     = ActiveDiscounts.Length;
            double     DiscountPercent = 0;

            for (int i = 0; i < activeCount; i++)
            {
                DiscountPercent = DiscountPercent + Convert.ToDouble(ActiveDiscounts[i][2]);
            }
            double totalDouble   = Convert.ToDouble(total);
            double discountPrice = totalDouble * DiscountPercent;

            label3.Text = String.Format("{0:0.00}", totalDouble - discountPrice);
        }
        private void button9_Click(object sender, EventArgs e)
        {
            Hide();
            ProductList PLsource = new ProductList();

            PLsource.ShowDialog();
            textBox1.Text = PLsource.getSelectedID();
            if (textBox1.Text != "")
            {
                string[] results = new MainDatabase().InteractDB_DisplayUpdate(Convert.ToInt32(textBox1.Text));
                textBox2.Text = Convert.ToString(results[1]);
                textBox3.Text = String.Format("{0:0.00}", results[2]);
            }
            Show();
        }
Beispiel #24
0
        void LoadPositions(RestClient client)
        {
            var request  = new RestRequest(@"Position?limit=300", Method.GET);
            var response = client.Execute <List <Position> >(request);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                SD.Debug.WriteLine(response.Data.Count);
                using (var trans = MainDatabase.BeginTransaction()) {
                    MainDatabase.DeleteAll <Position>(trans);
                    MainDatabase.SaveItems(trans, response.Data);
                    trans.Commit();
                }
            }
        }
Beispiel #25
0
        /// <summary>
        /// A helper method to ask for a name of a product and look it up in the database.
        /// </summary>
        /// <param name="io">IO controller to output and input text.</param>
        /// <param name="database">The main database.</param>
        /// <returns>Returns a product as a result of the look up. May be null if not found.</returns>
        public static async Task <IProduct> LookUpProductAsync(IIOController io, MainDatabase database)
        {
            io.Output.Write("Enter the name of the product:");
            string productName = io.Input.ReadInput();

            IProductRepository repo = database.ProductRepository;

            IProduct product = await repo.LookupProductFromName(productName);

            if (product is null)
            {
                io.Output.Write($"A product with the name '{productName}' could not be found. The results are case-sensitive.");
            }

            return(product);
        }
Beispiel #26
0
        private void button1_Click(object sender, EventArgs e) // Add
        {
            if (textBox1.Text != "")
            {
                if (new MainDatabase().InteractDB_CheckMatch(Convert.ToInt32(textBox1.Text)) == true)
                {
                    if ((textBox2.Text == "") || (Convert.ToInt32(textBox2.Text) < 1))
                    {
                        textBox2.Text = "1";
                    }
                    string[] res          = new MainDatabase().InteractDB_DisplayUpdate(Convert.ToInt32(textBox1.Text));
                    string   productName  = res[1];
                    double   price        = Convert.ToDouble(res[2]);
                    int      row          = 0;
                    int      scannedMatch = new TableScanner().scanMatch(dataGridView1, textBox1.Text, 0);
                    int      quantityPrev = 0;
                    if (scannedMatch != -1)
                    {
                        row          = scannedMatch;
                        quantityPrev = Convert.ToInt32(dataGridView1.Rows[row].Cells["Item_Quantity"].Value);
                    }
                    else
                    {
                        row = dataGridView1.Rows.Add();
                    }
                    dataGridView1.Rows[row].Cells["Item_ID"].Value       = textBox1.Text;
                    dataGridView1.Rows[row].Cells["Item_Name"].Value     = productName;
                    dataGridView1.Rows[row].Cells["Item_Quantity"].Value = Convert.ToString(Convert.ToInt32(textBox2.Text) + quantityPrev);
                    dataGridView1.Rows[row].Cells["Price_Raw"].Value     = String.Format("{0:0.00}", price);
                    dataGridView1.Rows[row].Cells["Price_Total"].Value   = String.Format("{0:0.00}", Convert.ToDouble(Convert.ToInt32(dataGridView1.Rows[row].Cells["Item_Quantity"].Value) * price));

                    textBox1.Text             = "";
                    textBox2.Text             = "";
                    dataGridView1.CurrentCell = dataGridView1.Rows[row].Cells[0];
                    dataGridView1.CurrentCell = null;
                    new Calculator().UpdateTotal(dataGridView1, 4, label6);
                }
                else
                {
                    // Alert Form -> ID not found
                }
            }
            double change = new Calculator().ChangeCalculation(Convert.ToDouble(label4.Text), Convert.ToDouble(label6.Text));

            label8.Text = String.Format("{0:0.00}", change);
        }
        private void CallVSU()
        {
            Hide();
            string[]        res = new MainDatabase().InteractDB_DisplayUpdate(Convert.ToInt32(textBox1.Text));
            ViewStockUpdate vsu = new ViewStockUpdate();
            int             A   = Convert.ToInt32(res[0]);
            string          B   = res[1];
            double          C   = Convert.ToDouble(res[2]);
            int             D   = Convert.ToInt32(res[3]);
            int             E   = Convert.ToInt32(res[4]);
            int             F   = Convert.ToInt32(res[5]);
            int             G   = Convert.ToInt32(res[6]);

            vsu.InitLabels(A, B, C, D, E, F, G);
            vsu.ShowDialog();
            Show();
        }
Beispiel #28
0
        public static async Task <ILocation> LookUpLocation(IIOController io, MainDatabase database)
        {
            io.Output.Write("Enter the name of the location:");
            string locationName = io.Input.ReadInput();

            ILocationRepository repo = database.LocationRepository;

            ILocation location = await repo.LookUpLocationByNameAsync(locationName);

            if (location is null)
            {
                io.Output.Write($"No location found with the name '{locationName}'");
                return(null);
            }

            return(location);
        }
Beispiel #29
0
        public static void ExecSQLList(List <string> SQLList, bool logRec = true)
        {
            StringBuilder sb      = new StringBuilder(4000);
            string        SQLText = "";

            foreach (string sql in SQLList)
            {
                sb.Append(sql + "\n");
            }
            SQLText = sb.ToString();
            DbCommand command = MainDatabase.DbProviderFactory.CreateCommand();

            command.CommandType    = CommandType.Text;
            command.CommandText    = SQLText;
            command.CommandTimeout = 300;
            MainDatabase.ExecuteNonQuery(command);
            command.Connection.Close();
        }
Beispiel #30
0
    private MainDatabase GetDatabaseByUserId(String userid)
    {
        MainDatabase db = null;

        Lock();
        if (m_pDatabaseMap.ContainsKey(userid))
        {
            db = m_pDatabaseMap[userid];
        }
        else
        {
            db = new MainDatabase(userid);
            m_pDatabaseMap.Add(userid, db);
        }
        Unlock();

        return(db);
    }