Ejemplo n.º 1
0
        //------------------------------------------------METHODS--------------------------------------------------------------------
        public void refreshCategories()
        {
            //refresh categAndCode
            categAndCode    = new List <string> [2];
            categAndCode[0] = new List <string>();
            categAndCode[1] = new List <string>();


            this.Category.Items.Clear();
            string[]        columns = { "strCategCode", "strCategName" };
            List <object>[] result;
            result = dbConnect.Select("select strCategCode,strCategName from tblCategory where boolCategIsDel = false;", columns);
            for (int i = 0; i < result[0].Count; i++)
            {
                this.Category.Items.Add(result[1].ElementAt(i).ToString());
                //add to categ and code

                //code
                this.categAndCode[0].Add(result[0].ElementAt(i).ToString());
                //name
                this.categAndCode[1].Add(result[1].ElementAt(i).ToString());
            }
        }
Ejemplo n.º 2
0
        public void refreshDepartments()
        {
            this.DepartmentList.Rows.Clear();
            List <object>[] rs;
            string[]        columns = { "strDepCode", "strDepName" };
            rs = dbConnect.Select("Select * from tblDepartment where boolDepIsDel = false;", columns);

            for (int i = 0; i < rs[0].Count; i++)
            {
                this.DepartmentList.Rows.Add(rs[0].ElementAt(i).ToString(), rs[1].ElementAt(i).ToString());
            }
            //clear selection
            DepartmentList.ClearSelection();
        }
Ejemplo n.º 3
0
        public void refreshVendors()
        {
            this.VendorList.Rows.Clear();
            List <object>[] rs;
            string[]        columns = { "strVendCode", "strVendName" };
            rs = dbConnect.Select("Select * from tblVendor where boolVendIsDel = false;", columns);

            for (int i = 0; i < rs[0].Count; i++)
            {
                this.VendorList.Rows.Add(rs[0].ElementAt(i).ToString(), rs[1].ElementAt(i).ToString());
            }

            //clear selection
            VendorList.ClearSelection();
        }
Ejemplo n.º 4
0
        private void SendEmail_Click(object sender, EventArgs e)
        {
            string[]        columns = { "strNameCode", "strNameFName", "strNameMName", "strNameLName", "strNameEmail" };
            List <object>[] rs;
            rs = dbConnect.Select("select * from tblName where boolNameIsDel = false;", columns);
            string expectedReturnDate = "";
            string beforeReturnDate   = "";
            string notificationDate   = "";

            bool haveNet = true;

            for (int i = 0; i < rs[0].Count; i++)
            {
                string bcode     = rs[0].ElementAt(i).ToString();
                string borremail = rs[4].ElementAt(i).ToString();
                //-----///string bfname = rs[3].ElementAt(i).ToString() + ", " + rs[1].ElementAt(i).ToString() + " " + rs[2].ElementAt(i).ToString();
                string          blname   = rs[3].ElementAt(i).ToString();
                string[]        columns2 = { "strItemName", "dtmBorHDateBorrowed", "strBorDBorHCode", "strBorDCode" };
                List <object>[] rs2;
                rs2 = dbConnect.Select("select * from tblborrowheader inner join tblborrowdetail on(tblborrowheader.strBorHCode = tblborrowdetail.strBorDBorHCode) inner join tblasset on(tblborrowdetail.strBorDAsseCode = tblasset.strAsseCode) inner join tblitemtype on(tblasset.strAsseItemCode = tblitemtype.strItemCode) where tblborrowheader.strBorHNameCode = '" + bcode + "' and tblborrowdetail.dtmBorDDateReturned is null;", columns2);


                for (int n = 0; n < rs2[0].Count; n++)
                {
                    expectedReturnDate = getExpectedReturnDate(Convert.ToDateTime(rs2[1].ElementAt(n).ToString()).ToString("yyyy-MM-dd"));
                    DateTime expectedreturndate2 = Convert.ToDateTime(expectedReturnDate);
                    beforeReturnDate = expectedreturndate2.AddDays(-3).ToString("yyyy-MM-dd");
                    notificationDate = DateTime.Today.ToString("yyyy-MM-dd");

                    if (notificationDate == beforeReturnDate)
                    {
                        try
                        {
                            var          fromAddress  = new MailAddress(thisemailadd, "From Name");
                            var          toAddress    = new MailAddress(borremail, "To Name");
                            string       fromPassword = emailpass;
                            const string subject      = "3days Before Overdue Notification";
                            string       body         = "Dear " + blname + ",\n\n" + message1;

                            var smtp = new SmtpClient
                            {
                                Host           = "smtp.gmail.com",
                                Port           = 587,
                                EnableSsl      = true,
                                DeliveryMethod = SmtpDeliveryMethod.Network,
                                Credentials    = new NetworkCredential(fromAddress.Address, fromPassword),
                                Timeout        = 20000
                            };
                            using (var message = new MailMessage(fromAddress, toAddress)
                            {
                                Subject = subject,
                                Body = body
                            })
                            {
                                smtp.Send(message);
                            }
                        }
                        catch {
                            haveNet = false;
                            break;
                        }
                    }
                }
                if (!haveNet)
                {
                    MessageBox.Show("No internet connection");
                    break;
                }
            }
            if (haveNet)
            {
                MessageBox.Show("Send Successful");
                allow = 0;
                this.Close();
            }
        }
Ejemplo n.º 5
0
        //-----------------------------------------METHODS------------------------------------------------------------------
        //----------------------------------DATA GRID---------------------------------------------------------------------
        public void refreshCategories()
        {
            this.CategoryList.Rows.Clear();
            List <object>[] rs;
            string[]        columns = { "strCategCode", "strCategName" };
            rs = dbConnect.Select("Select * from tblCategory where boolCategIsDel = false;", columns);

            for (int i = 0; i < rs[0].Count; i++)
            {
                this.CategoryList.Rows.Add(rs[0].ElementAt(i).ToString(), rs[1].ElementAt(i).ToString());
            }

            //clear selection
            CategoryList.ClearSelection();
        }