示例#1
0
        /// <summary>
        /// 영업마스터 수작업으로 등록
        /// </summary>
        /// <param name="VO"></param>
        /// <returns></returns>
        public bool AddOneSOMaster(SOMasterVO VO)
        {
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.Connection  = new SqlConnection(this.ConnectionString);
                cmd.CommandText = "insert into TBL_SO_MASTER(plan_id, so_wo_id, company_code, company_type, product_name, so_pcount, so_edate, so_sdate, so_ocount, so_ccount, so_comment) " +
                                  "values(@plan_id, @so_wo_id, @company_code, @company_type, @product_name, @so_pcount, @so_edate, @so_sdate, 0, 0, @so_comment)";
                cmd.CommandType = CommandType.Text;

                cmd.Parameters.AddWithValue("@plan_id", VO.plan_id);
                cmd.Parameters.AddWithValue("@so_wo_id", VO.so_wo_id);
                cmd.Parameters.AddWithValue("@company_code", VO.company_code);
                cmd.Parameters.AddWithValue("@company_type", VO.company_type);
                cmd.Parameters.AddWithValue("@product_name", VO.product_name);
                cmd.Parameters.AddWithValue("@so_pcount", VO.so_pcount);
                cmd.Parameters.AddWithValue("@so_edate", VO.so_edate);
                cmd.Parameters.AddWithValue("@so_sdate", VO.so_sdate);
                cmd.Parameters.AddWithValue("@so_comment", VO.so_comment);

                cmd.Connection.Open();
                var successRow = cmd.ExecuteNonQuery();
                cmd.Connection.Close();
                return(successRow > 0);
            }
        }
示例#2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count == 0)
            {
                MessageBox.Show("변경할 영업마스터가 없습니다. 영업마스터를 먼저 선택하여 주십시오.", "영업마스터", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                SetBottomStatusLabel("변경할 영업마스터가 없습니다. 영업마스터를 먼저 선택하여 주십시오.");
            }
            else
            {
                SOMasterVO vo = new SOMasterVO();

                foreach (DataGridViewRow row in this.dataGridView1.SelectedRows)
                {
                    vo = row.DataBoundItem as SOMasterVO;
                }

                //수정버튼
                SODialog frm = new SODialog(SODialog.EditMode.Update, vo);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    btnSearch.PerformClick();
                    SetBottomStatusLabel("수정이 완료되었습니다.");
                }
            }
        }
示例#3
0
        //영업마스터 생성
        private void btnCreatePO_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count < 1)
            {
                MessageBox.Show("파일 업로드는 필수입니다.", "파일 업로드", MessageBoxButtons.OK, MessageBoxIcon.Information);
                SetBottomStatusLabel("파일 업로드는 필수입니다.");
            }
            else
            {
                if (MessageBox.Show("영업마스터를 생성하시겠습니까?", "영업마스터생성", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    try
                    {
                        List <SOMasterVO> list = new List <SOMasterVO>();

                        for (int i = 0; i < dataGridView1.Rows.Count; i++)
                        {
                            SOMasterVO vo = new SOMasterVO();
                            vo.plan_id      = versionName;
                            vo.so_wo_id     = dataGridView1.Rows[i].Cells[2].Value.ToString();
                            vo.so_pcount    = Convert.ToInt32(dataGridView1.Rows[i].Cells[7].Value);
                            vo.company_code = dataGridView1.Rows[i].Cells[3].Value.ToString();
                            vo.so_edate     = dataGridView1.Rows[i].Cells[8].Value.ToString();
                            vo.so_sdate     = dataGridView1.Rows[i].Cells[0].Value.ToString();
                            vo.product_name = dataGridView1.Rows[i].Cells[6].Value.ToString();
                            list.Add(vo);
                        }

                        //DB
                        OrderService service = new OrderService();
                        bool         result  = service.AddSOMaster(list);

                        if (result)
                        {
                            Form fc  = Application.OpenForms["Main"];
                            Main frm = (Main)fc;
                            frm.CloseandOpenTab("영업마스터");
                        }
                        else
                        {
                            MessageBox.Show("영업마스터 생성에 실패하였습니다. 다시 시도하여주십시오.", "영업마스터 생성 실패", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            SetBottomStatusLabel("영업마스터 생성에 실패하였습니다. 다시 시도하여주십시오.");
                            return;
                        }
                    }
                    catch (Exception err)
                    {
                        LoggingUtility.GetLoggingUtility(err.Message, Level.Error);
                    }
                }
                else
                {
                    return;
                }
            }
        }
示例#4
0
        public SODialog(EditMode edit, SOMasterVO vo = null)
        {
            InitializeComponent();

            if (edit == EditMode.Insert)
            {
                txtCancel.Enabled = false;
                this.edit         = EditMode.Insert;
            }
            else if (edit == EditMode.Update)
            {
                this.vo           = vo;
                this.edit         = EditMode.Update;
                txtSOWO.Enabled   = false;
                cbProduct.Enabled = false;
            }
        }
示例#5
0
        /// <summary>
        /// 영업마스터 수정
        /// </summary>
        /// <param name="VO"></param>
        /// <returns></returns>
        public bool UpdateOneSOMaster(SOMasterVO VO)
        {
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.Connection = new SqlConnection(this.ConnectionString);
                cmd.Connection.Open();
                SqlTransaction tran = cmd.Connection.BeginTransaction();

                try
                {
                    cmd.Transaction = tran;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "update TBL_SO_MASTER set company_code = @company_code, company_type = @company_type, product_name = @product_name, so_pcount = @so_pcount, so_ccount=@so_ccount, so_comment = @so_comment, so_udate = @so_udate, so_edate = @so_edate where so_id = @so_id";

                    cmd.Parameters.AddWithValue("@company_code", VO.company_code);
                    cmd.Parameters.AddWithValue("@company_type", VO.company_type);
                    cmd.Parameters.AddWithValue("@product_name", VO.product_codename);
                    cmd.Parameters.AddWithValue("@so_pcount", VO.so_pcount);
                    cmd.Parameters.AddWithValue("@so_ccount", VO.so_ccount);
                    cmd.Parameters.AddWithValue("@so_comment", VO.so_comment);
                    cmd.Parameters.AddWithValue("@so_udate", VO.so_udate);
                    cmd.Parameters.AddWithValue("@so_id", VO.so_id);
                    cmd.Parameters.AddWithValue("@so_edate", VO.so_edate);

                    cmd.ExecuteNonQuery();

                    cmd.CommandText = "update TBL_DEMAND_PLAN set d_date = @so_edate where so_id = @so_id";

                    cmd.ExecuteNonQuery();

                    tran.Commit();
                    cmd.Connection.Close();
                    return(true);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    tran.Rollback();
                    cmd.Connection.Close();
                    return(false);
                }
            }
        }
