예제 #1
0
        private void DGV_SelectionChanged(object sender, EventArgs e)
        {
            if (!preventDGVSelectionChanged)
            {
                if (DGV.SelectedRows.Count == 1)
                {
                    GF.disableButton(this.ParentForm.Controls.Find("add_btn", true)[0] as Button);
                    GF.enableButton(this.ParentForm.Controls.Find("edit_btn", true)[0] as Button);

                    if (!preventEnable) // USE ENABLE BUTTON
                    {
                        if (DGV.Columns.Contains("is_use"))
                        {
                            if (DGV.SelectedRows[0].Cells["is_use"].Value.ToString() == "ACTIVE")
                            {
                                GF.enableButton(this.ParentForm.Controls.Find("del_btn", true)[0] as Button);
                                if (useDefaultEnable)
                                {
                                    this.ParentForm.Controls.Find("enable_btn", true)[0].Visible = false;
                                }
                            }

                            if (DGV.SelectedRows[0].Cells["is_use"].Value.ToString() == "INACTIVE")
                            {
                                GF.disableButton(this.ParentForm.Controls.Find("del_btn", true)[0] as Button);
                                if (useDefaultEnable)
                                {
                                    this.ParentForm.Controls.Find("enable_btn", true)[0].Visible = true;
                                }
                            }
                        }
                        else
                        {
                            GF.enableButton(this.ParentForm.Controls.Find("del_btn", true)[0] as Button);
                        }
                    }
                    else // NOT USE ENABLE BUTTON
                    {
                        if (DGV.SelectedRows[0].DefaultCellStyle.BackColor != Color.Khaki && DGV.SelectedRows[0].DefaultCellStyle.BackColor != Color.LightCoral)
                        {
                            GF.enableButton(this.ParentForm.Controls.Find("del_btn", true)[0] as Button);
                        }
                        else
                        {
                            GF.disableButton(this.ParentForm.Controls.Find("del_btn", true)[0] as Button);
                        }
                    }
                }
                else
                {
                    GF.enableButton(this.ParentForm.Controls.Find("add_btn", true)[0] as Button);
                    GF.disableButton(this.ParentForm.Controls.Find("edit_btn", true)[0] as Button);
                    GF.disableButton(this.ParentForm.Controls.Find("del_btn", true)[0] as Button);
                    if (preventEnable)
                    {
                        this.ParentForm.Controls.Find("enable_btn", true)[0].Visible = false;
                    }
                }
            }
        }
예제 #2
0
 private void delete_btn_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("ARE YOU SURE YOU WANT TO DELETE THIS ATTACHMENT ?", "DELETE ATTACHMENT", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         string fileName = DGV.SelectedRows[0].Cells["file_name"].Value.ToString();
         if (FTP.delete(fileName, "ATTACHMENT"))
         {
             string queryString = "DELETE FROM ATTACHMENT WHERE FILE_NAME LIKE '" + fileName + "'";
             DB.beginTrans();
             if (DB.set(queryString, "DELETE ATTACHMENT[" + fileName + "]"))
             {
                 DB.close();
                 GF.disableButton(add_btn);
                 GF.disableButton(delete_btn);
                 file_path.Text       = "";
                 attachment_name.Text = "";
                 loadAttachment();
             }
         }
         else
         {
             MessageBox.Show("CANNOT DELETE ATTACHMENT FILE via FTP !!", "ERROR");
             return;
         }
     }
 }
예제 #3
0
        private void loadAttachment()
        {
            if (Owner.Name == "shop_selling")
            {
                owner_name = Owner.Name;
            }
            else
            {
                owner_name = Owner.Owner.Name;
            }

            //GF.showLoading(this);
            this.DGV.Rows.Clear();

            if (DGV.Columns.Count == 0)
            {
                this.DGV.Columns.Add("attachment_name", "ATTACHMENT NAME");
                this.DGV.Columns.Add("file_name", "FILE NAME");
                this.DGV.Columns.Add("attachment_id", "ATTACHMENT ID");
            }

            String queryString = "SELECT ROW_NUMBER() OVER (ORDER BY attachment_name) as RowNum, attachment_id, attachment_name, file_name FROM ATTACHMENT WHERE owner_id = " + this.id.ToString() + " AND owner_form = '" + owner_name + "'";

            Dictionary <string, string> Params = new Dictionary <string, string>();

            /*Params.Add("@id", this.id.ToString());
            *  Params.Add("@owner_form", owner_name);*/

            using (DataTable myDT = DB.getS(queryString, Params, "GET ATTACHMENT"))
            {
                int rowNum = 0;
                foreach (DataRow myRow in myDT.Rows)
                {
                    this.DGV.Rows.Add(
                        myRow["attachment_name"],
                        myRow["file_name"],
                        myRow["attachment_id"]
                        );

                    this.DGV[0, rowNum].Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
                    this.DGV[1, rowNum].Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
                    rowNum++;
                }
            }
            this.DGV.Columns["attachment_id"].Visible = false;
            GF.updateRowNum(DGV);
            this.DGV.ClearSelection();

            if (viewOnly)
            {
                file_path.Enabled       = false;
                attachment_name.Enabled = false;
                GF.disableButton(add_btn);
                GF.disableButton(delete_btn);
            }
            GF.closeLoading();
        }
