public void SaveToolData(string toolType, string Barcode, float clearance, float height, float width, float length, string comments, string byWho, out string resCode, out string resDesc)
 {
     try
     {
         Log.AppendText("กำลังบันทึกข้อมูล Tool {" + toolType + ", " + Barcode + ", " + clearance.ToString() + ", " + height.ToString() + ", " + width.ToString() + ", " + length.ToString() + "} by " + byWho);
         ManageBiz ms = new ManageBiz();
         DataTable dtUser;
         dtUser = ms.GetToolBy(toolType);
         if (dtUser.Rows.Count == 0)
         {
             Log.AppendText("ตรวจสอบ ToolType เรียบร้อย");
             ms.AddNewTool(toolType, Barcode, clearance, height, width, length, comments);
             resCode = "00";
             resDesc = "";
         }
         else
         {
             Log.AppendText("WARNING! : ToolType ซ้ำ");
             Log.AppendText("เริ่มต้น Update Tool...");
             ms.UpdateToolData(toolType, Barcode, clearance, height, width, length, comments);
             resCode = "01";
             resDesc = "";
         }
     }
     catch (Exception ex)
     {
         resCode = "EX";
         resDesc = ex.Message;
         Log.AppendText(ex.Message);
     }
 }
 public void ShowUserList(ref ListBox lb)
 {
     try
     {
         Log.AppendText("กำลังเรียกข้อมูลรายชื่อผู้ใช้ระบบ...");
         ManageBiz ms = new ManageBiz();
         DataTable dtUser;
         dtUser = ms.GetUserList();
         lb.Items.Clear();
         for (int i = 0; i < dtUser.Rows.Count; i++)
         {
             if (dtUser.Rows[i]["AccountType"].ToString().Equals("A"))
             {
                 lb.Items.Add(dtUser.Rows[i]["UserName"].ToString() + ", " +
                              dtUser.Rows[i]["FirstName"].ToString() + ", " +
                              dtUser.Rows[i]["LastName"].ToString() + ", " +
                              "Administrator");
             }
             else if (dtUser.Rows[i]["AccountType"].ToString().Equals("U"))
             {
                 lb.Items.Add(dtUser.Rows[i]["UserName"].ToString() + ", " +
                              dtUser.Rows[i]["FirstName"].ToString() + ", " +
                              dtUser.Rows[i]["LastName"].ToString() + ", " +
                              "User");
             }
         }
         Log.AppendText("เรียกข้อมูลรายชื่อผู้ใช้ระบบ เรียบร้อย");
     }
     catch (Exception ex)
     {
         Log.AppendText(ex.Message);
         lb.Items.Clear();
     }
 }