示例#6
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (edit == EditMode.Insert)
            {
                //영업마스터 추가
                string planID = DateTime.Now.ToShortDateString().Replace("-", "") + "_P";

                SOMasterVO vo = new SOMasterVO();
                vo.plan_id  = planID;
                vo.so_wo_id = txtSOWO.Text;

                List <CompanyVO> company = (from item in list
                                            where item.company_code == (string)cbCompany.SelectedValue
                                            select item).ToList();

                vo.company_code = (string)cbCompany.SelectedValue;
                vo.company_type = company[0].company_type;
                vo.product_name = (string)cbProduct.SelectedValue;
                vo.so_pcount    = Convert.ToInt32(txtOrder.Text);
                vo.so_edate     = dtpsDate.Value.ToShortDateString();
                vo.so_sdate     = DateTime.Now.ToShortDateString();
                vo.so_comment   = txtComment.Text;

                OrderService service = new OrderService();


                if (MessageBox.Show("등록하시겠습니까?", "S/O등록", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    try
                    {
                        bool result = service.AddOneSOMaster(vo);

                        if (result)
                        {
                            DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            MessageBox.Show("등록에 실패하였습니다.");
                        }
                    }
                    catch (Exception err)
                    {
                        LoggingUtility.GetLoggingUtility(err.Message, Level.Error);
                    }
                }
                else
                {
                    return;
                }
            }
            else if (edit == EditMode.Update)
            {
                vo.so_id = vo.so_id;

                List <CompanyVO> company = (from item in list
                                            where item.company_code == (string)cbCompany.SelectedValue
                                            select item).ToList();

                vo.company_code     = (string)cbCompany.SelectedValue;
                vo.company_type     = company[0].company_type;
                vo.product_codename = (string)cbProduct.SelectedValue;
                vo.so_pcount        = Convert.ToInt32(txtOrder.Text);
                vo.so_ccount        = Convert.ToInt32(txtCancel.Text);
                vo.so_edate         = dtpsDate.Value.ToShortDateString();
                vo.so_udate         = string.Format("{0:yyyy-MM-dd HH:mm:ss}", today);
                vo.so_comment       = txtComment.Text;
                vo.so_edate         = dtpsDate.Value.ToShortDateString();

                OrderService service = new OrderService();

                if (MessageBox.Show("수정하시겠습니까?", "S/O수정", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    try
                    {
                        bool result = service.UpdateOneSOMaster(vo);

                        if (result)
                        {
                            MessageBox.Show("수정이 완료되었습니다.");
                            DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            MessageBox.Show("수정에 실패하였습니다.");
                        }
                    }
                    catch (Exception err)
                    {
                        LoggingUtility.GetLoggingUtility(err.Message, Level.Error);
                    }
                }
            }
        }
示例#7
0
        public bool UpdateOneSOMaster(SOMasterVO VO)
        {
            OrderDac dac = new OrderDac();

            return(dac.UpdateOneSOMaster(VO));
        }
示例#8
0
        public bool AddOneSOMaster(SOMasterVO VO)
        {
            OrderDac dac = new OrderDac();

            return(dac.AddOneSOMaster(VO));
        }