예제 #4
0
 private void file_path_TextChanged(object sender, EventArgs e)
 {
     if (file_path.Text.Trim() != "")
     {
         GF.enableButton(add_btn);
         Properties.Settings.Default.attachment_path = file_path.Text.Trim().Substring(0, file_path.Text.Trim().LastIndexOf('\\'));
         Properties.Settings.Default.Save();
     }
     else
     {
         GF.disableButton(add_btn);
     }
 }
예제 #5
0
        public attachments()
        {
            InitializeComponent();
            GF.doDebug("===== CHILD FORM :: " + this.Name + " IS OPENED =====");
            this.FormClosing += (s, e) =>
            {
                GF.doDebug("===== CHILD FORM :: " + this.Name + " IS CLOSED =====");
            };

            DGV.Width  = line_sep1.Width;
            DGV.Height = this.Height - DGV.Top - 40;

            GF.disableButton(add_btn);
            GF.disableButton(delete_btn);
        }
예제 #6
0
        private void last_btn_Click(object sender, EventArgs e)
        {
            GF.showLoading();

            page_txt.Text = total_lbl.Text;
            int.TryParse(page_txt.Text, out GF.currentPage);

            GF.disableButton(last_btn);
            GF.disableButton(next_btn);

            if (page_txt.Text != "1")
            {
                GF.enableButton(first_btn);
                GF.enableButton(prev_btn);
            }

            onLastClick(EventArgs.Empty);
        }
예제 #7
0
        private void next_btn_Click(object sender, EventArgs e)
        {
            GF.showLoading();

            page_txt.Text = (Convert.ToInt32(page_txt.Text) + 1).ToString();
            int.TryParse(page_txt.Text, out GF.currentPage);

            if (page_txt.Text == total_lbl.Text)
            {
                GF.disableButton(last_btn);
                GF.disableButton(next_btn);
            }

            if (page_txt.Text != "1")
            {
                GF.enableButton(first_btn);
                GF.enableButton(prev_btn);
            }

            onNextClick(EventArgs.Empty);
        }
예제 #8
0
        private void add_btn_Click(object sender, EventArgs e)
        {
            if (file_path.Text.Trim() == "")
            {
                GF.disableButton(add_btn);
                MessageBox.Show("PLEASE CHOOSE A FILE !!");
                return;
            }
            if (attachment_name.Text.Trim() == "")
            {
                MessageBox.Show("PLEASE ENTER ATTACHMENT NAME !!");
                attachment_name.Focus();
                return;
            }
            string filename = genFileName(file_path.Text.Trim());

            if (FTP.upload(file_path.Text.Trim(), filename, "ATTACHMENT"))
            {
                string queryString = "INSERT INTO ATTACHMENT ( ATTACHMENT_NAME, FILE_NAME, OWNER_ID, OWNER_FORM ) VALUES (";
                queryString += "'" + attachment_name.Text.Trim() + "', ";
                queryString += "'" + filename + "', ";
                queryString += id.ToString() + ", ";
                queryString += "'" + owner_name + "')";
                DB.beginTrans();
                if (DB.set(queryString, "INSERT ATTACHMENT[" + filename + "]"))
                {
                    DB.close();
                    GF.disableButton(add_btn);
                    GF.disableButton(delete_btn);
                    file_path.Text       = "";
                    attachment_name.Text = "";
                    loadAttachment();
                }
                else
                {
                    FTP.delete(filename, "ATTACHMENT");
                }
            }
        }
예제 #9
0
        private void btn_dgv_Load(object sender, EventArgs e)
        {
            this.Width       = Screen.PrimaryScreen.Bounds.Width - (this.Left * 2);
            paging_panel.Top = this.Height - this.Top - 165;
            DGV.Height       = paging_panel.Top - 70;

            GF.disableButton(first_btn);
            GF.disableButton(prev_btn);
            GF.disableButton(next_btn);
            GF.disableButton(last_btn);

            page_txt.Text = "1";

            int tmp;

            Int32.TryParse(total_lbl.Text.Trim(), out tmp);
            if (tmp > 1)
            {
                GF.enableButton(next_btn);
                GF.enableButton(last_btn);
            }
            //preventDGVSelectionChanged = true;
        }