Example #3
0
 public void ShowBoardList(ref ComboBox cbo)
 {
     try
     {
         Log.AppendText("กำลังเรียกข้อมูล Board...");
         ManageBiz ms = new ManageBiz();
         DataTable dt;
         dt             = ms.GetBoardList();
         cbo.DataSource = null;
         if (dt.Rows.Count > 0)
         {
             cbo.DataSource    = dt;
             cbo.DisplayMember = "BoardName";
             cbo.ValueMember   = "BoardName";
             Log.AppendText("เรียกข้อมูล Board เรียบร้อย");
         }
         else
         {
             Log.AppendText("ไม่พบข้อมูล Board");
         }
     }
     catch (Exception ex)
     {
         Log.AppendText(ex.Message);
         MessageBox.Show(ex.Message);
         cbo.DataSource = null;
     }
 }
 public void AddNewUser(string userName, string firstName, string lastName, string accountType, string cript_password, string byWho, out string resCode, out string resDesc)
 {
     try
     {
         Log.AppendText("กำลังส่งข้อมูลเพิ่มรายชื่อผู้ใช้ระบบใหม่ {" + userName + ", " + firstName + ", " + lastName + ", " + accountType + "} by " + byWho);
         ManageBiz ms = new ManageBiz();
         DataTable dtUser;
         dtUser = ms.GetUserBy(userName);
         if (dtUser.Rows.Count == 0)
         {
             Log.AppendText("ตรวจสอบ ชื่อผู้ใช้ เรียบร้อย");
             ms.AddNewUser(userName, firstName, lastName, accountType, cript_password);
             resCode = "00";
             resDesc = "";
         }
         else
         {
             Log.AppendText("WARNING! : ชื่อผู้ใช้ซ้ำ");
             resCode = "01";
             resDesc = "ชื่อผู้ใช้ซ้ำ!";
         }
     }
     catch (Exception ex)
     {
         resCode = "EX";
         resDesc = ex.Message;
         Log.AppendText(ex.Message);
     }
 }
 public void ShowToolList(ref ComboBox cbo)
 {
     try
     {
         Log.AppendText("กำลังเรียกข้อมูล Tools...");
         ManageBiz ms = new ManageBiz();
         DataTable dtUser;
         dtUser         = ms.GetToolList();
         cbo.DataSource = null;
         if (dtUser.Rows.Count > 0)
         {
             cbo.DataSource    = dtUser;
             cbo.DisplayMember = "ToolType";
             cbo.ValueMember   = "ToolType";
             Log.AppendText("เรียกข้อมูล Tools เรียบร้อย");
         }
         else
         {
             Log.AppendText("ไม่พบข้อมูล Tools");
         }
     }
     catch (Exception ex)
     {
         Log.AppendText(ex.Message);
         MessageBox.Show(ex.Message);
         cbo.DataSource = null;
     }
 }
        public void SaveProfileData(string profileName, float sampleStart, float sampleDistance,
                                    string Error1, string Error2, string Error3, string Error4, string Error5,
                                    float H1Par, float H2Par, float H3Par, float H4Par, float H5Par, float H6Par, float H7Par,
                                    string HAC1, string HAC2, string HAC3, string HAC4, string HAC5, string HAC6, string HAC7,
                                    float F1Par, float F2Par, float F3Par, float F4Par, float F5Par, float F6Par, float F7Par,
                                    string FAC1, string FAC2, string FAC3, string FAC4, string FAC5, string FAC6, string FAC7,
                                    float SP1, float SP2, float SP3, float SP4, float SP5, float SP6, float SP7,
                                    string byWho, out string resCode, out string resDesc)
        {
            try
            {
                Log.AppendText("กำลังบันทึกข้อมูล Profile {" + profileName + ", " + sampleStart.ToString() + ", " + sampleDistance.ToString() + ", " +
                               Error1 + ", " + Error2 + ", " + Error3 + ", " + Error4 + ", " + Error5 + ", " +
                               H1Par.ToString() + ", " + H2Par.ToString() + ", " + H3Par.ToString() + ", " + H4Par.ToString() + ", " + H5Par.ToString() + ", " + H6Par.ToString() + ", " + H7Par.ToString() + ", " +
                               HAC1 + ", " + HAC2 + ", " + HAC3 + ", " + HAC4 + ", " + HAC5 + ", " + HAC6 + ", " + HAC7 + ", " +
                               F1Par.ToString() + ", " + F2Par.ToString() + ", " + F3Par.ToString() + ", " + F4Par.ToString() + ", " + F5Par.ToString() + ", " + F6Par.ToString() + ", " + F7Par.ToString() + ", " +
                               FAC1 + ", " + FAC2 + ", " + FAC3 + ", " + FAC4 + ", " + FAC5 + ", " + FAC6 + ", " + FAC7 + ", " +
                               SP1.ToString() + ", " + SP2.ToString() + ", " + SP3.ToString() + ", " + SP4.ToString() + ", " + SP5.ToString() + ", " + SP6.ToString() + ", " + SP7.ToString() +
                               "} by " + byWho);

                ManageBiz ms = new ManageBiz();
                DataTable dtUser;
                dtUser = ms.GetProfileBy(profileName);
                if (dtUser.Rows.Count == 0)
                {
                    Log.AppendText("ตรวจสอบ ProfileName เรียบร้อย");
                    ms.AddNewProfile(profileName, sampleStart, sampleDistance,
                                     Error1, Error2, Error3, Error4, Error5,
                                     H1Par, H2Par, H3Par, H4Par, H5Par, H6Par, H7Par,
                                     HAC1, HAC2, HAC3, HAC4, HAC5, HAC6, HAC7,
                                     F1Par, F2Par, F3Par, F4Par, F5Par, F6Par, F7Par,
                                     FAC1, FAC2, FAC3, FAC4, FAC5, FAC6, FAC7,
                                     SP1, SP2, SP3, SP4, SP5, SP6, SP7);
                    resCode = "00";
                    resDesc = "";
                }
                else
                {
                    Log.AppendText("WARNING! : ProfileName ซ้ำ");
                    Log.AppendText("เริ่มต้น Update Profile...");
                    ms.UpdateProfileData(profileName, sampleStart, sampleDistance,
                                         Error1, Error2, Error3, Error4, Error5,
                                         H1Par, H2Par, H3Par, H4Par, H5Par, H6Par, H7Par,
                                         HAC1, HAC2, HAC3, HAC4, HAC5, HAC6, HAC7,
                                         F1Par, F2Par, F3Par, F4Par, F5Par, F6Par, F7Par,
                                         FAC1, FAC2, FAC3, FAC4, FAC5, FAC6, FAC7,
                                         SP1, SP2, SP3, SP4, SP5, SP6, SP7);
                    resCode = "01";
                    resDesc = "";
                }
            }
            catch (Exception ex)
            {
                resCode = "EX";
                resDesc = ex.Message;
                Log.AppendText(ex.Message);
            }
        }
