Exemplo n.º 1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            string datetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            if (checkdata())
            {
                if (txtNewPass.Text == txtConfirmPass.Text)
                {
                    //insert user into database.
                    string sqlinsertUser = @"insert into m_user (user_name, user_pass, user_permision,user_dept_cd,registration_date_time) VALUES  ('"
                                           + txtUserName.Text + "','" + txtNewPass.Text + "','" + cmbPermision.Text + "','" + cmbDept.Text + "','" + datetime + "')";

                    IPQC_Motor.TfSQL con = new IPQC_Motor.TfSQL();
                    con.sqlExecuteScalarString(sqlinsertUser);
                    MessageBox.Show("User: '******' is created", "Info");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Password is incorrect", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                }
            }
            else
            {
                MessageBox.Show("Pls, insert fill full data", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvDwr.RowCount > 0)
                {
                    int dwrlId          = int.Parse(dgvDwr.Rows[dgvDwr.CurrentRow.Index].Cells["dwr_id"].Value.ToString());
                    IPQC_Motor.TfSQL tf = new IPQC_Motor.TfSQL();

                    string       sqlDel = "delete from m_drawing where dwr_id = " + dwrlId;
                    DialogResult dialog = MessageBox.Show("Do you want to delete " + dgvDwr.Rows[dgvDwr.CurrentRow.Index].Cells["dwr_cd"].Value.ToString(), "Note !", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dialog == DialogResult.Yes)
                    {
                        tf.sqlExecuteNonQuery(sqlDel, false);
                        btnSearch_Click(sender, e);
                    }
                }
                else
                {
                    MessageBox.Show("Choose a Drawing", "Note", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch
            { MessageBox.Show("Choose a Drawing", "Note", MessageBoxButtons.OK, MessageBoxIcon.Information); }
        }
Exemplo n.º 3
0
        private void cmbMaSo_SelectedIndexChanged(object sender, EventArgs e)
        {
            string sqlPageID = "select case when max(page_id) is null then 1 else max(page_id) +1 end as maxcode from  m_header";

            IPQC_Motor.TfSQL con = new IPQC_Motor.TfSQL();
            con.sqlExecuteScalarString(sqlPageID);
        }
Exemplo n.º 4
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (Check())
     {
         IPQC_Motor.TfSQL tf = new IPQC_Motor.TfSQL();
         if (!CheckDup())
         {
             MessageBox.Show("Drawing Code exist in Database", "Note", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             bool showMes = false;
             if (DrawingId == "")
             {
                 string sqlAdd = "Insert into m_drawing(model_id, dwr_cd, dwr_name, doc_name, user_id, registration_date_time) values(" + int.Parse(cmbSubModel.SelectedValue.ToString()) + ", '" + txtDwrCd.Text + "', '" + txtDwrName.Text + "', '" + txtDoc.Text + "', (select user_id from m_user where user_name ='" + User + "'), now())";
                 showMes = tf.sqlExecuteNonQuery(sqlAdd, false);
             }
             else
             {
                 string sqlUpdate = "update m_drawing set dwr_cd = '" + txtDwrCd.Text + "', dwr_name = '" + txtDwrName.Text + "', doc_name = '" + txtDoc.Text + "', user_id = (select user_id from m_user where user_name = '" + User + "'), registration_date_time = now() where dwr_id = " + DrawingId;
                 showMes = tf.sqlExecuteNonQuery(sqlUpdate, false);
             }
             if (showMes)
             {
                 MessageBox.Show("Successful!", "Database Responce", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }
        private void btnOk_Click(object sender, EventArgs e)
        {
            IPQC_Motor.TfSQL con     = new IPQC_Motor.TfSQL();
            string           sqlpass = "******" + username + "'";

            if (txtOldPass.Text == con.sqlExecuteScalarString(sqlpass))
            {//update new password
                if (txtNewPass.Text == txtConfirmPass.Text)
                {
                    string           sqlupdatepass = "******" + txtNewPass.Text + "' where user_name = '" + username + "'";
                    IPQC_Motor.TfSQL update        = new IPQC_Motor.TfSQL();
                    update.sqlExecuteScalarString(sqlupdatepass);
                    MessageBox.Show("your Password is changed", "Info");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("New Pasword is incorrect", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                }
            }
            else
            {
                MessageBox.Show("Old Pasword is incorrect", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Exemplo n.º 6
0
        private void frmModel_Load(object sender, EventArgs e)
        {
            IPQC_Motor.TfSQL tf = new IPQC_Motor.TfSQL();
            if (DrawingId == "")
            {
                Text = "Add Drawing";
                string sqlCmbModel = @"select distinct model_cd from(select model_cd ,user_dept_cd from m_model a,m_user b where a.user_id = b.user_id )t,m_user a 
            where a.user_dept_cd = t.user_dept_cd and a.user_name = '" + User + "'";
                getCmb(sqlCmbModel, ref cmbModel);
            }
            else
            {
                Text = "Update Drawing";

                string sqlDwrCd    = "select dwr_cd from m_drawing where dwr_id = " + int.Parse(DrawingId);
                string sqlDwrName  = "select dwr_name from m_drawing where dwr_id = " + int.Parse(DrawingId);
                string sqlDoc      = "select doc_name from m_drawing where dwr_id = " + int.Parse(DrawingId);
                string sqlModel    = "select model_cd from m_model where model_id =" + int.Parse(ModelId);
                string sqlModelSub = "select model_sub_cd from m_model where model_id =" + int.Parse(ModelId);

                txtDwrCd.Text         = tf.sqlExecuteScalarString(sqlDwrCd);
                txtDwrName.Text       = tf.sqlExecuteScalarString(sqlDwrName);
                txtDoc.Text           = tf.sqlExecuteScalarString(sqlDoc);
                cmbModel.SelectedText = tf.sqlExecuteScalarString(sqlModel);
                cmbModel.Text         = tf.sqlExecuteScalarString(sqlModel);
                cmbSubModel.Text      = tf.sqlExecuteScalarString(sqlModelSub);
                cmbSubModel.Enabled   = false;
                cmbModel.Enabled      = false;
            }
        }
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (Check())
     {
         IPQC_Motor.TfSQL tf = new IPQC_Motor.TfSQL();
         if (!CheckDup())
         {
             MessageBox.Show("Model Sub exist in database!", "Database Responce", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             bool show = false;
             if (ModelId == "")
             {
                 string sqlAdd = "Insert into m_model(model_id, model_cd, model_sub_cd, user_id, registration_date_time) values((select max(model_id)+1 from m_model),'" + txtModel.Text + "', '" + txtModelSub.Text + "', (select user_id from m_user where user_name ='" + User + "'), now())";
                 show = tf.sqlExecuteNonQuery(sqlAdd, false);
             }
             else
             {
                 string sqlUpdate = "update m_model set model_sub_cd = '" + txtModelSub.Text + "', user_id = (select user_id from m_user where user_name = '" + User + "'), registration_date_time = now() where model_id = " + int.Parse(ModelId);
                 show = tf.sqlExecuteNonQuery(sqlUpdate, false);
             }
             if (show)
             {
                 MessageBox.Show("Successful!", "Database Responce", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     else
     {
         MessageBox.Show("Info is null", "Note", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Exemplo n.º 8
0
        private void listTV_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                int pageId = 0;
                if (int.TryParse(listTV.SelectedNode.Tag.ToString(), out pageId))
                {
                    IPQC_Motor.TfSQL tf        = new IPQC_Motor.TfSQL();
                    string           tagNode   = "select count(*) from m_header where page_id = " + pageId;
                    long             checkPage = tf.sqlExecuteScalarLong(tagNode);

                    if (checkPage > 0)
                    {
                        string[]         a     = listTV.SelectedNode.FullPath.ToString().Split('\\');
                        string           DWRCd = a[0];
                        IPQC_Part.frmFMS from  = new IPQC_Part.frmFMS(pageId, username, DWRCd);
                        this.Hide();
                        from.ShowDialog();
                        this.Show();
                    }
                }
                else
                {
                    MessageBox.Show("Hãy chọn một mã máy !", "Note!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch { return; }
        }
        public bool CheckDup()
        {
            IPQC_Motor.TfSQL tf     = new IPQC_Motor.TfSQL();
            string           sqldup = "select count(*) from m_model where model_cd = '" + txtModel.Text + "' and model_sub_cd ='" + txtModelSub.Text + "'";

            if (tf.sqlExecuteScalarDouble(sqldup) >= 1)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 10
0
        private void frmRegisterUser_Load(object sender, EventArgs e)
        {
            IPQC_Motor.TfSQL con     = new IPQC_Motor.TfSQL();
            string           sqldept = "select distinct user_dept_cd from m_user order by user_dept_cd";

            con.getComboBoxData(sqldept, ref cmbDept);

            string sqlPermision = "select distinct user_permision from m_user order by user_permision";

            con.getComboBoxData(sqlPermision, ref cmbPermision);
        }
Exemplo n.º 11
0
        public bool CheckDup()
        {
            IPQC_Motor.TfSQL tf     = new IPQC_Motor.TfSQL();
            string           sqldup = "select count(*) from m_drawing where dwr_cd = '" + txtDwrCd.Text + "'";

            if (tf.sqlExecuteScalarDouble(sqldup) >= 1)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 12
0
        private void cmbModel_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            IPQC_Motor.TfSQL tf            = new IPQC_Motor.TfSQL();
            DataTable        dtModel       = new DataTable();
            string           sqlCmbModeSub = "select model_sub_cd,model_id from m_model  where model_cd = '" + cmbModel.Text + "' order by model_sub_cd";

            tf.sqlDataAdapterFillDatatable(sqlCmbModeSub, ref dtModel);
            cmbSubModel.DataSource    = dtModel;
            cmbSubModel.ValueMember   = "model_id";
            cmbSubModel.DisplayMember = "model_sub_cd";
            cmbSubModel.Text          = "";
        }
Exemplo n.º 13
0
        void callpic()
        {
            IPQC_Motor.TfSQL tfSql   = new IPQC_Motor.TfSQL();
            string           bytePic = tfSql.sqlExecuteScalarString("select dwr_image from m_drawing where dwr_cd = '" + drawingcd + "'");

            if (bytePic != "")
            {
                byte[]       imgBytes = Convert.FromBase64String(bytePic);
                MemoryStream ms       = new MemoryStream(imgBytes, 0, imgBytes.Length);
                ms.Write(imgBytes, 0, imgBytes.Length);
                Image image = Image.FromStream(ms, true);

                picbox.Image    = image;
                picbox.SizeMode = PictureBoxSizeMode.Zoom;
            }
        }
 private void frmModel_Load(object sender, EventArgs e)
 {
     if (ModelId == "")
     {
         Text = "Add Model";
     }
     else
     {
         IPQC_Motor.TfSQL tf          = new IPQC_Motor.TfSQL();
         string           sqlModel    = "select model_cd from m_model where model_id = " + int.Parse(ModelId);
         string           sqlModelSub = "select model_sub_cd from m_model where model_id = " + int.Parse(ModelId);
         Text             = "Update Model";
         txtModel.Enabled = false;
         txtModel.Text    = tf.sqlExecuteScalarString(sqlModel);
         txtModelSub.Text = tf.sqlExecuteScalarString(sqlModelSub);
     }
 }
Exemplo n.º 15
0
        void buildDGV(ref DataGridView dgv)
        {
            //create datagipview
            dtInspectItems = new DataTable();
            dtInspectItems.Clear();
            string sql = @"
                        select a.item_measure, a.item_detail, a.item_spec_x, a.item_lower, a.item_upper,
                       (a.item_upper  - a.item_spec_x) as tolerance_up , (a.item_lower  - a.item_spec_x) as tolerances_low,a.item_tool,  
                        b.data_1, b.data_2, b.data_3, b.data_4, b.data_5, b.data_x, b.data_est, b.registration_date_time   from m_item a left join
                        (select dwr_cd,dwr_id, user_dept_cd from m_drawing a, m_user b where a.user_id = b.user_id) c on a.dwr_id = c.dwr_id
                        left join m_data b on a.item_id = b.item_id where c.dwr_cd = '" + drawingcd + "' and c.user_dept_cd = (select distinct user_dept_cd from m_user where user_name = '" + username + @"')
                        order by registration_date_time desc, item_measure asc ";

            IPQC_Motor.TfSQL con = new IPQC_Motor.TfSQL();
            con.sqlDataAdapterFillDatatable(sql, ref dtInspectItems);
            dgv.DataSource = dtInspectItems;
        }
Exemplo n.º 16
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            IPQC_Motor.TfSQL tf = new IPQC_Motor.TfSQL();
            dt = new DataTable();
            string sqlSearch = "select t.model_id, t.model_cd, t.model_sub_cd from m_user m,(select model_id,model_cd,model_sub_cd, user_dept_cd from m_model a,m_user b where a.user_id = b.user_id ) t where m.user_dept_cd = t.user_dept_cd and m.user_name ='" + User + "' ";

            if (!String.IsNullOrEmpty(txtModel.Text))
            {
                sqlSearch += " and t.model_cd = '" + txtModel.Text + "'";
            }
            if (!String.IsNullOrEmpty(txtModelSub.Text))
            {
                sqlSearch += " and t.model_sub_cd = '" + txtModelSub.Text + "'";
            }
            sqlSearch += " order by t.model_cd, t.model_id";
            tf.sqlDataAdapterFillDatatable(sqlSearch, ref dt);
            updateDGV(ref dgvModel, ref dt);
        }
Exemplo n.º 17
0
        private void frmFMS_Load(object sender, EventArgs e)
        {
            IPQC_Motor.TfSQL con          = new IPQC_Motor.TfSQL();
            string           sqlProcedure = @"
            select distinct header_procedure from
            (select header_procedure, user_dept_cd from m_header a, m_user b where a.user_id = b.user_id)t, m_user a
            where a.user_dept_cd = t.user_dept_cd and a.user_name = '" + username + "' order by header_procedure";

            con.getComboBoxData(sqlProcedure, ref cmbQuiTrinh);

            string sqlMachine = @"
            select distinct header_machine from
            (select header_machine, user_dept_cd from m_header a, m_user b where a.user_id = b.user_id)t, m_user a
            where a.user_dept_cd = t.user_dept_cd and a.user_name = '" + username + "' order by header_machine";

            con.getComboBoxData(sqlMachine, ref cmbMaSo);

            callpic();
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            IPQC_Motor.TfSQL tf = new IPQC_Motor.TfSQL();
            dt = new DataTable();
            string sqlSearch = @"select b.model_id, b.model_sub_cd, a.dwr_cd, a.dwr_name, a.doc_name, a.registration_date_time,a.dwr_id from m_drawing a left join m_model b on a.model_id = b.model_id where 1=1 ";

            if (!String.IsNullOrEmpty(cmbModel.Text))
            {
                sqlSearch += " and b.model_cd = '" + cmbModel.Text + "'";
            }
            if (!String.IsNullOrEmpty(cmbSubModel.Text))
            {
                sqlSearch += " and b.model_sub_cd = '" + cmbSubModel.Text + "'";
            }
            if (!String.IsNullOrEmpty(txtDwr.Text))
            {
                sqlSearch += " and a.dwr_cd = '" + txtDwr.Text + "'";
            }
            sqlSearch += " order by b.model_id";
            tf.sqlDataAdapterFillDatatable(sqlSearch, ref dt);
            updateDGV(ref dgvDwr, ref dt);
        }
Exemplo n.º 19
0
 private void frmModel_Load(object sender, EventArgs e)
 {
     IPQC_Motor.TfSQL con = new IPQC_Motor.TfSQL();
     string           sql = @"select distinct model_cd from(select model_cd ,user_dept_cd from m_model a,m_user b where a.user_id = b.user_id )t,m_user a 
     where a.user_dept_cd = t.user_dept_cd and a.user_name = '" + User + "'";
 }
 public void getCmb(string sql, ref ComboBox cmb)
 {
     IPQC_Motor.TfSQL tf = new IPQC_Motor.TfSQL();
     tf.getComboBoxData(sql, ref cmb);
 }
Exemplo n.º 21
0
        private void TreeView2(string DwrCd, string dateFrom, string dateTo, int limit, bool showDrawing)
        {
            DataTable dtTV = new DataTable();

            listTV.Nodes.Clear();
            IPQC_Motor.TfSQL tfSql = new IPQC_Motor.TfSQL();

            string sqlTreeDr = "select dwr_cd, dwr_name from m_drawing where model_id in (select model_id from m_model where model_sub_cd = '" + cmbSubModel.Text + "') ";

            if (showDrawing)
            {
                sqlTreeDr += " and dwr_cd = '" + DwrCd + "' ";
            }
            sqlTreeDr += " order by dwr_cd";
            tfSql.sqlDataAdapterFillDatatable(sqlTreeDr, ref dtTV);
            if (dtTV.Rows.Count > 0)
            {
                TreeNode[] header = new TreeNode[dtTV.Rows.Count];
                for (int k = 0; k < dtTV.Rows.Count; k++)
                {
                    DataTable dtTreeNode = new DataTable();
                    TreeNode  treeheader = new TreeNode
                    {
                        Text = dtTV.Rows[k]["dwr_cd"].ToString(),
                        Tag  = dtTV.Rows[k]["dwr_cd"].ToString()
                    };
                    header[k] = treeheader;

                    if (showDrawing)
                    {
                        header[k].Expand();
                    }

                    StringBuilder sqlTV = new StringBuilder();
                    sqlTV.Append(@"select cast(a.registration_date_time as date) dates
                            from m_header a left join m_data b on a.page_id = b.page_id left join m_item c on b.item_id = c.item_id 
                            where c.dwr_id = (select dwr_id from m_drawing where dwr_cd = '" + header[k].Tag + "') and a.registration_date_time >= '" + dateFrom.ToString() +
                                 "' and cast(a.registration_date_time as date) <= '" + dateTo.ToString() + "' group by dates order by dates desc limit " + limit);
                    tfSql.sqlDataAdapterFillDatatable(sqlTV.ToString(), ref dtTreeNode);

                    if (dtTreeNode.Rows.Count > 0)
                    {
                        TreeNode[] headerN = new TreeNode[dtTreeNode.Rows.Count];
                        for (int i = 0; i < dtTreeNode.Rows.Count; i++)
                        {
                            TreeNode treeheaderN = new TreeNode
                            {
                                Text = DateTime.Parse(dtTreeNode.Rows[i]["dates"].ToString()).ToString("yyyy-MM-dd"),
                            };
                            headerN[i] = treeheaderN;
                            header[k].Nodes.Add(treeheaderN);

                            DataTable dtChildNode  = new DataTable();
                            string    sqlNodeChild = @"select * from (select a.page_id, header_machine, footer_result, cast(a.registration_date_time as date) dates,a.registration_date_time date 
                            from m_header a left join m_data b on a.page_id = b.page_id left join m_item c on b.item_id = c.item_id where c.dwr_id = (select dwr_id from m_drawing where dwr_cd = '" + header[k].Tag + "') group by a.page_id,a.registration_date_time, header_machine, footer_result) tb where tb.dates = '" + headerN[i].Text + "'";
                            tfSql.sqlDataAdapterFillDatatable(sqlNodeChild, ref dtChildNode);

                            TreeNode[] headerchild = new TreeNode[dtChildNode.Rows.Count];
                            for (int j = 0; j < dtChildNode.Rows.Count; j++)
                            {
                                TreeNode treeheaderchild = new TreeNode
                                {
                                    Text = "MM: " + dtChildNode.Rows[j]["header_machine"].ToString() + " -- Page Id: " + dtChildNode.Rows[j]["page_id"].ToString() + " " + dtChildNode.Rows[j]["footer_result"].ToString(),
                                    Tag  = dtChildNode.Rows[j]["page_id"].ToString()
                                };

                                headerchild[j] = treeheaderchild;

                                if (dtChildNode.Rows[j]["footer_result"].ToString() == "NG")
                                {
                                    headerchild[j].BackColor = Color.Red;
                                }
                                else if (dtChildNode.Rows[j]["footer_result"].ToString() == "OK")
                                {
                                }
                                else
                                {
                                    headerchild[j].BackColor = Color.Yellow;
                                }

                                headerN[i].Nodes.Add(treeheaderchild);
                            }
                        }
                    }
                    listTV.Nodes.Add(header[k]);
                }
            }
        }