示例#1
0
        private void DataGridFill()
        {
            dataGridView1.Columns.Clear();
            dataGridView1.DataSource = null;

            string  date = "AND history_adding_time  BETWEEN '" + DateTime.Today.AddDays(-2).ToString("yyyy-MM-dd") + " 00:00:00' and '" + DateTime.Today.ToString("yyyy-MM-dd") + " 23:59:59'";
            DataSet ds   = DatabaseClass.GridFill("*", "history_view", "", "", date, "");

            System.Data.DataTable dt = ds.Tables["*"];
            foreach (DataRow dr in dt.Rows)                        // search whole table
            {
                if (!Convert.ToBoolean(dr["history_status"]))      // if id==2
                {
                    dr["stock_number"] = "-" + dr["stock_number"]; //change the name
                                                                   //break; break or not depending on you
                }
            }

            dataGridView1.DataSource            = dt;
            dataGridView1.Columns[0].HeaderText = "Name";
            dataGridView1.Columns[1].HeaderText = "Barcode";
            dataGridView1.Columns[3].HeaderText = "Number";
            dataGridView1.Columns[4].HeaderText = "Location";
            dataGridView1.Columns[5].HeaderText = "Add Date";
            dataGridView1.Columns[2].Visible    = false;
            dataGridView1.Columns["product_name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.dataGridView1.Sort(this.dataGridView1.Columns[5], ListSortDirection.Descending);
        }
示例#2
0
 public void Save()
 {
     if (textBox1.Text.Length < 9)
     {
         MessageBox.Show("Barcode must be at 9 characters long.");
         this.DialogResult = DialogResult.No;
         this.Close();
     }
     else if (textBox2.Text == "")
     {
         MessageBox.Show("Product name must not be empty.");
         this.DialogResult = DialogResult.No;
         this.Close();
     }
     else if (DatabaseClass.IsBarcodeExist(textBox1.Text, ManageProducts.CellID[0]))
     {
         MessageBox.Show("Barcode already exist another product.");
         this.DialogResult = DialogResult.No;
         this.Close();
     }
     else if (DatabaseClass.IsProductNameExist(textBox2.Text, ManageProducts.CellID[0]))
     {
         MessageBox.Show("Product name already exist another product.");
         this.DialogResult = DialogResult.No;
         this.Close();
     }
     else
     {
         DatabaseClass.EditProduct(Int32.Parse(ManageProducts.CellID[0]), Int32.Parse(textBox1.Text), textBox2.Text);
     }
 }
示例#3
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(
             "Are you sure delete this datas?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk
             ) == DialogResult.Yes)
     {
         if (MethodsClass.ExportDatabase())
         {
             if (DatabaseClass.DropHistoryStockLocation())
             {
                 label3.ForeColor = Color.Green;
                 label3.Text      = "Backed up and delete.";
                 label3.Visible   = true;
             }
             else
             {
                 label3.ForeColor = Color.Red;
                 label3.Text      = "Cant delete datas.";
                 label3.Visible   = true;
             }
         }
         else
         {
             label3.ForeColor = Color.Red;
             label3.Text      = "Not backed up.";
             label3.Visible   = true;
         }
     }
 }
示例#4
0
        private void Enter()
        {
            if (textBox1.Text.Length < 9)
            {
                MessageBox.Show("Barcode must be at 9 characters long.");
            }
            else if (!DatabaseClass.IsBarcodeExist(textBox1.Text, ""))
            {
                MessageBox.Show("Barcode is undefined on products.");
            }
            else
            {
                Barcode = Int32.Parse(textBox1.Text);

                Form OutInvOptions = new OutInvOptions();
                OutInvOptions.ShowDialog(this);

                while (OutInvOptions.DialogResult != DialogResult.Cancel)
                {
                    if (OutInvOptions.DialogResult == DialogResult.OK)
                    {
                        DataGridFill();
                        break;
                    }
                    else
                    {
                        OutInvOptions.ShowDialog(this);
                    }
                }
            }
        }