Example #7
0
        public BoardInfo(string boardName)
        {
            this.BoardName        = boardName;
            this.Description      = "";
            this.BoardThickness   = 0;
            this.FixtureThickness = 0;
            this.PhysicalSize     = new SizeF(100, 100);
            this.ImageFile        = "";

            ConnectorList = new List <ConnectorInfo>();

            ManageBiz ms = new ManageBiz();
            DataTable dt;

            dt = ms.GetBoardBy(boardName);

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    float boardWidth  = float.Parse(dt.Rows[0]["BoardWidth"].ToString());
                    float boardLength = float.Parse(dt.Rows[0]["BoardLength"].ToString());
                    this.PhysicalSize = new SizeF(boardWidth, boardLength);

                    this.Description      = dt.Rows[0]["DESC"].ToString();;
                    this.BoardThickness   = float.Parse(dt.Rows[0]["BoardThickness"].ToString());
                    this.FixtureThickness = float.Parse(dt.Rows[0]["FixtureThickness"].ToString());
                    this.ImageFile        = dt.Rows[0]["ImageFile"].ToString();;

                    if (ConnectorList == null)
                    {
                        ConnectorList = new List <ConnectorInfo>();
                    }

                    // Detail
                    DataTable dtDetail = ms.GetBoardDetailBy(boardName);
                    if (dtDetail != null)
                    {
                        if (dtDetail.Rows.Count > 0)
                        {
                            float  x, y, angle;
                            string connectorType, comments;
                            foreach (DataRow r in dtDetail.Rows)
                            {
                                x             = float.Parse(r["X"].ToString());
                                y             = float.Parse(r["Y"].ToString());
                                angle         = float.Parse(r["Angle"].ToString());
                                connectorType = r["ConnectorType"].ToString();
                                comments      = r["Comments"].ToString();
                                this.ConnectorList.Add(new ConnectorInfo(connectorType, x, y, angle, comments, FixtureThickness, BoardThickness));
                            }
                        }
                    }
                }
            }
        }
 public void SaveConnectorSpec(string connectorType, string toolType, string profileName,
                               int pins,
                               float baseThickness, float unseatedTop, float height, float seatedHeight,
                               float graphFPerPin, float graphDistance,
                               float minFPerPin, float maxFPerPin, float userFPerPin, float otherForce,
                               float parsPercent, float parsStartHeight, float parsDistance,
                               float gradDegrees, string comments,
                               string byWho, out string resCode, out string resDesc)
 {
     try
     {
         Log.AppendText("กำลังบันทึกข้อมูล Connector {" + connectorType + ", " + toolType + ", " + profileName + ", " + pins.ToString() + ", " +
                        baseThickness.ToString() + ", " + unseatedTop.ToString() + ", " + height.ToString() + ", " + seatedHeight.ToString() +
                        graphFPerPin.ToString() + ", " + graphDistance.ToString() +
                        minFPerPin.ToString() + ", " + maxFPerPin.ToString() + ", " + userFPerPin.ToString() + ", " + otherForce.ToString() +
                        parsPercent.ToString() + ", " + parsStartHeight.ToString() + ", " + parsDistance.ToString() + ", " +
                        gradDegrees.ToString() + ", " + comments +
                        "} by " + byWho);
         ManageBiz ms = new ManageBiz();
         DataTable dt;
         dt = ms.GetConnectorBy(connectorType);
         if (dt.Rows.Count == 0)
         {
             Log.AppendText("ตรวจสอบ Connector Type เรียบร้อย");
             ms.AddNewConnectorSpec(connectorType, toolType, profileName, pins,
                                    baseThickness, unseatedTop, height, seatedHeight,
                                    graphFPerPin, graphDistance,
                                    minFPerPin, maxFPerPin, userFPerPin, otherForce,
                                    parsPercent, parsStartHeight, parsDistance,
                                    gradDegrees, comments);
             resCode = "00";
             resDesc = "";
         }
         else
         {
             Log.AppendText("WARNING! : ToolType ซ้ำ");
             Log.AppendText("เริ่มต้น Update Tool...");
             ms.UpdateConnectorSpec(connectorType, toolType, profileName, pins,
                                    baseThickness, unseatedTop, height, seatedHeight,
                                    graphFPerPin, graphDistance,
                                    minFPerPin, maxFPerPin, userFPerPin, otherForce,
                                    parsPercent, parsStartHeight, parsDistance,
                                    gradDegrees, comments);
             resCode = "01";
             resDesc = "";
         }
     }
     catch (Exception ex)
     {
         resCode = "EX";
         resDesc = ex.Message;
         Log.AppendText(ex.Message);
     }
 }
        public bool Login(string UserName, string Password)
        {
            try
            {
                ManageBiz ms = new ManageBiz();

                string    crptPassword = StringCipher.Encrypt(Password, true);
                DataTable dtUser;
                dtUser = ms.GetUserBy(UserName);
                bool ShowDenineMessage = false;
                if (dtUser != null)
                {
                    if (dtUser.Rows.Count == 1)
                    {
                        string dbPassword = dtUser.Rows[0]["Password"].ToString();
                        if (dbPassword == crptPassword)
                        {
                            return(true);
                        }
                        else
                        {
                            ShowDenineMessage = true;
                        }
                    }
                    else
                    {
                        ShowDenineMessage = true;
                    }
                }
                else
                {
                    ShowDenineMessage = true;
                }
                if (ShowDenineMessage)
                {
                    MessageBox.Show("Access denine. Invalid user name or password.",
                                    "Login",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Asterisk,
                                    MessageBoxDefaultButton.Button1);
                }
                return(false);
            }
            catch (Exception ex)
            {
                Log.AppendText(ex.Message);
                MessageBox.Show("Login Error : " + ex.Message);
                return(false);
            }
        }
        public void DeleteTool(string toolType, string byWho, out string resCode, out string resDesc)
        {
            try
            {
                Log.AppendText("กำลังส่งข้อมูลการลบ Tool {" + toolType + "} by " + byWho);
                ManageBiz ms = new ManageBiz();

                ms.DeleteTool(toolType);
                resCode = "00";
                resDesc = "";
            }
            catch (Exception ex)
            {
                resCode = "EX";
                resDesc = ex.Message;
                Log.AppendText(ex.Message);
            }
        }
        public void DeleteUser(string userName, string byWho, out string resCode, out string resDesc)
        {
            try
            {
                Log.AppendText("กำลังส่งข้อมูลการลบรายชื่อ {" + userName + "} by " + byWho);
                ManageBiz ms = new ManageBiz();

                ms.DeleteUser(userName);
                resCode = "00";
                resDesc = "";
            }
            catch (Exception ex)
            {
                resCode = "EX";
                resDesc = ex.Message;
                Log.AppendText(ex.Message);
            }
        }
Example #12
0
        public void DeleteBoardSpec(string boardName, string byWho, out string resCode, out string resDesc)
        {
            try
            {
                Log.AppendText("กำลังส่งข้อมูลการลบ Board spec. {" + boardName + "} by " + byWho);
                ManageBiz ms = new ManageBiz();

                ms.DeleteBoardSpec(boardName);
                resCode = "00";
                resDesc = "";
            }
            catch (Exception ex)
            {
                resCode = "EX";
                resDesc = ex.Message;
                Log.AppendText(ex.Message);
            }
        }
        public void DeleteConnectorSpec(string connectorType, string byWho, out string resCode, out string resDesc)
        {
            try
            {
                Log.AppendText("กำลังส่งข้อมูลการลบ Connector spec {" + connectorType + "} by " + byWho);
                ManageBiz ms = new ManageBiz();

                ms.DeleteConnectorSpec(connectorType);
                resCode = "00";
                resDesc = "";
            }
            catch (Exception ex)
            {
                resCode = "EX";
                resDesc = ex.Message;
                Log.AppendText(ex.Message);
            }
        }
 public string AddNewHistory(string boardName, string byWho, out string resCode, out string resDesc) // Return file name of board history
 {
     try
     {
         Log.AppendText("กำลังเปิดการบันทึก Run history. {" + boardName + "} by " + byWho);
         ManageBiz ms       = new ManageBiz();
         int       runIndex = ms.GetNextRunHistoryBy(boardName);
         Log.AppendText("รหัสสำหรับ " + boardName + " คือ " + runIndex.ToString());
         string historyFile = ms.AddNewRunHistory(boardName, byWho);
         resCode = "00";
         resDesc = "";
         return(historyFile);
     }
     catch (Exception ex)
     {
         resCode = "EX";
         resDesc = ex.Message;
         Log.AppendText(ex.Message);
         return("");
     }
 }
