public static options GetOptions(this OPTIONS options_key, SccompDbf selected_comp)
        {
            try
            {
                using (LocalDbEntities db = DBX.DataSet(selected_comp))
                {
                    options opt = db.options.Where(o => o.key == options_key.ToString()).FirstOrDefault();

                    if (opt != null)
                    {
                        return(opt);
                    }
                    else
                    {
                        options o = new options {
                            key = options_key.ToString()
                        };
                        db.options.Add(o);
                        db.SaveChanges();
                        return(o);
                    }
                }
            }
            catch (Exception ex)
            {
                XMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
                return(null);
            }
        }
        private void SetDropdownItem()
        {
            this.cShType._Items.Add(new XDropdownListItem {
                Text = "บุคคลธรรมดา", Value = SHARE_HOLDER_TYPE.P.ToString()
            });
            this.cShType._Items.Add(new XDropdownListItem {
                Text = "นิติบุคคล", Value = SHARE_HOLDER_TYPE.C.ToString()
            });

            string nationality_file_path = AppDomain.CurrentDomain.BaseDirectory + @"Template\nationality.json";

            if (File.Exists(nationality_file_path))
            {
                JsonConvert.DeserializeObject <List <nationality_VM> >(File.ReadAllText(nationality_file_path)).OrderBy(n => n.nationality_code).ToList().ForEach(n =>
                {
                    this.cNationality._Items.Add(new XDropdownListItem {
                        Text = n.nationality_code + " : " + n.nationality_name_th, Value = n
                    });
                });
            }
            else
            {
                XMessageBox.Show("ค้นหาแฟ้ม nationality.json ไม่พบ", "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
                return;
            }
        }
        public static int SaveOptions(this options options_to_save, SccompDbf selected_comp)
        {
            try
            {
                using (LocalDbEntities db = DBX.DataSet(selected_comp))
                {
                    options option = db.options.Where(o => o.key == options_to_save.key).FirstOrDefault();
                    if (option != null) // update
                    {
                        option.value_datetime = options_to_save.value_datetime;
                        option.value_num      = options_to_save.value_num;
                        option.value_str      = options_to_save.value_str;

                        return(db.SaveChanges());
                    }
                    else // add new
                    {
                        db.options.Add(options_to_save);
                        return(db.SaveChanges());
                    }
                }
            }
            catch (Exception ex)
            {
                XMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
                return(0);
            }
        }
Beispiel #4
0
        private void btnPreview_Click(object sender, EventArgs e)
        {
            try
            {
                this.query_model = JsonConvert.DeserializeObject <QueryModel>(this.TextArea.Text);

                if (this.query_model != null)
                {
                    DialogReportScope scope = new DialogReportScope(this, this.query_model, this.default_data_path);
                    if (scope.ShowDialog() == DialogResult.OK)
                    {
                        DialogDisplayDataTable dt = new DialogDisplayDataTable(scope.data_table);
                        dt.ShowDialog();
                    }
                }
                else
                {
                    XMessageBox.Show("Syntax error", "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
                    return;
                }
            }
            catch (Exception ex)
            {
                XMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
                return;
            }
        }
Beispiel #5
0
        //public SQLiteDbPrepare(SccompDbf sccomp) :
        //    base(new SQLiteConnection()
        //    {
        //        ConnectionString = new SQLiteConnectionStringBuilder() { DataSource = sccomp.GetAbsolutePath() + taxonomy_matching_file_name, ForeignKeys = true }.ConnectionString
        //    }, true)
        //{

        //}

        //protected override void OnModelCreating(DbModelBuilder modelBuilder)
        //{
        //    modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        //    base.OnModelCreating(modelBuilder);
        //}

        //public DbSet<boj5_header> boj5_header { get; set; }
        //public DbSet<boj5_person> boj5_person { get; set; }
        //public DbSet<boj5_detail> boj5_detail { get; set; }
        //public DbSet<glacc_match> glacc_match { get; set; }

        public static void EnsureDbCreated(SccompDbf sccomp)
        {
            try
            {
                if (!Directory.Exists(sccomp.GetAbsolutePath()))
                {
                    XMessageBox.Show("ค้นหาไดเร็คทอรี่ " + sccomp.GetAbsolutePath() + " ไม่พบ", "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
                    return;
                }

                if (!File.Exists(sccomp.GetAbsolutePath() + SQLiteDbPrepare.taxonomy_matching_file_name))
                {
                    SQLiteConnection.CreateFile(sccomp.GetAbsolutePath() + SQLiteDbPrepare.taxonomy_matching_file_name);

                    using (SQLiteConnection connection = new SQLiteConnection(@"Data Source=" + sccomp.GetAbsolutePath() + SQLiteDbPrepare.taxonomy_matching_file_name + @";Version=3;"))
                    {
                        using (SQLiteCommand cmd = connection.CreateCommand())
                        {
                            cmd.CommandText = "CREATE TABLE IF NOT EXISTS glacc_match(id INTEGER PRIMARY KEY, accnum TEXT, depcod TEXT, taxodesc TEXT, taxodesc2 TEXT)";

                            connection.Open();
                            cmd.ExecuteNonQuery();
                            connection.Close();
                        }
                    }
                }

                UpgradeDB(sccomp);
            }
            catch (Exception ex)
            {
                XMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
            }
        }
        public static void ExtractZipFile(string archiveFilenameIn, string password, string outFolder)
        {
            ZipFile zf = null;

            try
            {
                FileStream fs = File.OpenRead(archiveFilenameIn);
                zf = new ZipFile(fs);
                if (!String.IsNullOrEmpty(password))
                {
                    zf.Password = password;     // AES encrypted entries are handled automatically
                }
                foreach (ZipEntry zipEntry in zf)
                {
                    if (!zipEntry.IsFile)
                    {
                        continue;           // Ignore directories
                    }
                    String entryFileName = zipEntry.Name;
                    // to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName);
                    // Optionally match entrynames against a selection list here to skip as desired.
                    // The unpacked length is available in the zipEntry.Size property.

                    byte[] buffer    = new byte[4096];  // 4K is optimum
                    Stream zipStream = zf.GetInputStream(zipEntry);

                    // Manipulate the output filename here as desired.
                    String fullZipToPath = Path.Combine(outFolder, entryFileName);
                    string directoryName = Path.GetDirectoryName(fullZipToPath);
                    if (directoryName.Length > 0)
                    {
                        Directory.CreateDirectory(directoryName);
                    }

                    // Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size
                    // of the file, but does not waste memory.
                    // The "using" will close the stream even if an exception occurs.
                    using (FileStream streamWriter = File.Create(fullZipToPath))
                    {
                        StreamUtils.Copy(zipStream, streamWriter, buffer);
                    }
                }
            }
            catch (Exception ex)
            {
                XMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
                return;
            }
            finally
            {
                if (zf != null)
                {
                    zf.IsStreamOwner = true; // Makes close also shut the underlying stream
                    zf.Close();              // Ensure we release resources
                }
            }
        }
Beispiel #7
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     if (XMessageBox.Show("ยกเลิกการแก้ไขข้อมูล, ทำต่อหรือไม่?", "", MessageBoxButtons.OKCancel, XMessageBoxIcon.Question) == DialogResult.OK)
     {
         this.tmp_boj5_header = null;
         this.GetBojData();
         this.FillForm(this.boj5_header, this.boj5_detail);
         this.ResetFormState(FORM_MODE.READ);
     }
 }
Beispiel #8
0
 public static OleDbConnection GetConnection(string data_path)
 {
     if (!Directory.Exists(data_path))
     {
         XMessageBox.Show("ค้นหาไดเร็คทอรี่ " + data_path + " ไม่พบ", "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
         return(null);
     }
     else
     {
         return(new OleDbConnection(@"Provider=VFPOLEDB.1;Data Source=" + data_path));
     }
 }
        private void btnDown_Click(object sender, EventArgs e)
        {
            if (this.dgvPerson.CurrentCell.RowIndex == this.dgvPerson.Rows.Count - 1 || this.dgvPerson.Rows.Count <= 1)
            {
                return;
            }

            using (LocalDbEntities db = DBX.DataSet(this.main_form.selected_comp))
            {
                if (db.boj5_person.Count() <= 1)
                {
                    return;
                }

                var curr_person = db.boj5_person.Find(((boj5_person)(this.dgvPerson).Rows[this.dgvPerson.CurrentCell.RowIndex].Cells[this.col_boj5_person.Name].Value).id);
                if (curr_person == null)
                {
                    XMessageBox.Show("ค้นหารายการที่ต้องการแก้ไขไม่พบ", "", MessageBoxButtons.OK, XMessageBoxIcon.Stop);
                    return;
                }

                var next_person = db.boj5_person.Where(p => p.itemSeq > curr_person.itemSeq).OrderBy(p => p.itemSeq).FirstOrDefault();
                if (next_person == null)
                {
                    XMessageBox.Show("รายการนี้อยู่ในลำดับสุดท้ายแล้ว ไม่สามารถเลื่อนลงได้อีก", "", MessageBoxButtons.OK, XMessageBoxIcon.Stop);
                    return;
                }

                long?curr_seq = curr_person.itemSeq;
                long?next_seq = next_person.itemSeq;
                curr_person.itemSeq = next_seq;
                next_person.itemSeq = curr_seq;
                db.SaveChanges();

                long?seq = 0;
                db.boj5_detail.Include("boj5_person").OrderBy(d => d.boj5_person.itemSeq).ToList().ForEach(d => d.itemNo = ++seq);
                db.SaveChanges();

                this.LoadPersonToDatagrid();

                var selected_row = this.dgvPerson.Rows.Cast <DataGridViewRow>().Where(r => ((boj5_person)r.Cells[this.col_boj5_person.Name].Value).id == curr_person.id).FirstOrDefault();
                if (selected_row != null)
                {
                    selected_row.Cells[selected_row.DataGridView.FirstDisplayedScrollingColumnIndex].Selected = true;
                }
            }
        }
Beispiel #10
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.data_path == null)
            {
                XMessageBox.Show("กรุณาระบุที่เก็บข้อมูล", "", MessageBoxButtons.OK, XMessageBoxIcon.Stop);
                return;
            }

            if (!(File.Exists(this.data_path + @"\armas.dbf") && File.Exists(this.data_path + @"\apmas.dbf") && File.Exists(this.data_path + @"\stmas.dbf") && File.Exists(this.data_path + @"\glacc.dbf") && File.Exists(this.data_path + @"\oeslm.dbf") && File.Exists(this.data_path + @"\istab.dbf")))
            {
                XMessageBox.Show("กรุณาระบุที่เก็บข้อมูลให้ถูกต้อง", "", MessageBoxButtons.OK, XMessageBoxIcon.Stop);
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Beispiel #11
0
        private void btnBrowseZipFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.InitialDirectory = this.selected_comp.GetAbsolutePath();
            ofd.Filter           = "Zip File|*.zip|All File|*.*";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                if (HelperClass.GetFileNameListInZip(ofd.FileName).Where(f => f.ToLower() == "dimension_static.xml").Count() < 1)
                {
                    XMessageBox.Show("Zip file ที่ท่านเลือกไม่ใช่ไฟล์รูปแบบงบการเงิน กรุณาเลือกใหม่ให้ถูกต้อง", "", MessageBoxButtons.OK, XMessageBoxIcon.Stop);
                    return;
                }

                this.cZipFilePath.Text = ofd.FileName;
            }
        }
Beispiel #12
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);
            }
        }