示例#5
0
        private void ParentForm_Load(object sender, EventArgs e)
        {
            this.Text = this.Text + " v" + Assembly.GetExecutingAssembly().GetName().Version.ToString();



            DatabaseClass.CreateDB();
            DatabaseClass.CreateTable();
            string[] LicenseKey = new string[2];
            LicenseKey = Regedit.Read();

            DatabaseClass.DeleteOlderThen(Settings.Default.DeletePeriod.ToString());

            if (LicenseKey == null)
            {
                menuStrip1.Enabled = false;
                Form License = new License();
                License.MdiParent = this;
                License.Show();
            }
            else if (!MethodsClass.LicenseCheck(MethodsClass.CreateKey(LicenseKey[0]), LicenseKey[1]))
            {
                menuStrip1.Enabled = false;
                Form License = new License();
                License.MdiParent = this;
                License.Show();
            }
            else if (!DatabaseClass.LocationTableCheck())
            {
                menuStrip1.Enabled = false;
                if (!DatabaseClass.ProductsTableCheck())
                {
                    if (MessageBox.Show(
                            "Do you have a database created and backed up with this program that you want to add to the system? \nIf you choose a wrong file, you may need to uninstall and reinstall the program.", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk
                            ) == DialogResult.Yes)
                    {
                        Form ImportDatabaseFile = new ImportDatabaseFile();
                        ImportDatabaseFile.ShowDialog();
                    }
                    else
                    {
                        Form AddLocation = new AddLocation();
                        AddLocation.ShowDialog();
                    }
                }
                else
                {
                    Form AddLocation = new AddLocation();
                    AddLocation.ShowDialog();
                }
            }
            else
            {
                Form HomeForm = new Home();
                HomeForm.MdiParent = this;
                HomeForm.Show();
            }
        }
示例#6
0
        private void InInvOptions_Load(object sender, EventArgs e)
        {
            label8.Text = DatabaseClass.ProductName(InInventory.Barcode);
            label7.Text = DatabaseClass.WhereIsProduct(InInventory.Barcode);
            string[] locations = new string[3];
            locations = DatabaseClass.GetLocationList();

            comboBox1.Items.AddRange(locations[0].Distinct().ToArray().ToList().Select(i => (object)i).ToArray());
            comboBox2.Items.AddRange(Enumerable.Range(1, Int32.Parse(locations[1])).Select(i => (object)i).ToArray());
            comboBox3.Items.AddRange(Enumerable.Range(1, Int32.Parse(locations[2])).Select(i => (object)i).ToArray());
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string Location;

            try
            {
                if (comboBox1.SelectedItem == null)
                {
                    MessageBox.Show("Location is not selected correctly.");
                }
                else if (numericUpDown1.Value < 1)
                {
                    MessageBox.Show("The number cannot be zero or negative.");
                }
                else
                {
                    Location = comboBox1.SelectedItem.ToString();

                    if (!DatabaseClass.OutInvIsExist(OutInventory.Barcode, Location))
                    {
                        MessageBox.Show("Stock not found");
                        this.Close();
                    }
                    else if (!DatabaseClass.EnoughInStock(OutInventory.Barcode, Location, Decimal.ToInt32(numericUpDown1.Value)))
                    {
                        if (DatabaseClass.IsStockZero(OutInventory.Barcode, Location, Decimal.ToInt32(numericUpDown1.Value)))
                        {
                            DatabaseClass.OutInventoryDelete(OutInventory.Barcode, Decimal.ToInt32(numericUpDown1.Value), Location);
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("There is not enough product in the division to perform the operation. \n Check the number or location.");
                            this.DialogResult = DialogResult.No;
                            this.Close();
                        }
                    }
                    else
                    {
                        DatabaseClass.OutInventoryUpdate(OutInventory.Barcode, Decimal.ToInt32(numericUpDown1.Value), Location);
                        this.Close();
                    }
                }
            }
            catch (NullReferenceException InvalidThrow)
            {
                MessageBox.Show("Location is not selected correctly. Message: " + InvalidThrow.Message);
            }
        }
