Exemplo n.º 1
0
        public static List <GlaccDbf> GetGlaccList(SccompDbf sccomp)
        {
            List <GlaccDbf> glacc = new List <GlaccDbf>();

            if (!Directory.Exists(sccomp.GetAbsolutePath()))
            {
                XMessageBox.Show("ค้นหาไดเร็คทอรี่ " + sccomp.GetAbsolutePath() + " ไม่พบ", "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
                return(glacc);
            }
            else
            {
                using (OleDbConnection conn = DbfTable.GetConnection(sccomp.GetAbsolutePath()))
                {
                    OleDbCommand cmd = conn.CreateCommand();
                    cmd.CommandText = "Select * From glacc Order By accnum ASC";

                    DataTable dt = new DataTable();
                    conn.Open();
                    using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
                    {
                        da.Fill(dt);
                        conn.Close();
                        foreach (DataRow row in dt.Rows)
                        {
                            int indent_space = !row.IsNull("level") ? (Convert.ToInt32(row.Field <decimal>("level")) - 1) * 4 : 0;

                            glacc.Add(new GlaccDbf
                            {
                                accnam  = !row.IsNull("accnam") ? row.Field <string>("accnam").TrimEnd().AddIndent(indent_space) : string.Empty,
                                accnam2 = !row.IsNull("accnam2") ? row.Field <string>("accnam2").TrimEnd().AddIndent(indent_space) : string.Empty,
                                accnum  = !row.IsNull("accnum") ? row.Field <string>("accnum").TrimEnd() : string.Empty,
                                acctyp  = !row.IsNull("acctyp") ? row.Field <string>("acctyp").TrimEnd() : string.Empty,
                                group   = !row.IsNull("group") ? row.Field <string>("group").TrimEnd() : string.Empty,
                                level   = !row.IsNull("level") ? row.Field <decimal>("level") : -1,
                                nature  = !row.IsNull("nature") ? row.Field <string>("nature").TrimEnd() : string.Empty,
                                parent  = !row.IsNull("parent") ? row.Field <string>("parent").TrimEnd() : string.Empty,
                                status  = !row.IsNull("status") ? row.Field <string>("status").TrimEnd() : string.Empty,
                                usedep  = !row.IsNull("usedep") ? row.Field <string>("usedep").TrimEnd() : string.Empty
                            });
                        }
                    }
                }
                return(glacc);
            }
        }
Exemplo n.º 2
0
        public static IsinfoDbf GetIsinfo(SccompDbf sccomp)
        {
            if (!Directory.Exists(sccomp.GetAbsolutePath()))
            {
                XMessageBox.Show("ค้นหาไดเร็คทอรี่ " + sccomp.GetAbsolutePath() + " ไม่พบ", "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
                return(null);
            }
            else
            {
                using (OleDbConnection conn = DbfTable.GetConnection(sccomp.GetAbsolutePath()))
                {
                    OleDbCommand cmd = conn.CreateCommand();
                    cmd.CommandText = "Select * From isinfo";

                    DataTable dt = new DataTable();
                    conn.Open();
                    using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
                    {
                        da.Fill(dt);
                        conn.Close();
                        if (dt.Rows.Count == 0)
                        {
                            return(null);
                        }


                        return(new IsinfoDbf
                        {
                            addr01 = !dt.Rows[0].IsNull("addr01") ? dt.Rows[0].Field <string>("addr01").TrimEnd() : string.Empty,
                            addr01eng = !dt.Rows[0].IsNull("addr01eng") ? dt.Rows[0].Field <string>("addr01eng").TrimEnd() : string.Empty,
                            addr02 = !dt.Rows[0].IsNull("addr02") ? dt.Rows[0].Field <string>("addr02").TrimEnd() : string.Empty,
                            addr02eng = !dt.Rows[0].IsNull("addr02eng") ? dt.Rows[0].Field <string>("addr02eng").TrimEnd() : string.Empty,
                            engnam = !dt.Rows[0].IsNull("engnam") ? dt.Rows[0].Field <string>("engnam").TrimEnd() : string.Empty,
                            taxid = !dt.Rows[0].IsNull("taxid") ? dt.Rows[0].Field <string>("taxid").TrimEnd() : string.Empty,
                            telnum = !dt.Rows[0].IsNull("telnum") ? dt.Rows[0].Field <string>("telnum").TrimEnd() : string.Empty,
                            thinam = !dt.Rows[0].IsNull("thinam") ? dt.Rows[0].Field <string>("thinam").TrimEnd() : string.Empty,
                            trdreg = !dt.Rows[0].IsNull("trdreg") ? dt.Rows[0].Field <string>("trdreg").TrimEnd() : string.Empty,
                        });
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static List <SccompDbf> GetSccompList()
        {
            List <SccompDbf> sccomp = new List <SccompDbf>();

            if (!Directory.Exists(DbfTable.secure_path))
            {
                XMessageBox.Show("ค้นหาไดเร็คทอรี่ Secure ไม่พบ, \n    อาจเป็นเพราะท่านติดตั้งโปรแกรม Express e-Filing ไว้ในตำแหน่งที่ไม่ถูกต้อง", "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
                return(sccomp);
            }
            else
            {
                using (OleDbConnection conn = DbfTable.GetConnection(secure_path) /*new OleDbConnection(@"Provider=VFPOLEDB.1;Data Source=" + secure_path)*/)
                {
                    OleDbCommand cmd = conn.CreateCommand();
                    cmd.CommandText = "Select * From sccomp Order By compnam ASC";

                    DataTable dt = new DataTable();
                    conn.Open();
                    using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
                    {
                        da.Fill(dt);
                        conn.Close();
                        foreach (DataRow row in dt.Rows)
                        {
                            sccomp.Add(new SccompDbf
                            {
                                candel  = !row.IsNull("candel") ? row.Field <string>("candel").TrimEnd() : string.Empty,
                                compcod = !row.IsNull("compcod") ? row.Field <string>("compcod").TrimEnd() : string.Empty,
                                compnam = !row.IsNull("compnam") ? row.Field <string>("compnam").TrimEnd() : string.Empty,
                                gendat  = !row.IsNull("gendat") ? (DateTime?)row.Field <DateTime>("gendat") : null,
                                path    = !row.IsNull("path") ? row.Field <string>("path").TrimEnd() : string.Empty
                            });
                        }
                    }
                }

                return(sccomp);
            }
        }