예제 #1
0
파일: StoreIn.cs 프로젝트: swankham/Epicoil
        private void tlbSave_Click(object sender, EventArgs e)
        {
            //bool IsSuccess;
            string msg;
            int StoreInid;
            int SelectedCount = 0;

            if (dataGridView1.Rows.Count == 0)
            {
                return;
            }

            if (!HashListSeleted())
            {
                MessageBox.Show("Please select rows in grid.", "Please try agian.", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            if (!HashArticleSelected(out SelectedCount))
            {
                MessageBox.Show("Please select rows in grid.", "Please try agian.", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            if (SelectedCount > 0)
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure to save store in. \rAfter your save, you can't modify it.", "Please Confirm.", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    int iRow = dataGridView1.CurrentRow.Index;
                    List<StoreInDetail> selectedList = new List<StoreInDetail>();

                    for (int i = 0; (this.dataGridView2.Rows.Count) > i; i++)
                    {
                        if ((bool)dataGridView2[0, i].EditedFormattedValue && string.IsNullOrEmpty(dataGridView2.Rows[i].Cells["stock"].Value.GetString()))
                        {
                            dataGridView2.CurrentCell = dataGridView2[0, i];

                            var item = new StoreInDetail();
                            item = _repo.GetArticleListToSave(Convert.ToInt32(dataGridView2.Rows[i].Cells["lineid"].Value));
                            item.Location = dataGridView2.Rows[i].Cells["Place"].Value.GetString();
                            item.NGStatus = Convert.ToInt32(dataGridView2.Rows[i].Cells["ngflag"].Value.GetBoolean());
                            item.NGRemark = dataGridView2.Rows[i].Cells["ngRemark"].Value.GetString();
                            HeadContent.PONum = item.PONum;
                            HeadContent.PONumber = item.PONumber;
                            selectedList.Add(item);
                        }
                    }

                    if (selectedList != null)
                    {
                        HeadContent.StoreInDate = DateTime.Now;
                        HeadContent = _repo.InsertStoreIn(HeadContent, epiSession);
                        _repo.InsertStoreInLine(selectedList, epiSession, HeadContent.StoreInID, HeadContent.TransactionID, out msg);
                    }
                    SetHeaderContent(HeadContent);
                    MessageBox.Show("Save Store In completed. And then will be create Part in Epicor.", "Progression.", MessageBoxButtons.OK);
                    Progression frm1 = new Progression("NEWPART", HeadContent.TransactionID, epiSession, HeadContent.Possession);
                    frm1.ShowDialog();

                    tlbSave.Enabled = false;
                    SetHeaderContent(HeadContent, true);
                    var result = _repo.GetDetailArticle(HeadContent.StoreInPlanId, HeadContent.TransactionID);
                    SetDetailArticle(result, true);
                }
            }
        }