示例#8
0
        private void SettingsMenu_Load(object sender, EventArgs e)
        {
            location = DatabaseClass.MinLocation();
            string location0 = location[0];

            for (char i = Convert.ToChar(location[0]); i <= 'Z'; i++)
            {
                location0 = location0 + i;
            }

            comboBox1.Items.AddRange(location0.Distinct().ToArray().ToList().Select(i => (object)i).ToArray());
            comboBox2.Items.AddRange(Enumerable.Range(Int32.Parse(location[1]), 10 - Int32.Parse(location[1])).Select(i => (object)i).ToArray());
            comboBox3.Items.AddRange(Enumerable.Range(Int32.Parse(location[2]), 100 - Int32.Parse(location[2])).Select(i => (object)i).ToArray());

            numericUpDown1.Value = Settings.Default.DeletePeriod;
        }
        private void OutInvOptions_Load(object sender, EventArgs e)
        {
            label8.Text = DatabaseClass.ProductName(OutInventory.Barcode);
            label7.Text = "";
            List <List <string> > locations = new List <List <string> >();

            locations = DatabaseClass.GetStockLocations(OutInventory.Barcode);

            comboBox1.Items.Clear();
            for (int i = 0; i < locations[0].Count; i++)
            {
                comboBox1.Items.Add(locations[0][i]);

                label7.Text = label7.Text + locations[0][i] + ": " + locations[1][i] + ";  ";
            }
        }
