Пример #1
0
        private void Metal_Logic()
        {
            try
            {
                if (txt_faccd.Text.ToString().Equals(""))
                {
                    MessageBox.Show("관리번호를 입력하시기 바랍니다.");
                    return;
                }

                if (txt_facnm.Text.ToString().Equals(""))
                {
                    MessageBox.Show("제품명을 입력하시기 바랍니다.");
                    return;
                }

                if (txt_sn.Text.ToString().Equals(""))
                {
                    MessageBox.Show("장비S/N을 입력하시기 바랍니다.");
                    return;
                }



                if (path != null && path != "")
                {
                    flow_img      = ComInfo.GetImage(path);
                    flow_img_size = flow_img.Length;
                }
                else
                {
                    flow_img      = null;
                    flow_img_size = 0;
                }


                if (txt_price.Text.ToString() == "" | txt_price.Text.ToString() == null)
                {
                    txt_price.Text = "0";
                }

                if (txt_amount.Text.ToString() == "" | txt_amount.Text.ToString() == null)
                {
                    txt_amount.Text = "0";
                }

                if (txt_faccd.Enabled)
                {
                    wnDm wDm   = new wnDm();
                    int  rsNum = wDm.InsertFac(
                        txt_faccd.Text.ToString()
                        , txt_facnm.Text.ToString()
                        , txt_sn.Text.ToString()
                        , txt_spec.Text.ToString()
                        , int.Parse(txt_amount.Text.ToString().Replace(",", ""))
                        , dtp_makedate.Text.ToString()
                        , dtp_buydate.Text.ToString()
                        , int.Parse(txt_price.Text.ToString().Replace(",", ""))
                        , txt_makecust.Text.ToString()
                        , txt_comment.Text.ToString()
                        , txt생산능력.Text.ToString().Replace(",", "")
                        , cmb_mainten.SelectedValue.ToString().Replace(",", "")
                        , flow_img
                        , flow_img_size
                        , txt마력.Text.ToString().Replace(",", "")
                        , txt점검주기.Text.ToString().Replace(",", "")
                        , cmb_dept.SelectedValue.ToString()
                        );
                    if (rsNum == 0)
                    {
                        resetSetting();
                        MessageBox.Show("성공적으로 등록하였습니다.");
                    }
                    else if (rsNum == 1)
                    {
                        MessageBox.Show("저장에 실패하였습니다");
                    }
                    else if (rsNum == 2)
                    {
                        MessageBox.Show("SQL COMMAND 에러");
                    }
                    else if (rsNum == 3)
                    {
                        MessageBox.Show("기존 코드가 있으니 \n 다른 코드로 입력 바랍니다.");
                    }
                    else
                    {
                        MessageBox.Show("Exception 에러1");
                    }
                }
                else
                {
                    if (!right[1])
                    {
                        MessageBox.Show("권한이없습니다.");
                        return;
                    }
                    wnDm wDm   = new wnDm();
                    int  rsNum = wDm.UpdateFac(
                        txt_faccd.Text.ToString()
                        , txt_facnm.Text.ToString()
                        , txt_sn.Text.ToString()
                        , txt_spec.Text.ToString()
                        , int.Parse(txt_amount.Text.ToString())
                        , dtp_makedate.Text.ToString()
                        , dtp_buydate.Text.ToString()
                        , int.Parse(txt_price.Text.ToString())
                        , txt_makecust.Text.ToString()
                        , txt_comment.Text.ToString()
                        );
                    if (rsNum == 0)
                    {
                        MessageBox.Show("성공적으로 수정하였습니다.");
                    }
                    else if (rsNum == 1)
                    {
                        MessageBox.Show("저장에 실패하였습니다");
                    }
                    else
                    {
                        MessageBox.Show("Exception 에러");
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }