Example #1
0
 public FrmCompany(Guid?id = null, bool canEdit = true)
 {
     InitializeComponent();
     btnSaveNew.Enabled = btnSaveClose.Enabled = canEdit;
     if (!id.Equals(null))
     {
         companyID = (Guid)id;
         string     query = string.Format("SELECT * FROM COMPANY WHERE ID='{0}'", id);
         SqlCommand cmd   = new SqlCommand(query, Connect.ToDatabase());
         cmd.CommandTimeout = 10000;
         var reader = cmd.ExecuteReader();
         int i      = reader.FieldCount;
         if (reader.HasRows)
         {
             while (reader.Read())
             {
                 this.Text             = this.Text + companyID;
                 txtNameInKhmer.Text   = reader["NameInKhmer"].ToString();
                 txtNameInEnglish.Text = reader["NameInEnglish"].ToString();
                 txtEmail.Text         = reader["Email"].ToString();
                 txtPhone.Text         = reader["Phone"].ToString();
                 txtLocation.Text      = reader["Location"].ToString();
                 chkActive.Checked     = bool.Parse(reader["Active"].ToString());
                 myPicture1.SetImage(Helpers.ByteArrayToImage(SelectPicture.GetPhoto("Logo", "COMPANY", companyID)));
             }
         }
         reader.Close();
     }
 }
Example #2
0
 public FrmStudent(Guid?id = null, bool canEdit = true)
 {
     InitializeComponent();
     btnSaveNew.Enabled = btnSaveClose.Enabled = canEdit;
     if (!id.Equals(null))
     {
         StudentID = (Guid)id;
         string     query = string.Format("SELECT * FROM tbStudent WHERE ID='{0}'", id);
         SqlCommand cmd   = new SqlCommand(query, Connect.ToDatabase());
         cmd.CommandTimeout = 10000;
         var reader = cmd.ExecuteReader();
         int i      = reader.FieldCount;
         if (reader.HasRows)
         {
             while (reader.Read())
             {
                 this.Text           = this.Text + StudentID;
                 txtStudentID.Text   = reader["StudentID"].ToString();
                 txtStudentName.Text = reader["FullName"].ToString();
                 if (rdWomen.Text.Equals(reader["Gender"].ToString()))
                 {
                     rdWomen.Checked = true;
                 }
                 else
                 {
                     rdMan.Checked = true;
                 }
                 dtpBirthDate.Text    = reader["BirthDate"].ToString();
                 txtBirthPlace.Text   = reader["BirthPlace"].ToString();
                 txtFatherName.Text   = reader["FatherName"].ToString();
                 txtFatherJob.Text    = reader["FatherJob"].ToString();
                 txtMotherName.Text   = reader["MotherName"].ToString();
                 txtMotherJob.Text    = reader["MotherJob"].ToString();
                 txtCurrentPlace.Text = reader["CurrentPlace"].ToString();
                 txtContact.Text      = reader["Contact"].ToString();
                 byte[] ph = SelectPicture.GetPhoto("Photo", "tbStudent", StudentID);
                 myPicture1.SetImage(Helpers.ByteArrayToImage(ph));
                 chkActive.Checked = bool.Parse(reader["Active"].ToString());
             }
         }
         reader.Close();
     }
 }
Example #3
0
        public static CustomerEntity GetByID(Guid?id)
        {
            CustomerEntity customerEntity = new CustomerEntity();

            try
            {
                string     query = string.Format("SELECT*FROM CUSTOMER WHERE ID='{0}'", id);
                SqlCommand cmd   = new SqlCommand(query, Connect.ToDatabase());
                cmd.CommandTimeout = 10000;
                var reader = cmd.ExecuteReader();
                int i      = reader.FieldCount;
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        customerEntity.ID           = (Guid)reader["ID"];
                        customerEntity.CustomerName = reader["CustomerName"].ToString();
                        customerEntity.Gender       = reader["Gender"].ToString();
                        customerEntity.Address      = reader["Address"].ToString();
                        customerEntity.Active       = bool.Parse(reader["Active"].ToString());
                        customerEntity.OtherContact = reader["OtherContact"].ToString();
                        customerEntity.MemberShipID = (Guid)reader["MemberShipID"];
                        customerEntity.Photo        = SelectPicture.GetPhoto("Photo", "CUSTOMER", customerEntity.ID);
                    }
                }
                reader.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
                if (Connect.ToDatabase().State != ConnectionState.Closed)
                {
                    Connect.ToDatabase().Close();
                }
            }
            return(customerEntity);
        }
Example #4
0
        public static ProductEntity GetById(Guid?id)
        {
            ProductEntity productEntity = new ProductEntity();

            try
            {
                string     query = string.Format("SELECT * FROM PRODUCT WHERE ID='{0}'", id);
                SqlCommand cmd   = new SqlCommand(query, Connect.ToDatabase());
                cmd.CommandTimeout = 10000;
                var reader = cmd.ExecuteReader();
                int i      = reader.FieldCount;
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        productEntity.Id          = (Guid)reader["ID"];
                        productEntity.CategoryId  = (Guid)reader["CategoryID"];
                        productEntity.ProductName = reader["ProductName"].ToString();
                        productEntity.Price       = decimal.Parse(reader["Price"].ToString());
                        productEntity.Quantity    = int.Parse(reader["Quantity"].ToString());
                        productEntity.MadeDate    = DateTime.Parse(reader["MadeDate"].ToString());
                        productEntity.ExpireDate  = DateTime.Parse(reader["ExpireDate"].ToString());
                        productEntity.Barcode     = reader["Barcode"].ToString();
                        productEntity.Active      = bool.Parse(reader["Active"].ToString());
                        productEntity.Photo       = SelectPicture.GetPhoto("Photo", "PRODUCT", productEntity.Id);
                    }
                }
                reader.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
                Connect.Close();
            }
            return(productEntity);
        }
Example #5
0
        public static CompanyEntity GetById(Guid?id)
        {
            CompanyEntity companyEntity = new CompanyEntity();

            try
            {
                string     query = string.Format("SELECT * FROM COMPANY WHERE ID='{0}'", id);
                SqlCommand cmd   = new SqlCommand(query, Connect.ToDatabase());
                cmd.CommandTimeout = 10000;
                var reader = cmd.ExecuteReader();
                int i      = reader.FieldCount;
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        companyEntity.Id            = (Guid)reader["ID"];
                        companyEntity.NameInEnglish = reader["NameInEnglish"].ToString();
                        companyEntity.NameInKhmer   = reader["NameInKhmer"].ToString();
                        companyEntity.Email         = reader["Email"].ToString();
                        companyEntity.Phone         = reader["Phone"].ToString();
                        companyEntity.Location      = reader["Location"].ToString();
                        companyEntity.Active        = bool.Parse(reader["Active"].ToString());
                        companyEntity.Logo          = SelectPicture.GetPhoto("Logo", "COMPANY", companyEntity.Id);
                    }
                }
                reader.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
                Connect.Close();
            }
            return(companyEntity);
        }
Example #6
0
 public static byte[] GetPhoto(Guid id)
 {
     return(SelectPicture.GetPhoto("Logo", "COMPANY", id));
 }
Example #7
0
 public static byte[] GetPhoto(Guid id)
 {
     return(SelectPicture.GetPhoto("Photo", "PRODUCT", id));
 }