コード例 #1
0
ファイル: ProductForm.cs プロジェクト: tousekdominik/SkSys
 private void button2_Click(object sender, EventArgs e)
 {
     changingID = -1;
     changingItem = null;
     button1.Text = "přidat";
     textBox1.Text = "";
     button2.Enabled = false;
 }
コード例 #2
0
ファイル: Composition.cs プロジェクト: tousekdominik/SkSys
 public Composition(int id, Product product, MaterialType materialType, float amount, Unit unit)
 {
     ID = id;
     Product = product;
     MaterialType = materialType;
     Amount = amount;
     Unit = unit;
 }
コード例 #3
0
ファイル: ProductExport.cs プロジェクト: tousekdominik/SkSys
 public ProductExport(int id, Product product, float amount, Unit unit, String description, Month month, int year, Deadline deadline)
 {
     ID = id;
     Product = product;
     Amount = amount;
     Unit = unit;
     Description = description;
     Month = month;
     Year = year;
     Deadline = deadline;
 }
コード例 #4
0
ファイル: ProductForm.cs プロジェクト: tousekdominik/SkSys
 private void button1_Click(object sender, EventArgs e)
 {
     if (!Auth.HasAccess(AppSettings.User, this.Name, "AddItem"))
         return;
     if (textBox1.Text != "")
     {
         if (changingID != -1)
         {
             changingItem.Name = textBox1.Text;
             products.Change(changingItem);
             changingID = -1;
             changingItem = null;
             button2.Enabled = false;
         }
         else
             products.Add(textBox1.Text);
         textBox1.Text = "";
     }
     button1.Text = "přidat";
     refreshData();
 }
コード例 #5
0
ファイル: ProductExports.cs プロジェクト: tousekdominik/SkSys
 public void Add(Product Product, float Amount, Unit Unit, String Description, Month Month, int Year, Deadline Deadline)
 {
     _SQL.RunQuery(String.Format("INSERT INTO `{0}` VALUES(default,{1},{2},{3},'{4}',{5},{6},{7});",
         _table, Product.ID, Amount, Unit.ID, Description.Replace("'", "''"), Month.ID, Year, Deadline.ID));
 }
コード例 #6
0
ファイル: Compositions.cs プロジェクト: tousekdominik/SkSys
 public void Add(Product Product, MaterialType MaterialType, float Amount, Unit Unit)
 {
     _SQL.RunQuery(String.Format("INSERT INTO `{0}` VALUES(default,{1},{2},{3},{4});",
         _table, Product.ID, MaterialType.ID, Amount.ToString().Replace(',', '.'), Unit.ID));
 }
コード例 #7
0
ファイル: ProductForm.cs プロジェクト: tousekdominik/SkSys
 private void button3_Click(object sender, EventArgs e)
 {
     if (!Auth.HasAccess(AppSettings.User, this.Name, "EditItem"))
         return;
     if (listBox1.SelectedIndex > -1)
     {
         textBox1.Text = ((Product)(listBox1.Items[listBox1.SelectedIndex])).Name.ToString();
         changingID = ((Product)(listBox1.Items[listBox1.SelectedIndex])).ID;
         changingItem = ((Product)(listBox1.Items[listBox1.SelectedIndex]));
         button1.Text = "uložit";
         button2.Enabled = true;
     }
 }