Beispiel #13
0
        private void btnDeleteItem_Click(object sender, EventArgs e)
        {
            if (this.dgv.CurrentCell == null)
            {
                return;
            }

            this.dgv.Rows[this.dgv.CurrentCell.RowIndex].DrawDeletingRowOverlay();
            if (XMessageBox.Show("ลบรายการที่เลือก, ทำต่อหรือไม่?", "", MessageBoxButtons.OKCancel, XMessageBoxIcon.Question) != DialogResult.OK)
            {
                this.dgv.Rows[this.dgv.CurrentCell.RowIndex].ClearDeletingRowOverlay();
                return;
            }

            var deleting_id = ((boj5_detail)this.dgv.Rows[this.dgv.CurrentCell.RowIndex].Cells[this.col_boj5_detail.Name].Value).id;

            try
            {
                using (LocalDbEntities db = DBX.DataSet(this.main_form.selected_comp))
                {
                    var deleting_data = db.boj5_detail.Find(deleting_id);
                    if (deleting_data != null)
                    {
                        db.boj5_detail.Remove(deleting_data);
                        db.SaveChanges();

                        long?seq = 0;
                        db.boj5_detail.Include("boj5_person").OrderBy(d => d.boj5_person.itemSeq).ToList().ForEach(d => d.itemNo = ++seq);
                        db.SaveChanges();

                        this.GetBojData();
                        this.FillForm(this.boj5_header, this.boj5_detail);
                    }
                    else
                    {
                        XMessageBox.Show("ค้นหารายการที่ต้องการลบไม่พบ", "", MessageBoxButtons.OK, XMessageBoxIcon.Stop);
                    }
                }
            }
            catch (Exception ex)
            {
                XMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
            }
        }