示例#10
0
        private void DataGridFill()
        {
            dataGridView1.Columns.Clear();
            dataGridView1.DataSource = null;

            DataSet ds = DatabaseClass.GridFill("*", "stock_view", textBox1.Text, textBox2.Text, "", "");

            dataGridView1.DataSource            = ds.Tables["*"];
            dataGridView1.Columns[0].HeaderText = "Name";
            dataGridView1.Columns[1].HeaderText = "Barcode";
            dataGridView1.Columns[2].HeaderText = "Number";
            dataGridView1.Columns[3].HeaderText = "Location";
            dataGridView1.Columns["product_name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dataGridView1.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.dataGridView1.Sort(this.dataGridView1.Columns[0], ListSortDirection.Ascending);
        }
示例#11
0
        private void button1_Click(object sender, EventArgs e)
        {
            Settings.Default.DeletePeriod = Convert.ToInt32(numericUpDown1.Value);

            if (comboBox1.SelectedItem != null && comboBox2.SelectedItem != null & comboBox3.SelectedItem != null)
            {
                char comboLocation1 = Char.Parse(comboBox1.SelectedItem.ToString());
                int  comboLocation2 = Int32.Parse(comboBox2.SelectedItem.ToString());
                int  comboLocation3 = Int32.Parse(comboBox3.SelectedItem.ToString());

                progressBar1.Style = ProgressBarStyle.Marquee;
                button1.Enabled    = false;
                DatabaseClass.LocationTableAddItem(comboLocation1, comboLocation2, comboLocation3);
            }
            else
            {
                MessageBox.Show("You can't leave empty slot.");
            }
        }
示例#12
0
        private void DataGridFill()
        {
            dataGridView1.Columns.Clear();
            dataGridView1.DataSource = null;

            string date = "AND history_adding_time  BETWEEN '" + DateTime.Today.AddDays(-2).ToString("yyyy-MM-dd") + " 00:00:00' and '" + DateTime.Today.ToString("yyyy-MM-dd") + " 23:59:59'";

            DataSet ds = DatabaseClass.GridFill("*", "in_history_view", "", "", date, "");

            dataGridView1.DataSource            = ds.Tables["*"];
            dataGridView1.Columns[0].HeaderText = "Name";
            dataGridView1.Columns[1].HeaderText = "Barcode";
            dataGridView1.Columns[2].Visible    = false;
            dataGridView1.Columns[3].HeaderText = "Number";
            dataGridView1.Columns[4].HeaderText = "Location";
            dataGridView1.Columns[5].HeaderText = "Add Date";
            dataGridView1.Columns["product_name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.dataGridView1.Sort(this.dataGridView1.Columns[4], ListSortDirection.Descending);
        }
示例#13
0
        private void DataGridFill()
        {
            dataGridView1.Columns.Clear();
            dataGridView1.DataSource = null;

            DataSet ds = DatabaseClass.GridFill("*", "products", textBox3.Text, textBox4.Text, "", "");

            dataGridView1.DataSource = ds.Tables["*"];

            dataGridView1.Columns[1].HeaderText = "Barcodes";
            dataGridView1.Columns[2].HeaderText = "Name";
            dataGridView1.Columns[3].HeaderText = "Add Date";
            dataGridView1.Columns[0].Visible    = false;
            dataGridView1.Columns["product_name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            DataGridViewButtonColumn btn = new DataGridViewButtonColumn();

            dataGridView1.Columns.Add(btn);
            btn.Name       = "dataGridButton";
            btn.HeaderText = "";
            btn.Text       = "Edit";
            btn.UseColumnTextForButtonValue = true;
        }
示例#14
0
 public void Enter()
 {
     if (textBox1.Text.Length < 9)
     {
         MessageBox.Show("Barcode must be at 9 characters long.");
     }
     else if (textBox2.Text == "")
     {
         MessageBox.Show("Product name must not be empty.");
     }
     else if (DatabaseClass.IsBarcodeExist(textBox1.Text, ""))
     {
         MessageBox.Show("Barcode already exist.");
     }
     else if (DatabaseClass.IsProductNameExist(textBox2.Text, ""))
     {
         MessageBox.Show("Product name already exist.");
     }
     else
     {
         DatabaseClass.AddNewProduct(Int32.Parse(textBox1.Text), textBox2.Text);
         DataGridFill();
     }
 }
示例#15
0
        private void button1_Click(object sender, EventArgs e)
        {
            string[] Location = new string[3];
            try
            {
                if (comboBox1.SelectedItem == null || comboBox2.SelectedItem == null || comboBox3.SelectedItem == null)
                {
                    MessageBox.Show("Location is not selected correctly.");
                }
                else if (numericUpDown1.Value < 1)
                {
                    MessageBox.Show("The number cannot be zero or negative.");
                }
                else
                {
                    Location[0] = comboBox1.SelectedItem.ToString();
                    Location[1] = comboBox2.SelectedItem.ToString();
                    Location[2] = comboBox3.SelectedItem.ToString();

                    if (DatabaseClass.InInvIsExist(InInventory.Barcode, Location))
                    {
                        DatabaseClass.InInventoryUpdate(InInventory.Barcode, Decimal.ToInt32(numericUpDown1.Value), Location);
                    }
                    else
                    {
                        DatabaseClass.InInventoryInsert(InInventory.Barcode, Decimal.ToInt32(numericUpDown1.Value), Location);
                    }

                    this.Close();
                }
            }
            catch (NullReferenceException InvalidThrow)
            {
                MessageBox.Show("Location is not selected correctly. Message: " + InvalidThrow.Message);
            }
        }
示例#16
0
        private void DataGridFill()
        {
            dataGridView1.Columns.Clear();
            dataGridView1.DataSource = null;

            DataSet ds;
            string  table;
            string  date;
            string  history_status;

            if (checkBox1.Checked)
            {
                date = "AND history_adding_time  BETWEEN '0000-00-00 00:00:00' and '" + DateTime.Today.ToString("yyyy-MM-dd") + " 23:59:59'";
            }
            else
            {
                date = "AND history_adding_time  BETWEEN '" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + " 00:00:00' and '" + dateTimePicker2.Value.ToString("yyyy-MM-dd") + " 23:59:59'";
            }

            if (comboBox1.SelectedIndex == 1)
            {
                table = "in_history_view";
            }
            else if (comboBox1.SelectedIndex == 2)
            {
                table = "out_history_view";
            }
            else
            {
                table = "history_view";
            }

            if (checkBox2.Checked)
            {
                string columns = "product_name, product_barcode, history_status, SUM(stock_number), location, history_adding_time";
                string groupBy = "GROUP BY  product_barcode, history_status";
                ds = DatabaseClass.GridFill(columns, table, textBox1.Text, textBox2.Text, date, groupBy);
            }
            else
            {
                ds = DatabaseClass.GridFill("*", table, textBox1.Text, textBox2.Text, date, "");
            }

            System.Data.DataTable dt = ds.Tables["*"];
            foreach (DataRow dr in dt.Rows)                   // search whole table
            {
                if (!Convert.ToBoolean(dr["history_status"])) // if id==2
                {
                    dr[3] = "-" + dr[3];                      //change the name
                    //break; break or not depending on you
                }
            }

            dataGridView1.DataSource            = dt;
            dataGridView1.Columns[0].HeaderText = "Name";
            dataGridView1.Columns[1].HeaderText = "Barcode";
            dataGridView1.Columns[2].Visible    = false;
            dataGridView1.Columns[3].HeaderText = "Number";
            dataGridView1.Columns[4].HeaderText = "Location";
            dataGridView1.Columns[5].HeaderText = "Add Date";
            dataGridView1.Columns["product_name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.dataGridView1.Sort(this.dataGridView1.Columns[5], ListSortDirection.Descending);

            dataGridView1.Refresh();
        }