コード例 #8
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if ((dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null)&&(cellValue=="")) return;
            else if ((dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value!=null)&&(cellValue == dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()))
                return;
            if ((addID != -1) && (addID != e.RowIndex))
                rowsAdded = false;
            else if ((addID != -1) && (addID == e.RowIndex))
                rowsAdded = true;

            if (initState) return;
            if (units == null) return;
            if (products == null) return;

            foreach(String collumn in nummericIntCollums){
                int intOut = 0;
                if (dataGridView1.Rows[e.RowIndex].Cells[collumn].Value == null) continue;
                if (!int.TryParse(dataGridView1.Rows[e.RowIndex].Cells[collumn].Value.ToString(), out intOut))
                {
                    dataGridView1.Rows[e.RowIndex].Cells[collumn].ErrorText = "Zadejte číselnou hodnotu!";
                }
                else {
                    dataGridView1.Rows[e.RowIndex].Cells[collumn].ErrorText = "";
                }
            }
            foreach (String collumn in nummericFloatCollums)
            {
                float floatOut = 0;
                if (dataGridView1.Rows[e.RowIndex].Cells[collumn].Value == null) continue;
                if (!float.TryParse(dataGridView1.Rows[e.RowIndex].Cells[collumn].Value.ToString().Replace('.',','), out floatOut))
                {
                    dataGridView1.Rows[e.RowIndex].Cells[collumn].ErrorText = "Zadejte číselnou hodnotu!";
                }
                else
                {
                    dataGridView1.Rows[e.RowIndex].Cells[collumn].ErrorText = "";
                }
            }

            bool rowError = false;
            foreach (DataGridViewCell cell in dataGridView1.Rows[e.RowIndex].Cells) {
                if (cell.ErrorText != "")
                {
                    rowError = true;
                    break;
                }
            }

            if (dataGridView1.Rows[e.RowIndex].Cells["UnitColumn"].Value == null) return;
            Unit unitItem = getUnit(dataGridView1.Rows[e.RowIndex].Cells["UnitColumn"].Value.ToString());
            if (unitItem.ID == 0) return;

            Product productItem;
            if (dataGridView1.Rows[e.RowIndex].Cells["ProductColumn"].Value == null) productItem = new Product(0, "");
            else
            {
                productItem = getProduct(dataGridView1.Rows[e.RowIndex].Cells["ProductColumn"].Value.ToString());
            }

            Month monthItem = new Month(0, "");
            if (dataGridView1.Rows[e.RowIndex].Cells["MonthColumn"].Value == null)
            {
                monthItem = (new Months()).getMonth(monthComboBox.Text);
            }
            else {
                monthItem = (new Months()).getMonth(dataGridView1.Rows[e.RowIndex].Cells["MonthColumn"].Value.ToString());
            }

            int year = 0;
            if (dataGridView1.Rows[e.RowIndex].Cells["YearColumn"].Value == null)
            {
                year = (int)yearUpDown.Value;
            }
            else {
                year = (int)parseCell(0, e.RowIndex, "YearColumn");
            }
            //if (dataGridView1.Rows[e.RowIndex].Cells["PriceColumn"].Value == null) return;

            String description = "";
            if (dataGridView1.Rows[e.RowIndex].Cells["DescriptionColumn"].Value != null)
                description = dataGridView1.Rows[e.RowIndex].Cells["DescriptionColumn"].Value.ToString();

            int id = 0;
            if (!rowsAdded) id = items[e.RowIndex].ID;/* id = int.Parse(dataGridView1.Rows[e.RowIndex].Cells["IDColumn"].Value.ToString());*/
            ProductExport productExportItem = new ProductExport(
                 (int)parseCell(0,e.RowIndex,"IDColumn"),
                 productItem,
                 parseCell(0,e.RowIndex,"AmountColumn"),
                 unitItem,
                 description,
                 monthItem,
                 year,
                 lastDeadline
            );

            if (rowError) return;
            if (rowsAdded)
            {
                Status = "Přidávám novou položku...";
                ProductExports.Add(productExportItem);
                if (!connector.IsConnected()) return;
                dataGridView1.BeginInvoke(new Action(()=>{
                    reload();
                    dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.Rows.Count - 1;
                    //dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells.Count - 1].Selected = true;
                    //dataGridView1.BeginEdit(true);
                }));
                addID = -1;
                dataGridView1.Rows[dataGridView1.NewRowIndex].ReadOnly = false;
                dataGridView1.Rows[dataGridView1.NewRowIndex].DefaultCellStyle = dataGridView1.DefaultCellStyle;
                refresh();
            }
            else
            {
                if (items[e.RowIndex] != productExportItem)
                {
                    Status = "Provádím úpravy...";
                    ProductExports.Change(productExportItem);
                    if (!connector.IsConnected()) return;
                }
            }
            rowsAdded = false;
            Status = ".....";
        }
コード例 #9
0
ファイル: Products.cs プロジェクト: tousekdominik/SkSys
 public void Change(Product item)
 {
     _SQL.RunQuery(String.Format("UPDATE `{0}` SET NAME='{1}' WHERE ID={2};", _table, item.Name.Replace("'", "''"), item.ID));
 }