Exemplo n.º 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                #region 공장등록 & 수정
                if (cboCategory.Text == "" || txtCode.Text == "" || cboType.Text == "" || cboParent.Text == "" ||
                    txtName.Text == "" || cboUseYN.Text == "")
                {
                    MessageBox.Show("필수정보 입력 필요");
                    return;
                }

                //공통코드 완성 후 콤보박스 바인딩하고 수정이 필요
                FACTORY_VO vo = new FACTORY_VO();
                vo.FAC_CODE         = txtCode.Text;
                vo.FAC_FCLTY        = cboCategory.Text;
                vo.FAC_FCLTY_PARENT = cboParent.Text;
                vo.FAC_NAME         = txtName.Text;
                vo.FAC_TYP          = cboType.Text;
                vo.FAC_FREE_YN      = cboFreeYN.Text;

                //순서 텍스트에 null, 숫자 외 입력시 null 값 입력
                if (int.TryParse(txtSort.Text, out int plzNull))
                {
                    vo.FAC_TYP_SORT = plzNull;
                }
                else
                {
                    vo.FAC_TYP_SORT = null;
                }
                vo.FAC_DEMAND_YN = cboDemandYN.Text;
                vo.FAC_PROCS_YN  = cboProcYN.Text;
                vo.FAC_MTRL_YN   = cboMtrlYN.Text;
                vo.FAC_LAST_MDFR = txtModifier.Text;
                vo.FAC_LAST_MDFY = txtModifyDate.Text;
                vo.FAC_USE_YN    = cboUseYN.Text;
                vo.FAC_DESC      = txtDesc.Text;
                vo.COM_NAME      = (cboCom.Text.Length < 1) ? "" : cboCom.SelectedValue.ToString();


                FactoryService service = new FactoryService();
                Message        msg     = service.SaveFactory(vo, Update);
                if (msg.IsSuccess)
                {
                    MessageBox.Show(msg.ResultMessage);
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show(msg.ResultMessage);
                    return;
                }

                #endregion
            }
            catch (Exception err)
            {
                this.Log.WriteError($"[[RECV {this.Name}]]:{err.Message}");
            }
        }
Exemplo n.º 2
0
        //데이터 insert
        public Message SaveFactory(FACTORY_VO fac, bool update)
        {
            try
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = new SqlConnection(this.ConnectionString);
                    cmd.CommandText = "SP_SaveFactory";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@P_UPDATE", update);
                    cmd.Parameters.AddWithValue("@P_FAC_CODE", fac.FAC_CODE);
                    cmd.Parameters.AddWithValue("@P_FAC_FCLTY", fac.FAC_FCLTY);
                    cmd.Parameters.AddWithValue("@P_FAC_FCLTY_PARENT", fac.FAC_FCLTY_PARENT);
                    cmd.Parameters.AddWithValue("@P_FAC_NAME", fac.FAC_NAME);
                    cmd.Parameters.AddWithValue("@P_FAC_TYP", fac.FAC_TYP);
                    cmd.Parameters.AddWithValue("@P_FAC_FREE_YN", fac.FAC_FREE_YN);
                    cmd.Parameters.Add(new SqlParameter("@P_FAC_TYP_SORT", System.Data.SqlDbType.Int));
                    cmd.Parameters["@P_FAC_TYP_SORT"].Value = (object)fac.FAC_TYP_SORT ?? DBNull.Value;
                    cmd.Parameters.AddWithValue("@P_FAC_DEMAND_YN", fac.FAC_DEMAND_YN);
                    cmd.Parameters.AddWithValue("@P_FAC_PROCS_YN", fac.FAC_PROCS_YN);
                    cmd.Parameters.AddWithValue("@P_FAC_MTRL_YN", fac.FAC_MTRL_YN);
                    cmd.Parameters.AddWithValue("@P_FAC_LAST_MDFR", fac.FAC_LAST_MDFR);
                    cmd.Parameters.AddWithValue("@P_FAC_LAST_MDFY", fac.FAC_LAST_MDFY);
                    cmd.Parameters.AddWithValue("@P_FAC_USE_YN", fac.FAC_USE_YN);
                    cmd.Parameters.AddWithValue("@P_FAC_DESC", fac.FAC_DESC);
                    cmd.Parameters.AddWithValue("@P_COM_NAME", fac.COM_NAME);
                    cmd.Parameters.Add(new SqlParameter("@P_ReturnCode", System.Data.SqlDbType.NVarChar, 5));
                    cmd.Parameters["@P_ReturnCode"].Direction = System.Data.ParameterDirection.Output;

                    cmd.Connection.Open();
                    cmd.ExecuteNonQuery();
                    cmd.Connection.Close();

                    string  result  = cmd.Parameters["@P_ReturnCode"].Value.ToString();
                    Message message = new Message();
                    if (result == "S01")
                    {
                        message.IsSuccess     = true;
                        message.ResultMessage = "성공적으로 등록되었습니다.";
                    }
                    else if (result == "S02")
                    {
                        message.IsSuccess     = true;
                        message.ResultMessage = "성공적으로 수정되었습니다.";
                    }
                    else if (result == "S03")
                    {
                        message.IsSuccess     = false;
                        message.ResultMessage = "코드 중복";
                    }
                    else if (result == "S00")
                    {
                        message.IsSuccess     = false;
                        message.ResultMessage = "실패하였습니다.";
                    }

                    return(message);
                }
            }
            catch (Exception err)
            {
                return(new Message(err));
            }
        }
Exemplo n.º 3
0
        public Message SaveFactory(FACTORY_VO fac, bool update)
        {
            FactoryDAC dac = new FactoryDAC();

            return(dac.SaveFactory(fac, update));
        }