예제 #1
0
        public frmSetting()
        {
            InitializeComponent();

            conn = md.getConn();
            comm = md.getComm();
            sda  = md.getSda();

            dgOrg.CurrentCellDirtyStateChanged   += new EventHandler(dgOrg_CurrentCellDirtyStateChanged);
            dgTabel.CurrentCellDirtyStateChanged += new EventHandler(dgTabel_CurrentCellDirtyStateChanged);
        }
예제 #2
0
        //cek branchnya
        public string branch()
        {
            try
            {
                conn = md.getConn();
                comm = md.getComm();
                sda  = md.getSda();

                table_setup = "";
                table_temp  = "";
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }

                // ambil code org
                comm.Connection     = conn;
                comm.CommandText    = "select msp_org_cd from m_setup_parameter ";
                comm.CommandTimeout = 10000;
                comm.CommandType    = CommandType.Text;
                DataSet ds = new DataSet();
                sda.SelectCommand = comm;
                sda.Fill(ds);
                conn.Close();
                if (ds.Tables[0].Rows.Count > 0)
                {
                    table_temp = ds.Tables[0].Rows[0][0].ToString();
                }
                return(table_setup = table_temp);
            }
            catch (Exception ex)
            {
                log = "Gagal Ambil Branch : " + ex.Message.ToString();
                return("");
            }
        }
예제 #3
0
        private Boolean cekKoneksi()
        {
            Boolean hasil = false;

            mod md = new mod();

            md.setConString("server=" + txtServer.Text + "; port=" + txtPort.Text + "; user id=" + txtUserName.Text + "; password="******"; database=information_schema");
            conn = md.getConn();
            sda  = md.getSda();
            comm = md.getComm();
            try
            {
                conn.Open();

                comm.Connection     = conn;
                comm.CommandText    = "select schema_name DATABASE_LIST from schemata";
                comm.CommandType    = CommandType.Text;
                comm.CommandTimeout = 1000;
                DataSet ds = new DataSet();
                sda.SelectCommand = comm;
                sda.Fill(ds);
                conn.Close();

                if (ds.Tables[0].Rows.Count > 0)
                {
                    cmbDB.Properties.DataSource    = ds.Tables[0].DefaultView;
                    cmbDB.Properties.DisplayMember = "DATABASE_LIST";
                    cmbDB.Properties.ValueMember   = "DATABASE_LIST";

                    cmbDB.Enabled = true;
                }
            }
            catch (MySqlException ex) {
                MessageBox.Show(ex.Message);
                MessageBox.Show("Koneksi gagal", "Data Transfer", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            return(hasil);
        }
예제 #4
0
        private void loadSetting()
        {
            String server = "", port = "", username = "", password = "", db = "";

            XmlDocument doc = new XmlDocument();

            doc.Load(Directory.GetCurrentDirectory() + "\\config.xml");

            XmlNodeList list = doc.GetElementsByTagName("Connection");

            if (list.Count > 0)
            {
                foreach (XmlNode nodeParent in list)
                {
                    foreach (XmlNode nodeChild in nodeParent.ChildNodes)
                    {
                        switch (nodeChild.Name)
                        {
                        case "Server":
                            server = nodeChild.InnerText;
                            break;

                        case "Port":
                            port = nodeChild.InnerText;
                            break;

                        case "Username":
                            username = nodeChild.InnerText;
                            break;

                        case "Password":
                            password = nodeChild.InnerText;
                            break;

                        case "Database":
                            db = nodeChild.InnerText;
                            break;

                        default:
                            break;
                        }
                        ;
                    }
                }
            }

            try
            {
                myString = "server=" + server + "; port=" + port + "; username="******"; password="******"; database=" + db + ";";

                md.setConString(myString);
                conn = md.getConn();
                comm = md.getComm();
                sda  = md.getSda();

                conn.Open();
            }
            catch (MySqlException ex)
            {
                frmKoneksi konek = new frmKoneksi();
                konek.ShowDialog();
            }
            finally {
                conn.Close();
            }
        }
예제 #5
0
        //describe each table
        private string descTable(String tabName)
        {
            string txt = "";

            try
            {
                conn = md.getConn();
                comm = md.getComm();
                sda  = md.getSda();

                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }

                //get description of table
                comm.Connection     = conn;
                comm.CommandText    = "desc " + tabName;
                comm.CommandTimeout = 10000;
                comm.CommandType    = CommandType.Text;
                DataSet ds = new DataSet();
                sda.SelectCommand = comm;
                sda.Fill(ds);
                conn.Close();

                //put into list 1d
                List <string> list = new List <string>();
                if (ds.Tables[0].Rows.Count > 0)
                {
                    for (int a = 0; a <= ds.Tables[0].Rows.Count - 1; a++)
                    {
                        list.Add(ds.Tables[0].Rows[a][0].ToString() + "~" + ds.Tables[0].Rows[a][1].ToString());
                    }
                }

                //start to divide first column and second column
                string[] str;
                str = list[0].Split('~');
                txt = str[0].ToString();

                //loop each row to syntesize full text of list of columns
                for (int b = 1; b <= list.Count - 1; b++)
                {
                    str = list[b].Split('~');

                    switch (str[1].ToString())
                    {
                    case "datetime":
                        txt = txt + ", date_format(" + str[0].ToString() + ",'%Y-%m-%d %H:%i:%s')";
                        break;

                    case "double":
                        txt = txt + ", ifnull(" + str[0].ToString() + ")";
                        break;

                    case "decimal":
                        txt = txt + ", ifnull(" + str[0].ToString() + ")";
                        break;

                    case "int":
                        txt = txt + ", ifnull(" + str[0].ToString() + ",0)";
                        break;

                    default:
                        txt = txt + ", " + str[0].ToString();
                        break;
                    }
                }

                //return txt that contains full columns list
                return(txt);
            }
            catch (Exception ex)
            {
                return(txt);

                log = "Gagal Export : " + ex.ToString();
            }
        }