Example #15
0
        public void ShowDialog()
        {
            IsSelected = false;

            frmSelectBoard f = new frmSelectBoard();

            List <string> boards = new List <string>();
            ManageBiz     ms     = new ManageBiz();
            DataTable     dt;

            dt = ms.GetBoardList();
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow r in dt.Rows)
                    {
                        boards.Add(r["BoardName"].ToString());
                    }
                }
            }
            f.BoardList = boards;

            DialogResult ret = f.ShowDialog();

            if (ret == DialogResult.OK)
            {
                if (!f.SelectedBoard.BoardName.Equals(""))
                {
                    SelectedBoard = f.SelectedBoard;
                    IsSelected    = true;
                }
                else
                {
                    SelectedBoard = new BoardInfo("");
                    IsSelected    = false;
                }
            }
        }
Example #16
0
 public void SaveBoardSpec(string boardName, string DESC, string imageFile, float boardThickness, float boardWidth, float boardLength, float fixtureThickness,
                           List <int> rowList, List <float> xList, List <float> yList, List <float> angleList, List <string> connectorList, List <string> commentsList,
                           string byWho, out string resCode, out string resDesc)
 {
     try
     {
         Log.AppendText("กำลังบันทึกข้อมูล Board spec. {" +
                        boardName + ", " + DESC + ", " + boardThickness.ToString() + ", " +
                        boardWidth.ToString() + ", " + boardLength.ToString() + ", " +
                        fixtureThickness.ToString() + ", Connector count = " + rowList.Count.ToString() + "} by " + byWho);
         ManageBiz ms = new ManageBiz();
         DataTable dt;
         dt = ms.GetBoardBy(boardName);
         if (dt.Rows.Count == 0)
         {
             Log.AppendText("ตรวจสอบ  Board spec. เรียบร้อย");
             ms.AddNewBoardSpec(boardName, DESC, imageFile, boardWidth, boardLength, boardThickness, fixtureThickness,
                                rowList, xList, yList, angleList, connectorList, commentsList);
             resCode = "00";
             resDesc = "";
         }
         else
         {
             Log.AppendText("WARNING! : Board spec. ซ้ำ");
             Log.AppendText("เริ่มต้น Update  Board spec....");
             ms.UpdateBoardSpec(boardName, DESC, imageFile, boardWidth, boardLength, boardThickness, fixtureThickness,
                                rowList, xList, yList, angleList, connectorList, commentsList);
             resCode = "01";
             resDesc = "";
         }
     }
     catch (Exception ex)
     {
         resCode = "EX";
         resDesc = ex.Message;
         Log.AppendText(ex.Message);
     }
 }
        public void LoadToolData(string toolType, ref TextBox _clearance, ref TextBox _height, ref TextBox _width, ref TextBox _length, ref TextBox _barcode, ref TextBox _comments)
        {
            try
            {
                Log.AppendText("กำลังเรียกข้อมูล Tools {" + toolType + "}");

                _clearance.Text = "";
                _height.Text    = "";
                _width.Text     = "";
                _length.Text    = "";
                _barcode.Text   = "";
                _comments.Text  = "";

                ManageBiz ms = new ManageBiz();
                DataTable dtUser;
                dtUser = ms.GetToolBy(toolType);
                if (dtUser.Rows.Count > 0)
                {
                    _clearance.Text = dtUser.Rows[0]["Clearance"].ToString();
                    _height.Text    = dtUser.Rows[0]["Height"].ToString();
                    _width.Text     = dtUser.Rows[0]["Width"].ToString();
                    _length.Text    = dtUser.Rows[0]["Length"].ToString();
                    _barcode.Text   = dtUser.Rows[0]["Barcode"].ToString();
                    _comments.Text  = dtUser.Rows[0]["Comments"].ToString();

                    Log.AppendText("เรียกข้อมูล Tools เรียบร้อย");
                }
                else
                {
                    Log.AppendText("ไม่พบข้อมูล Tools");
                }
            }
            catch (Exception ex)
            {
                Log.AppendText(ex.Message);
                MessageBox.Show(ex.Message);
            }
        }
        public void LoadConnectorSpec(string connectorType, ref ComboBox _ToolType, ref ComboBox _ProfileName, ref TextBox _Pins,
                                      ref TextBox _baseThickness, ref TextBox _unseatedTop, ref TextBox _height, ref TextBox _seatedHeight,
                                      ref TextBox _graphFPerPin, ref TextBox _graphDistance,
                                      ref TextBox _minFPerPin, ref TextBox _maxFPerPin, ref TextBox _userFPerPin, ref TextBox _otherForce,
                                      ref TextBox _parsPercent, ref TextBox _parsStartHeight, ref TextBox _parsDistance,
                                      ref TextBox _gradDegrees, ref TextBox _comments)
        {
            try
            {
                Log.AppendText("กำลังเรียกข้อมูล Connector spec. {" + connectorType + "}");

                DataTable dtConnector   = new DataTable();
                DataTable dtToolType    = new DataTable();
                DataTable dtProfileName = new DataTable();
                ManageBiz ms            = new ManageBiz();

                dtConnector   = ms.GetConnectorBy(connectorType);
                dtToolType    = ms.GetToolList();
                dtProfileName = ms.GetProfileList();

                if (dtConnector.Rows.Count > 0)
                {
                    _ToolType.DataSource    = null;
                    _ToolType.DataSource    = dtToolType;
                    _ToolType.DisplayMember = "ToolType";
                    _ToolType.ValueMember   = "ToolType";
                    _ToolType.Text          = dtConnector.Rows[0]["ToolType"].ToString();

                    _ProfileName.DataSource    = null;
                    _ProfileName.DataSource    = dtProfileName;
                    _ProfileName.DisplayMember = "ProfileName";
                    _ProfileName.ValueMember   = "ProfileName";
                    _ProfileName.Text          = dtConnector.Rows[0]["ProfileName"].ToString();

                    _Pins.Text = dtConnector.Rows[0]["NumberOfPins"].ToString();

                    _baseThickness.Text = dtConnector.Rows[0]["BaseThickness"].ToString();
                    _unseatedTop.Text   = dtConnector.Rows[0]["UnseatedTop"].ToString();
                    _height.Text        = dtConnector.Rows[0]["Height"].ToString();
                    _seatedHeight.Text  = dtConnector.Rows[0]["SeatedHeight"].ToString();

                    _graphFPerPin.Text  = dtConnector.Rows[0]["GraphFPerPin"].ToString();
                    _graphDistance.Text = dtConnector.Rows[0]["GraphDistance"].ToString();

                    _minFPerPin.Text  = dtConnector.Rows[0]["MinFPerPin"].ToString();
                    _maxFPerPin.Text  = dtConnector.Rows[0]["MaxFPerPin"].ToString();
                    _userFPerPin.Text = dtConnector.Rows[0]["UserFPerPin"].ToString();
                    _userFPerPin.Text = dtConnector.Rows[0]["OtherForce"].ToString();

                    _parsPercent.Text     = dtConnector.Rows[0]["PARSPercent"].ToString();
                    _parsStartHeight.Text = dtConnector.Rows[0]["PARSStartHeight"].ToString();
                    _parsDistance.Text    = dtConnector.Rows[0]["PARSDistance"].ToString();

                    _gradDegrees.Text = dtConnector.Rows[0]["FGradDegrees"].ToString();

                    _comments.Text = dtConnector.Rows[0]["Comments"].ToString();

                    Log.AppendText("เรียกข้อมูล Tools เรียบร้อย");
                }
                else
                {
                    Log.AppendText("ไม่พบข้อมูล Tools");
                }
            }
            catch (Exception ex) { Log.AppendText(ex.Message); MessageBox.Show(ex.Message); }
        }
        //
        // ---------------------------------------------------------
        // Constructor
        // ---------------------------------------------------------
        public ConnectorInfo(string connectorType, float x, float y, float angle, string comments, float fixtureThickness, float boardThickness)
        {
            // Preseting
            ToolType    = "";
            ProfileName = "";
            //
            NumberOfPins     = 0;
            CONBaseThickness = 0; CONUnseatedTop = 0; CONHeight = 0; CONSeatedHeight = 0;
            //
            GraphFPerPin = 0; GraphDistance = 0;
            //
            MinFPerPin = 0; MaxFPerPin = 0; UserFPerPin = 0; OtherForce = 0;
            //
            PARSPercent = 0; PARSStartHeight = 0; PARSDistance = 0;
            //
            FGradDegrees = 0;
            CONComments  = "";
            //
            ToolClearance = 0; ToolHeight = 0; ToolWidth = 0; ToolLength = 0;
            //
            ToolBarcode = ""; ToolComments = "";
            //
            PARSSamplingStartHeight = 0; PARSSamplingDistance = 0;
            //
            Error1 = ""; Error2 = ""; Error3 = ""; Error4 = ""; Error5 = "";
            //
            H1Par = 0; H2Par = 0; H3Par = 0; H4Par = 0; H5Par = 0; H6Par = 0; H7Par = 0;
            //
            HAC1 = ""; HAC2 = ""; HAC3 = ""; HAC4 = ""; HAC5 = ""; HAC6 = ""; HAC7 = "";
            //
            F1Par = 0; F2Par = 0; F3Par = 0; F4Par = 0; F5Par = 0; F6Par = 0; F7Par = 0;
            //
            FAC1 = ""; FAC2 = ""; FAC3 = ""; FAC4 = ""; FAC5 = ""; FAC6 = ""; FAC7 = "";
            //
            SP1 = 0; SP2 = 0; SP3 = 0; SP4 = 0; SP5 = 0; SP6 = 0; SP7 = 0;
            //
            // Assigning
            this.ConnectorType = connectorType;
            //
            this.X        = x;
            this.Y        = y;
            this.Angle    = angle;
            this.Comments = comments;
            //
            this.FixtureThickness = fixtureThickness;
            this.BoardThickness   = boardThickness;
            //
            this.Location = new PointF(x, y);
            //
            // Connector type database
            ManageBiz ms = new ManageBiz();
            DataTable dtCON;

            dtCON = ms.GetConnectorBy(connectorType);
            if (dtCON != null)
            {
                if (dtCON.Rows.Count > 0)
                {
                    ToolType    = dtCON.Rows[0]["ToolType"].ToString();
                    ProfileName = dtCON.Rows[0]["ProfileName"].ToString();
                    //
                    NumberOfPins     = int.Parse(dtCON.Rows[0]["NumberOfPins"].ToString());
                    CONBaseThickness = float.Parse(dtCON.Rows[0]["BaseThickness"].ToString());
                    CONUnseatedTop   = float.Parse(dtCON.Rows[0]["UnseatedTop"].ToString());
                    CONHeight        = float.Parse(dtCON.Rows[0]["Height"].ToString());
                    CONSeatedHeight  = float.Parse(dtCON.Rows[0]["SeatedHeight"].ToString());
                    //
                    GraphFPerPin  = float.Parse(dtCON.Rows[0]["GraphFPerPin"].ToString());
                    GraphDistance = float.Parse(dtCON.Rows[0]["GraphDistance"].ToString());
                    //
                    MinFPerPin  = float.Parse(dtCON.Rows[0]["MinFPerPin"].ToString());
                    MaxFPerPin  = float.Parse(dtCON.Rows[0]["MaxFPerPin"].ToString());
                    UserFPerPin = float.Parse(dtCON.Rows[0]["UserFPerPin"].ToString());
                    OtherForce  = float.Parse(dtCON.Rows[0]["OtherForce"].ToString());
                    //
                    PARSPercent     = float.Parse(dtCON.Rows[0]["PARSPercent"].ToString());
                    PARSStartHeight = float.Parse(dtCON.Rows[0]["PARSStartHeight"].ToString());
                    PARSDistance    = float.Parse(dtCON.Rows[0]["PARSDistance"].ToString());
                    //
                    FGradDegrees = float.Parse(dtCON.Rows[0]["FGradDegrees"].ToString());
                    //
                    CONComments = dtCON.Rows[0]["Comments"].ToString();
                }
            }
            dtCON.Dispose();
            dtCON = null;
            //
            // Tool type database
            DataTable dtTOOL;

            dtTOOL = ms.GetToolBy(ToolType);
            if (dtTOOL != null)
            {
                if (dtTOOL.Rows.Count > 0)
                {
                    ToolClearance = float.Parse(dtTOOL.Rows[0]["Clearance"].ToString());
                    ToolHeight    = float.Parse(dtTOOL.Rows[0]["Height"].ToString());
                    ToolWidth     = float.Parse(dtTOOL.Rows[0]["Width"].ToString());
                    ToolLength    = float.Parse(dtTOOL.Rows[0]["Length"].ToString());
                    //
                    ToolBarcode  = dtTOOL.Rows[0]["Barcode"].ToString();
                    ToolComments = dtTOOL.Rows[0]["Comments"].ToString();
                }
            }
            dtTOOL.Dispose();
            dtTOOL = null;
            //
            // Profile database
            DataTable dtPF;

            dtPF = ms.GetProfileBy(ProfileName);
            if (dtPF != null)
            {
                if (dtPF.Rows.Count > 0)
                {
                    PARSSamplingStartHeight = float.Parse(dtPF.Rows[0]["StartHeight"].ToString());
                    PARSSamplingDistance    = float.Parse(dtPF.Rows[0]["Distance"].ToString());
                    //
                    Error1 = dtPF.Rows[0]["Error1"].ToString();
                    Error2 = dtPF.Rows[0]["Error2"].ToString();
                    Error3 = dtPF.Rows[0]["Error3"].ToString();
                    Error4 = dtPF.Rows[0]["Error4"].ToString();
                    Error5 = dtPF.Rows[0]["Error5"].ToString();
                    //
                    H1Par = float.Parse(dtPF.Rows[0]["H1Par"].ToString());
                    H2Par = float.Parse(dtPF.Rows[0]["H2Par"].ToString());
                    H3Par = float.Parse(dtPF.Rows[0]["H3Par"].ToString());
                    H4Par = float.Parse(dtPF.Rows[0]["H4Par"].ToString());
                    H5Par = float.Parse(dtPF.Rows[0]["H5Par"].ToString());
                    H6Par = float.Parse(dtPF.Rows[0]["H6Par"].ToString());
                    H7Par = float.Parse(dtPF.Rows[0]["H7Par"].ToString());
                    //
                    HAC1 = dtPF.Rows[0]["HAC1"].ToString();
                    HAC2 = dtPF.Rows[0]["HAC2"].ToString();
                    HAC3 = dtPF.Rows[0]["HAC3"].ToString();
                    HAC4 = dtPF.Rows[0]["HAC4"].ToString();
                    HAC5 = dtPF.Rows[0]["HAC5"].ToString();
                    HAC6 = dtPF.Rows[0]["HAC6"].ToString();
                    HAC7 = dtPF.Rows[0]["HAC7"].ToString();
                    //
                    F1Par = float.Parse(dtPF.Rows[0]["F1Par"].ToString());
                    F2Par = float.Parse(dtPF.Rows[0]["F2Par"].ToString());
                    F3Par = float.Parse(dtPF.Rows[0]["F3Par"].ToString());
                    F4Par = float.Parse(dtPF.Rows[0]["F4Par"].ToString());
                    F5Par = float.Parse(dtPF.Rows[0]["F5Par"].ToString());
                    F6Par = float.Parse(dtPF.Rows[0]["F6Par"].ToString());
                    F7Par = float.Parse(dtPF.Rows[0]["F7Par"].ToString());
                    //
                    FAC1 = dtPF.Rows[0]["FAC1"].ToString();
                    FAC2 = dtPF.Rows[0]["FAC2"].ToString();
                    FAC3 = dtPF.Rows[0]["FAC3"].ToString();
                    FAC4 = dtPF.Rows[0]["FAC4"].ToString();
                    FAC5 = dtPF.Rows[0]["FAC5"].ToString();
                    FAC6 = dtPF.Rows[0]["FAC6"].ToString();
                    FAC7 = dtPF.Rows[0]["FAC7"].ToString();
                    //
                    SP1 = float.Parse(dtPF.Rows[0]["SP1"].ToString());
                    SP2 = float.Parse(dtPF.Rows[0]["SP2"].ToString());
                    SP3 = float.Parse(dtPF.Rows[0]["SP3"].ToString());
                    SP4 = float.Parse(dtPF.Rows[0]["SP4"].ToString());
                    SP5 = float.Parse(dtPF.Rows[0]["SP5"].ToString());
                    SP6 = float.Parse(dtPF.Rows[0]["SP6"].ToString());
                    SP7 = float.Parse(dtPF.Rows[0]["SP7"].ToString());
                }
            }
            dtPF.Dispose();
            dtPF = null;
            //
            // Compute tool parameters
            this.ToolSize = new SizeF(this.ToolWidth, this.ToolLength);
            if (this.ToolSize.Width <= 0)
            {
                this.ToolSize.Width = 1;
            }
            if (this.ToolSize.Height <= 0)
            {
                this.ToolSize.Height = 1;
            }
            //
            //

            /* -----------------------------------------------------------------------------------------
            * ชุดคำสั่ง ต่อไปนี้ ถูกออกแบบตามความต้องการ เข้าถึงข้อมูลจากฐานข้อมูล
            * เช่น ระยะสั่งให้เลื่อนแท่นกด เป็นต้น
            * ----------------------------------------------------------------------------------------*/
            /* ----------------------------------------------
             * Graph scaling
             * ----------------------------------------------*/
            GraphHorizontalFrom = CONUnseatedTop - CONHeight;
            GraphHorizontalTo   = GraphHorizontalFrom - GraphDistance;
            //
            GraphVerticalFrom = 0;
            GraphVerticalTo   = GraphFPerPin;
            //
            GraphForceLimit  = MaxFPerPin / 2 + MinFPerPin / 2;
            GraphHeightLimit = 0;
            //

            /* ----------------------------------------------
             * Height parameters
             * ----------------------------------------------*/
            GotoZeroSpeed = Properties.Settings.Default.GotoZeroSpeed; // mm per sec
            ZeroClearance = Properties.Settings.Default.ZeroClearance; //mm
            ZeroHeight    = Properties.Settings.Default.ZeroHeight;    // mm
            //

            /* ----------------------------------------------
             * Distance parameters
             * ----------------------------------------------*/
            UnseatedToolTop          = FixtureThickness + BoardThickness + CONUnseatedTop - CONHeight + CONBaseThickness + ToolHeight;
            Distance_UnseatedToolTop = ZeroHeight - UnseatedToolTop;
            AboveBoardBaseHeight     = CONUnseatedTop - CONHeight;
            Distance_Seated          = AboveBoardBaseHeight - CONSeatedHeight;
            //

            /* ----------------------------------------------
             * Profiled distance parameters
             * เครื่องหมาย (-) ให้กำหนดระยะ Jog แบบทิศขึ้นเป็น (-)
             * ----------------------------------------------*/
            PF_Row0_Distance = Distance_UnseatedToolTop - Properties.Settings.Default.OffsetTopDistance;
            PF_Row1_Distance = Properties.Settings.Default.OffsetTopDistance - H1Par;
            PF_Row2_Distance = Distance_Seated - H2Par + H1Par;
            PF_Row3_Distance = Distance_Seated - H3Par + H1Par;
            PF_Row4_Distance = Distance_Seated - H4Par + H1Par;
            PF_Row5_Distance = Distance_Seated - H5Par + H1Par;
            PF_Row6_Distance = Distance_Seated - H6Par + H1Par;
            PF_Row7_Distance = Distance_Seated - H7Par + H1Par;
            //

            /* ----------------------------------------------
             * Profiled distance parameters
             * ----------------------------------------------*/
            PF_Row1_Force = F1Par;
            PF_Row2_Force = MinFPerPin * NumberOfPins + F2Par;
            PF_Row3_Force = MaxFPerPin * NumberOfPins + F3Par;
            PF_Row4_PARS  = F4Par;
            PF_Row5_Force = F5Par;
            PF_Row6_Force = MaxFPerPin * NumberOfPins + F6Par;
            PF_Row7_Grad  = F7Par;
            //
        }