Beispiel #14
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,
                        });
                    }
                }
            }
        }
Beispiel #15
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.tmp_boj5_header == null)
            {
                return;
            }
            try
            {
                using (LocalDbEntities db = DBX.DataSet(this.main_form.selected_comp))
                {
                    var header_to_update = db.boj5_header.Find(1);
                    header_to_update.accSource          = this.tmp_boj5_header.accSource;
                    header_to_update.foreignShareholder = this.tmp_boj5_header.foreignShareholder;
                    header_to_update.headerStatus       = this.tmp_boj5_header.headerStatus;
                    header_to_update.meetingNo          = this.tmp_boj5_header.meetingNo;
                    header_to_update.meetingType        = this.tmp_boj5_header.meetingType;
                    header_to_update.parValue           = this.tmp_boj5_header.parValue;
                    header_to_update.sourceDate         = this.tmp_boj5_header.sourceDate;
                    header_to_update.thaiShareholder    = this.tmp_boj5_header.thaiShareholder;
                    header_to_update.totalCapital       = this.tmp_boj5_header.totalCapital;
                    header_to_update.totalForeignShare  = this.tmp_boj5_header.totalForeignShare;
                    header_to_update.totalShare         = this.tmp_boj5_header.totalShare;
                    header_to_update.totalThaiShare     = this.tmp_boj5_header.totalThaiShare;
                    header_to_update.userId             = this.tmp_boj5_header.userId;
                    header_to_update.yearEnd            = this.tmp_boj5_header.yearEnd;

                    db.SaveChanges();
                }

                this.tmp_boj5_header = null;
                this.ResetFormState(FORM_MODE.READ);
                this.GetBojData();
                this.FillForm(this.boj5_header, this.boj5_detail);
            }
            catch (Exception ex)
            {
                XMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
            }
        }
