Пример #1
0
        public void get_image(string filePath, string newFileName)
        {
            string     oldPath = filePath;
            Form_admin fa      = new Form_admin();
            string     newpath = fa.data_folder + @"\Item_img\";
            FileInfo   f1      = new FileInfo(oldPath);

            if (f1.Exists)
            {
                if (!Directory.Exists(newpath))
                {
                    Directory.CreateDirectory(newpath);
                }
                f1.CopyTo(string.Format("{0}{1}{2}", newpath, newFileName, f1.Extension));
            }
            string im33 = fa.data_folder + "\\Item_300x300_tumb\\" + newFileName + ".jpg";
            string im11 = fa.data_folder + "\\Item_150x150_tumb\\" + newFileName + ".jpg";



            Image image = Image.FromFile(filePath);
            Image thumb = image.GetThumbnailImage(300, 300, () => false, IntPtr.Zero);

            thumb.Save(im33, ImageFormat.Jpeg);


            Image thumb2 = image.GetThumbnailImage(150, 150, () => false, IntPtr.Zero);

            thumb2.Save(im11, ImageFormat.Jpeg);
        }
Пример #2
0
        public void Load_pro()
        {
            try
            {
                Form_admin fa = new Form_admin();
                serialPort1.PortName = fa.Port2;
                serialPort1.BaudRate = 9600;
                serialPort1.Open();
                proximity prox = new proximity();
                prox.Show();
                try
                {
                    string idr = serialPort1.ReadLine();
                    prox.Close();


                    validate(idr);
                }
                catch (TimeoutException t)
                {
                    prox.Close();
                    MessageBox.Show(t.Message);
                }

                serialPort1.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
0
        private void set_data(string sql)
        {
            try
            {
                Form_admin fa   = new Form_admin();
                string     conn = "user id=" + fa.username + ";" +
                                  "password="******";" +
                                  "server=" + fa.serverurl + ";" +
                                  "Trusted_Connection=yes;" +
                                  "database=" + fa.database + "; " +
                                  "connection timeout=" + fa.timeout;

                SqlCommand        sCommand;
                SqlDataAdapter    sAdapter;
                SqlCommandBuilder sBuilder;
                DataSet           sDs;
                DataTable         sTable;


                SqlConnection connection = new SqlConnection(conn);
                connection.Open();
                sCommand = new SqlCommand(sql, connection);
                sAdapter = new SqlDataAdapter(sCommand);
                sBuilder = new SqlCommandBuilder(sAdapter);
                sDs      = new DataSet();
                sAdapter.Fill(sDs, "mytable");
                sTable = sDs.Tables["mytable"];
                connection.Close();
                dataGridView1.DataSource = sDs.Tables["mytable"];
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Пример #4
0
        private void button4_Click(object sender, EventArgs e)
        {
            //Application.Restart();
            this.Close();
            Form_admin admin = new Form_admin();

            admin.Show();
        }
Пример #5
0
        public static string echo_darshi(string key)
        {
            string     attr = "";
            Form_admin fa   = new Form_admin();

            XmlDocument doc = new XmlDocument();

            doc.Load(fa.language_file);
            //add lang case

            if (fa.language == "Sinhala")
            {
                try
                {
                    XmlNode node1 = doc.DocumentElement.SelectSingleNode("/language/SINHALA/add");
                    attr = node1.Attributes[key].InnerText;
                    return(attr);
                }
                catch (NullReferenceException)
                {
                    XmlNode node2 = doc.DocumentElement.SelectSingleNode("/language/ENGLISH/add");
                    attr = node2.Attributes[key].InnerText;

                    return(attr);
                }
            }
            if (fa.language == "Tamil")
            {
                XmlNode node3 = doc.DocumentElement.SelectSingleNode("/language/TAMIL/add");
                try
                {
                    attr = node3.Attributes[key].InnerText;
                    return(attr);
                }
                catch (NullReferenceException)
                {
                    XmlNode node4 = doc.DocumentElement.SelectSingleNode("/language/ENGLISH/add");
                    attr = node4.Attributes[key].InnerText;

                    return(attr);
                }
            }
            else
            {
                XmlNode node5 = doc.DocumentElement.SelectSingleNode("/language/ENGLISH/add");
                try
                {
                    attr = node5.Attributes[key].InnerText;
                    return(attr);
                }
                catch (NullReferenceException)
                {
                    return("This Key (" + key + ") Not update Plese update to Language.xml file");
                }
            }
        }
Пример #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            Login        login  = new Login();
            DialogResult Result = login.ShowDialog();

            if (Result == DialogResult.OK)
            {
                Form_admin admin = new Form_admin();
                admin.Show();
            }
        }
Пример #7
0
        private void To_print(string invoice_num)
        {
            invodt = (DataTable)(dataGridView1.DataSource);

            int row = invodt.Rows.Count;
            int r   = (25 * row) + 265;
            //MessageBox.Show(r.ToString() + "     ----   " + row.ToString());


            PaperSize UCS_Paper = new PaperSize("UCS-Paper", 300, r);

            try
            {
                PrintDocument pd = new PrintDocument();
                pd.DefaultPageSettings.PaperSize = UCS_Paper;
                pd.PrinterSettings.DefaultPageSettings.PaperSize = UCS_Paper;
                pd.DocumentName = invoice_num;

                // all sizes are converted from mm to inches & then multiplied by 100.

                pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);

                Form_admin fa = new Form_admin();

                if (fa.printer == "Print Dialog")
                {
                    DialogResult dialogResult = printDialog.ShowDialog();
                    if (dialogResult == DialogResult.OK)
                    {
                        pd.Print();
                        this.Close();
                    }
                }
                else
                {
                    pd.PrinterSettings.PrinterName = fa.printer;
                    pd.Print();
                    this.Close();
                }
            }
            catch (Exception printx)
            {
                MessageBox.Show(printx.ToString());
            }
        }
Пример #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (price == 0.00)
            {
                MessageBox.Show("Please Select Items You Want to by");
                return; // return because we don't want to run normal code of buton click
            }
            try
            {
                Form_admin fa = new Form_admin();
                serialPort1.PortName = fa.Port;
                serialPort1.BaudRate = 9600;
                serialPort1.Open();
                proximity prox = new proximity();
                prox.Show();
                try
                {
                    string id = serialPort1.ReadLine();
                    prox.Close();


                    validate(id);
                }
                catch (TimeoutException t)
                {
                    prox.Close();
                    MessageBox.Show(t.Message);
                }

                serialPort1.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #9
0
        public Shop_Items(string item_id)
        {
            InitializeComponent();

            item_code = item_id;

            Form_admin fa   = new Form_admin();
            string     conn = ConfigurationManager.ConnectionStrings["UCS_Starter.Properties.Settings.UCSConn"].ToString();

            SqlConnection connection = new SqlConnection(conn);

            try
            {
                SqlDataReader myReader = null;
                string        sql      = "SELECT * FROM NEW_SHOP('') WHERE [Type ID] = '" + item_id + "'";
                if (item_id == null)
                {
                    sql = "SELECT * FROM NEW_SHOP('')";
                }
                if (item_code == "All")
                {
                    sql = "SELECT * FROM NEW_SHOP('')";
                }

                SqlCommand myCommand = new SqlCommand(sql, connection);
                connection.Open();
                myReader = myCommand.ExecuteReader();
                while (myReader.Read())
                {
                    string Name   = (myReader["Item Code"].ToString());
                    string D_name = (myReader["Item Name"].ToString());
                    string im11   = fa.data_folder + "\\Item_150x150_tumb\\";
                    string Url    = im11 + (myReader["Image"].ToString());;
                    int    max    = (int)(myReader["Quantity"]);

                    if (max > 0)
                    {
                        Button newb = new Button();
                        newb.Name            = "BT" + Name;
                        newb.Text            = D_name;
                        newb.Width           = 150;
                        newb.Height          = 150;
                        newb.Font            = new Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        newb.ForeColor       = System.Drawing.SystemColors.ButtonHighlight;
                        newb.BackgroundImage = Image.FromFile(Url);
                        newb.Click          += (s, ec) =>
                        {
                            try
                            {
                                NumericUpDown btn1 = flowLayoutPanel1.Controls.Find("UD" + Name, true).FirstOrDefault() as NumericUpDown;
                                btn1.Value += 1;
                            }
                            catch (Exception ex3)
                            {
                                // Get reference to the dialog type.
                                var dialogTypeName = "System.Windows.Forms.PropertyGridInternal.GridErrorDlg";
                                var dialogType     = typeof(Form).Assembly.GetType(dialogTypeName);

                                // Create dialog instance.
                                var dialog = (Form)Activator.CreateInstance(dialogType, new PropertyGrid());

                                // Populate relevant properties on the dialog instance.
                                dialog.Text = "No Stock";
                                dialogType.GetProperty("Details").SetValue(dialog, ex3.ToString(), null);
                                dialogType.GetProperty("Message").SetValue(dialog, "Sorry! No Stock Available", null);

                                // Display dialog.
                                var result = dialog.ShowDialog();
                            }
                        };
                        flowLayoutPanel1.Controls.Add(newb);

                        NumericUpDown newud = new NumericUpDown();
                        newud.Name    = "UD" + Name;
                        newud.Width   = 150;
                        newud.Minimum = 0;
                        newud.Maximum = max;
                        flowLayoutPanel1.Controls.Add(newud);
                    }
                }
                connection.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message.ToString());
            }
        }
Пример #10
0
        public Discard(string item_code)
        {
            InitializeComponent();

            label5.Text = item_code;

            Form_admin fa   = new Form_admin();
            string     conn = ConfigurationManager.ConnectionStrings["UCS_Starter.Properties.Settings.UCSConn"].ToString();

            SqlConnection myConnection = new SqlConnection(conn);

            SqlCommand        sCommand;
            SqlDataAdapter    sAdapter;
            SqlCommandBuilder sBuilder;
            DataSet           sDs;
            DataTable         sTable;

            string        sql        = "SELECT * FROM Drop_Item_View('" + item_code + "')";
            SqlConnection connection = new SqlConnection(conn);

            connection.Open();
            sCommand = new SqlCommand(sql, connection);
            sAdapter = new SqlDataAdapter(sCommand);
            sBuilder = new SqlCommandBuilder(sAdapter);
            sDs      = new DataSet();
            sAdapter.Fill(sDs, "mytable");
            sTable = sDs.Tables["mytable"];
            connection.Close();
            dataGridView1.DataSource = sDs.Tables["mytable"];

            int sum = 0;

            foreach (DataRow dr in sDs.Tables["mytable"].Rows)
            {
                sum += Convert.ToInt32(dr["Quantity"]);
            }

            rem_sum = sum;

            label2.Text = "Total Quantity\n" + sum.ToString();

            string sql2 = "SELECT Quantity_Code, Item_Code, Quantity FROM Quantity WHERE Item_Code = ('" + item_code + "')";

            connection.Open();
            sCommand = new SqlCommand(sql2, connection);
            sAdapter = new SqlDataAdapter(sCommand);
            sBuilder = new SqlCommandBuilder(sAdapter);
            sDs      = new DataSet();
            sAdapter.Fill(sDs, "mytable");
            sTable = sDs.Tables["mytable"];
            connection.Close();
            dataGridView2.DataSource = sDs.Tables["mytable"];


            int sum2 = 0;

            foreach (DataRow dr in sDs.Tables["mytable"].Rows)
            {
                sum2 += Convert.ToInt32(dr["Quantity"]);
            }

            item_sum = sum2;

            label1.Text = "Total Quantity\n" + sum2.ToString();

            numericUpDown1.Maximum = (sum2 - sum);
            numericUpDown1.Minimum = 1;
            button1.Enabled        = false;

            label4.Text = "Updated Remaining  Quantity\n" + (sum2 - sum).ToString();

            //----------------------------------------------------------------------------------------------------


            try
            {
                SqlDataReader myReader = null;
                string        sql3     = "SELECT * FROM Items WHERE [Item_Code] = '" + item_code + "'";

                //MessageBox.Show(sql3);
                SqlCommand myCommand = new SqlCommand(sql3, connection);
                connection.Open();
                myReader = myCommand.ExecuteReader();
                while (myReader.Read())
                {
                    string D_name = (myReader["Item_Name"].ToString());
                    string im11   = fa.data_folder + "\\Item_150x150_tumb\\";
                    string Url    = im11 + (myReader["Item_img_ID"].ToString());;

                    label6.Text = D_name;
                    pictureBox1.Load(Url);
                }
                connection.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message.ToString());
            }
            //----------------------------------------------------------------------------------------------------
        }