Example #20
0
        public void LoadBoardSpec(string boardName, ref TextBox _Desc,
                                  ref TextBox _boardWidth, ref TextBox _boardLength, ref TextBox _boardThickness, ref TextBox _fixtureThickness,
                                  ref TextBox _imageFile, ref ListView lvDetail, ref BoardModelClass _bmcPreview, ref PictureBox _picPreview)
        {
            try
            {
                Log.AppendText("กำลังเรียกข้อมูล Board spec. {" + boardName + "}");

                _Desc.Text             = "";
                _boardWidth.Text       = "";
                _boardLength.Text      = "";
                _boardThickness.Text   = "";
                _fixtureThickness.Text = "";
                _imageFile.Text        = "";
                lvDetail.Items.Clear();

                ManageBiz ms = new ManageBiz();
                DataTable dt;
                dt = ms.GetBoardBy(boardName);
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        string desc             = dt.Rows[0]["DESC"].ToString();
                        float  boardWidth       = float.Parse(dt.Rows[0]["BoardWidth"].ToString());
                        float  boardLength      = float.Parse(dt.Rows[0]["BoardLength"].ToString());
                        float  boardThickness   = float.Parse(dt.Rows[0]["BoardThickness"].ToString());
                        float  fixtureThickness = float.Parse(dt.Rows[0]["FixtureThickness"].ToString());
                        string imageFile        = dt.Rows[0]["ImageFile"].ToString();

                        _Desc.Text             = desc;
                        _boardWidth.Text       = boardWidth.ToString();
                        _boardLength.Text      = boardLength.ToString();
                        _boardThickness.Text   = boardThickness.ToString();
                        _fixtureThickness.Text = fixtureThickness.ToString();
                        _imageFile.Text        = imageFile;

                        // Detail
                        DataTable dtDetail = ms.GetBoardDetailBy(boardName);
                        if (dtDetail != null)
                        {
                            if (dtDetail.Rows.Count > 0)
                            {
                                foreach (DataRow r in dtDetail.Rows)
                                {
                                    float  x             = float.Parse(r["X"].ToString());
                                    float  y             = float.Parse(r["Y"].ToString());
                                    float  angle         = float.Parse(r["Angle"].ToString());
                                    string connectorType = r["ConnectorType"].ToString();
                                    string comments      = r["Comments"].ToString();

                                    string[] astr = { r["RowNbr"].ToString(), x.ToString("0.000"), y.ToString("0.000"), angle.ToString("0.0"),
                                                      connectorType,          comments };
                                    lvDetail.Items.Add(new ListViewItem(astr));
                                }
                            }
                        }

                        BoardInfo info = new BoardInfo(boardName);
                        if (_bmcPreview == null)
                        {
                            _bmcPreview = new BoardModelClass(ref _picPreview, info);
                        }
                        else
                        {
                            _bmcPreview.UpdateBoardInfo(info);
                        }

                        Log.AppendText("เรียกข้อมูล Board spec. เรียบร้อย");
                    }
                    else
                    {
                        Log.AppendText("ไม่พบข้อมูล Board spec.");
                    }
                }
            }
            catch (Exception ex)
            {
                Log.AppendText(ex.Message);
                MessageBox.Show(ex.Message);
            }
        }
        public void LoadProfileData(string profileName, ref TextBox _Start, ref TextBox _Distance, ref TextBox _E1, ref TextBox _E2, ref TextBox _E3, ref TextBox _E4, ref TextBox _E5, ref ListView lv)
        {
            try
            {
                Log.AppendText("กำลังเรียกข้อมูล Profile data {" + profileName + "}");

                _Start.Text    = "";
                _Distance.Text = "";
                _E1.Text       = "";
                _E2.Text       = "";
                _E3.Text       = "";
                _E4.Text       = "";
                _E5.Text       = "";

                ManageBiz ms = new ManageBiz();
                DataTable dtUser;
                dtUser = ms.GetProfileBy(profileName);
                if (dtUser.Rows.Count > 0)
                {
                    _Start.Text    = dtUser.Rows[0]["StartHeight"].ToString();
                    _Distance.Text = dtUser.Rows[0]["Distance"].ToString();

                    _E1.Text = dtUser.Rows[0]["Error1"].ToString();
                    _E2.Text = dtUser.Rows[0]["Error2"].ToString();
                    _E3.Text = dtUser.Rows[0]["Error3"].ToString();
                    _E4.Text = dtUser.Rows[0]["Error4"].ToString();
                    _E5.Text = dtUser.Rows[0]["Error5"].ToString();

                    lv.Items[0].SubItems[2].Text = dtUser.Rows[0]["H1Par"].ToString();
                    lv.Items[0].SubItems[3].Text = dtUser.Rows[0]["HAC1"].ToString();
                    lv.Items[0].SubItems[5].Text = dtUser.Rows[0]["F1Par"].ToString();
                    lv.Items[0].SubItems[6].Text = dtUser.Rows[0]["FAC1"].ToString();
                    lv.Items[0].SubItems[7].Text = dtUser.Rows[0]["SP1"].ToString();

                    lv.Items[1].SubItems[2].Text = dtUser.Rows[0]["H2Par"].ToString();
                    lv.Items[1].SubItems[3].Text = dtUser.Rows[0]["HAC2"].ToString();
                    lv.Items[1].SubItems[5].Text = dtUser.Rows[0]["F2Par"].ToString();
                    lv.Items[1].SubItems[6].Text = dtUser.Rows[0]["FAC2"].ToString();
                    lv.Items[1].SubItems[7].Text = dtUser.Rows[0]["SP2"].ToString();

                    lv.Items[2].SubItems[2].Text = dtUser.Rows[0]["H3Par"].ToString();
                    lv.Items[2].SubItems[3].Text = dtUser.Rows[0]["HAC3"].ToString();
                    lv.Items[2].SubItems[5].Text = dtUser.Rows[0]["F3Par"].ToString();
                    lv.Items[2].SubItems[6].Text = dtUser.Rows[0]["FAC3"].ToString();
                    lv.Items[2].SubItems[7].Text = dtUser.Rows[0]["SP3"].ToString();

                    lv.Items[3].SubItems[2].Text = dtUser.Rows[0]["H4Par"].ToString();
                    lv.Items[3].SubItems[3].Text = dtUser.Rows[0]["HAC4"].ToString();
                    lv.Items[3].SubItems[5].Text = dtUser.Rows[0]["F4Par"].ToString();
                    lv.Items[3].SubItems[6].Text = dtUser.Rows[0]["FAC4"].ToString();
                    lv.Items[3].SubItems[7].Text = dtUser.Rows[0]["SP4"].ToString();

                    lv.Items[4].SubItems[2].Text = dtUser.Rows[0]["H5Par"].ToString();
                    lv.Items[4].SubItems[3].Text = dtUser.Rows[0]["HAC5"].ToString();
                    lv.Items[4].SubItems[5].Text = dtUser.Rows[0]["F5Par"].ToString();
                    lv.Items[4].SubItems[6].Text = dtUser.Rows[0]["FAC5"].ToString();
                    lv.Items[4].SubItems[7].Text = dtUser.Rows[0]["SP5"].ToString();

                    lv.Items[5].SubItems[2].Text = dtUser.Rows[0]["H6Par"].ToString();
                    lv.Items[5].SubItems[3].Text = dtUser.Rows[0]["HAC6"].ToString();
                    lv.Items[5].SubItems[5].Text = dtUser.Rows[0]["F6Par"].ToString();
                    lv.Items[5].SubItems[6].Text = dtUser.Rows[0]["FAC6"].ToString();
                    lv.Items[5].SubItems[7].Text = dtUser.Rows[0]["SP6"].ToString();

                    lv.Items[6].SubItems[2].Text = dtUser.Rows[0]["H7Par"].ToString();
                    lv.Items[6].SubItems[3].Text = dtUser.Rows[0]["HAC7"].ToString();
                    lv.Items[6].SubItems[5].Text = dtUser.Rows[0]["F7Par"].ToString();
                    lv.Items[6].SubItems[6].Text = dtUser.Rows[0]["FAC7"].ToString();
                    lv.Items[6].SubItems[7].Text = dtUser.Rows[0]["SP7"].ToString();

                    Log.AppendText("เรียกข้อมูล Profile เรียบร้อย");
                }
                else
                {
                    Log.AppendText("ไม่พบข้อมูล Profile");
                }
            }
            catch (Exception ex)
            {
                Log.AppendText(ex.Message);
                MessageBox.Show(ex.Message);
            }
        }