Beispiel #16
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);
            }
        }
Beispiel #17
0
 private void btnCommonButton_Click(object sender, EventArgs e)
 {
     XMessageBox.Show("常规按钮单击", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Beispiel #18
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (this.tag_xml == null || this.tag_xml.Count == 0)
            {
                XMessageBox.Show("กรุณาระบุที่เก็บไฟล์รูปแบบงบการเงินก่อน", "", MessageBoxButtons.OK, XMessageBoxIcon.Warning);
                this.btnBrowseZipFile.PerformClick();
                return;
            }

            if (this.form_mode == FORM_MODE.EDIT)
            {
                return;
            }

            if (this.tabControl1.SelectedTab == this.tabAsset)
            {
                if (this.dgv1.CurrentCell == null)
                {
                    return;
                }

                string acctyp = ((GlaccDbf)this.dgv1.Rows[this.dgv1.CurrentCell.RowIndex].Cells[this.col1_glacc.Name].Value).acctyp;
                if (acctyp == "1")
                {
                    return;
                }

                this.ShowInlineForm();
            }

            if (this.tabControl1.SelectedTab == this.tabLiability)
            {
                if (this.dgv2.CurrentCell == null)
                {
                    return;
                }

                string acctyp = ((GlaccDbf)this.dgv2.Rows[this.dgv2.CurrentCell.RowIndex].Cells[this.col2_glacc.Name].Value).acctyp;
                if (acctyp == "1")
                {
                    return;
                }

                this.ShowInlineForm();
            }

            if (this.tabControl1.SelectedTab == this.tabEquity)
            {
                if (this.dgv3.CurrentCell == null)
                {
                    return;
                }

                string acctyp = ((GlaccDbf)this.dgv3.Rows[this.dgv3.CurrentCell.RowIndex].Cells[this.col3_glacc.Name].Value).acctyp;
                if (acctyp == "1")
                {
                    return;
                }

                this.ShowInlineForm();
            }

            if (this.tabControl1.SelectedTab == this.tabRevenue)
            {
                if (this.dgv4.CurrentCell == null)
                {
                    return;
                }

                string acctyp = ((GlaccDbf)this.dgv4.Rows[this.dgv4.CurrentCell.RowIndex].Cells[this.col4_glacc.Name].Value).acctyp;
                if (acctyp == "1")
                {
                    return;
                }

                this.ShowInlineForm();
            }

            if (this.tabControl1.SelectedTab == this.tabExpense)
            {
                if (this.dgv5.CurrentCell == null)
                {
                    return;
                }

                string acctyp = ((GlaccDbf)this.dgv5.Rows[this.dgv5.CurrentCell.RowIndex].Cells[this.col5_glacc.Name].Value).acctyp;
                if (acctyp == "1")
                {
                    return;
                }

                this.ShowInlineForm();
            }

            this.ResetFormState(FORM_MODE.EDIT);
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.boj5_person.shType.Trim().Length == 0)
            {
                XMessageBox.Show("กรุณาระบุประเภทของผู้ถือหุ้น", "", MessageBoxButtons.OK, XMessageBoxIcon.Warning);
                this.cShType.Focus();
                return;
            }

            if (this.boj5_person.holderName.Trim().Length == 0)
            {
                XMessageBox.Show("กรุณาระบุชื่อผู้ถือหุ้น", "", MessageBoxButtons.OK, XMessageBoxIcon.Warning);
                this.cHolderName.Focus();
                return;
            }

            if (this.boj5_person.nationality.Trim().Length == 0)
            {
                XMessageBox.Show("กรุณาระบุสัญชาติของผู้ถือหุ้น", "", MessageBoxButtons.OK, XMessageBoxIcon.Warning);
                this.cNationality.Focus();
                return;
            }

            if (this.boj5_person.shId.Trim().Length == 0)
            {
                XMessageBox.Show("กรุณาระบุเลขนิติบุคคล/บัตรประชาชน", "", MessageBoxButtons.OK, XMessageBoxIcon.Warning);
                this.cShId.Focus();
                return;
            }
            try
            {
                using (LocalDbEntities db = DBX.DataSet(this.main_form.selected_comp))
                {
                    if (this.boj5_person.id > 0) // edit
                    {
                        var data_to_update = db.boj5_person.Find(this.boj5_person.id);
                        if (data_to_update == null)
                        {
                            db.boj5_person.Add(this.boj5_person);
                        }
                        else
                        {
                            data_to_update.addrForeign = this.boj5_person.addrForeign;
                            data_to_update.addrFull    = this.boj5_person.addrFull;
                            data_to_update.addrNo      = this.boj5_person.addrNo;
                            data_to_update.amphur      = this.boj5_person.amphur;
                            data_to_update.holderName  = this.boj5_person.holderName;
                            data_to_update.itemSeq     = this.boj5_person.itemSeq;
                            data_to_update.moo         = this.boj5_person.moo;
                            data_to_update.nationality = this.boj5_person.nationality;
                            data_to_update.occupation  = this.boj5_person.occupation;
                            data_to_update.province    = this.boj5_person.province;
                            data_to_update.road        = this.boj5_person.road;
                            data_to_update.shId        = this.boj5_person.shId;
                            data_to_update.shType      = this.boj5_person.shType;
                            data_to_update.soi         = this.boj5_person.soi;
                            data_to_update.surname     = this.boj5_person.surname;
                            data_to_update.title       = this.boj5_person.title;
                            data_to_update.tumbol      = this.boj5_person.tumbol;
                        }
                    }
                    else // add
                    {
                        db.boj5_person.Add(this.boj5_person);
                    }
                    db.SaveChanges();

                    long?seq = 0;
                    db.boj5_person.ToList().ForEach(p => p.itemSeq = ++seq);
                    db.SaveChanges();

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                XMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.boj5_detail.shareDocId.Trim().Length == 0)
            {
                XMessageBox.Show("กรุณาระบุหมายเลขใบหุ้น", "", MessageBoxButtons.OK, XMessageBoxIcon.Warning);
                this.cShareDocId.Focus();
                return;
            }

            if (this.boj5_detail.boj5_person_id == -1)
            {
                XMessageBox.Show("กรุณาระบุผู้ถือหุ้น", "", MessageBoxButtons.OK, XMessageBoxIcon.Warning);
                //this.cHolderId.Focus();
                this.dgvPerson.Focus();
                return;
            }

            if (this.boj5_detail.shareNumber == 0)
            {
                XMessageBox.Show("กรุณาระบุจำนวนหุ้น", "", MessageBoxButtons.OK, XMessageBoxIcon.Warning);
                this.cShareNumber.Focus();
                return;
            }

            if (!this.boj5_detail.shareDocDate.HasValue)
            {
                XMessageBox.Show("กรุณาระบุวันที่ออกเลขที่ใบหุ้น", "", MessageBoxButtons.OK, XMessageBoxIcon.Warning);
                this.cShareDocDate.Focus();
                return;
            }

            if (!this.boj5_detail.shareRegExist.HasValue)
            {
                XMessageBox.Show("กรุณาระบุวันที่ลงทะเบียนผู้ถือหุ้น", "", MessageBoxButtons.OK, XMessageBoxIcon.Warning);
                this.cShareRegExist.Focus();
                return;
            }

            try
            {
                using (LocalDbEntities db = DBX.DataSet(this.main_form.selected_comp))
                {
                    if (this.boj5_detail.id > 0) // edit
                    {
                        var data_to_update = db.boj5_detail.Find(this.boj5_detail.id);
                        if (data_to_update == null)
                        {
                            db.boj5_detail.Add(this.boj5_detail);
                        }
                        else
                        {
                            data_to_update.asPaidAmount   = this.boj5_detail.asPaidAmount;
                            data_to_update.boj5_person_id = this.boj5_detail.boj5_person_id;
                            data_to_update.paidAmount     = this.boj5_detail.paidAmount;
                            data_to_update.shareDocDate   = this.boj5_detail.shareDocDate;
                            data_to_update.shareDocId     = this.boj5_detail.shareDocId;
                            data_to_update.shareNumber    = this.boj5_detail.shareNumber;
                            data_to_update.shareRegExist  = this.boj5_detail.shareRegExist;
                            data_to_update.shareRegOmit   = this.boj5_detail.shareRegOmit;
                            data_to_update.shareType      = this.boj5_detail.shareType;
                        }
                    }
                    else // add
                    {
                        db.boj5_detail.Add(this.boj5_detail);
                    }

                    db.SaveChanges();

                    long?seq = 0;
                    db.boj5_detail.Include("boj5_person").OrderBy(d => d.boj5_person.itemSeq).ToList().ForEach(d => d.itemNo = ++seq);
                    db.SaveChanges();

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                XMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
            }
        }
        private void btnDeleteHolder_Click(object sender, EventArgs e)
        {
            if (this.dgvPerson.CurrentCell == null)
            {
                return;
            }

            this.dgvPerson.Rows[this.dgvPerson.CurrentCell.RowIndex].DrawDeletingRowOverlay();

            try
            {
                using (LocalDbEntities db = DBX.DataSet(this.main_form.selected_comp))
                {
                    var         deleting_id = ((boj5_person)this.dgvPerson.Rows[this.dgvPerson.CurrentCell.RowIndex].Cells[this.col_boj5_person.Name].Value).id;
                    boj5_person person_to_delete;

                    if (db.boj5_detail.Where(d => d.boj5_person_id == deleting_id).Count() > 0)
                    {
                        if (XMessageBox.Show("มีรายการใบหุ้นของผู้ถือหุ้นรายนี้อยู่\n - เลือก \"ตกลง\" เพื่อให้ลบทั้งรายการใบหุ้น และ ชื่อผู้ถือหุ้นรายนี้\n - เลือก \"ยกเลิก\" เพื่อยกเลิกการทำงานนี้", "", MessageBoxButtons.OKCancel, XMessageBoxIcon.Question) == DialogResult.OK)
                        {
                            person_to_delete = db.boj5_person.Find(deleting_id);
                            if (person_to_delete != null)
                            {
                                db.boj5_detail.RemoveRange(db.boj5_detail.Where(d => d.boj5_person_id == deleting_id));
                                db.boj5_person.Remove(db.boj5_person.Find(deleting_id));
                                db.SaveChanges();

                                long?seq = 0;
                                db.boj5_person.ToList().ForEach(p => p.itemSeq = ++seq);
                                db.SaveChanges();

                                this.LoadPersonToDatagrid();
                            }
                            else
                            {
                                XMessageBox.Show("ค้นหารายการที่ต้องการลบไม่พบ", "", MessageBoxButtons.OK, XMessageBoxIcon.Stop);
                                this.LoadPersonToDatagrid();
                            }
                        }
                        else
                        {
                            this.dgvPerson.Rows[this.dgvPerson.CurrentCell.RowIndex].ClearDeletingRowOverlay();
                        }
                        return;
                    }
                    else
                    {
                        if (XMessageBox.Show("ลบรายการที่เลือก, ทำต่อหรือไม่?", "", MessageBoxButtons.OKCancel, XMessageBoxIcon.Question) != DialogResult.OK)
                        {
                            this.dgvPerson.Rows[this.dgvPerson.CurrentCell.RowIndex].ClearDeletingRowOverlay();
                        }

                        person_to_delete = db.boj5_person.Find(deleting_id);
                        if (person_to_delete != null)
                        {
                            db.boj5_person.Remove(person_to_delete);
                            db.SaveChanges();

                            long?seq = 0;
                            db.boj5_person.ToList().ForEach(p => p.itemSeq = ++seq);
                            db.SaveChanges();
                            this.LoadPersonToDatagrid();
                        }
                        else
                        {
                            XMessageBox.Show("ค้นหารายการที่ต้องการลบไม่พบ", "", MessageBoxButtons.OK, XMessageBoxIcon.Stop);
                            this.LoadPersonToDatagrid();
                        }
                    }

                    long?itemno = 0;
                    db.boj5_detail.Include("boj5_person").OrderBy(d => d.boj5_person.itemSeq).ToList().ForEach(d => d.itemNo = ++itemno);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                XMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, XMessageBoxIcon.Error);
            }
        }
Beispiel #22
0
 protected override void OnMouseClick(MouseEventArgs e)
 {
     base.OnMouseClick(e);
     XMessageBox.Show(e.Location.ToString());
 }
Beispiel #23
0
 private void ddbi2_Click(object sender, EventArgs e)
 {
     XMessageBox.Show("下拉项2单击");
 }