Exemplo n.º 1
0
        private void FindJewel(FindJewelBy findParam)
        {
            foreach (DataGridViewRow dgvr in dgvJewel.Rows)
            {
                var findCode = "";
                var code     = "";
                if (findParam == FindJewelBy.JewelNo)
                {
                    findCode = dgvr.Cells["JewelNo"].Value.ToString();
                    code     = txtBarCode.Text;
                }
                else if (findParam == FindJewelBy.StyleNo)
                {
                    findCode = dgvr.Cells["StyleNo"].Value.ToString();
                    code     = txtStyleNo.Text;
                }
                if (String.Compare(findCode, code, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    MessageBox.Show(findParam + Resources.frmBarCodeOrder_FindJewel__already_exists_Please_search_for_new_record_, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtBarCode.Text = String.Empty;
                    txtStyleNo.Text = String.Empty;
                    return;
                }
            }
            JewelMaster JewelData = null;

            if (findParam == FindJewelBy.JewelNo)
            {
                JewelData = _jewelService.GetJewelsByJewelNo(txtBarCode.Text);
            }
            else if (findParam == FindJewelBy.StyleNo)
            {
                JewelData = _jewelService.GetJewelsByStyleNo(txtStyleNo.Text);
            }

            if (JewelData == null)
            {
                MessageBox.Show(Resources.frmBarCodeOrder_FindJewel_Records_Not_found__);
                txtBarCode.Text = String.Empty;
                txtStyleNo.Text = String.Empty;
                return;
            }

            int _newRow = dgvJewel.RowCount;

            dgvJewel.Rows.Add(1);
            dgvJewel.Rows[_newRow].Cells[0].Value  = true;
            dgvJewel.Rows[_newRow].Height          = 100;
            dgvJewel.Rows[_newRow].Cells[2].Value  = JewelData.JewelNo;
            dgvJewel.Rows[_newRow].Cells[3].Value  = JewelData.StyleNo;
            dgvJewel.Rows[_newRow].Cells[4].Value  = JewelData.JewelDescription;
            dgvJewel.Rows[_newRow].Cells[5].Value  = JewelData.MetalColor;
            dgvJewel.Rows[_newRow].Cells[6].Value  = ImageExtension.GetImageName(JewelData.StyleNo);
            dgvJewel.Rows[_newRow].Cells[7].Value  = JewelData.DiamondPcs;
            dgvJewel.Rows[_newRow].Cells[8].Value  = JewelData.DiamondWt;
            dgvJewel.Rows[_newRow].Cells[9].Value  = JewelData.GrsWt;
            dgvJewel.Rows[_newRow].Cells[10].Value = JewelData.NetWt;
            dgvJewel[1, _newRow].Value             = ImageExtension.ResolveImage(JewelData.StyleNo);

            dgvJewel.FirstDisplayedScrollingRowIndex = dgvJewel.RowCount - 1;

            CatalogueRequest.Add(new QueryRequest
            {
                JewelNo = JewelData.JewelNo,
                StyleNo = JewelData.StyleNo,
            });

            GetTotal();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (base.IsValid == false)
            {
                MessageBox.Show(AllErrors.ErrorMessageString(), Constants.ALERTMESSAGEHEADER);
                return;
            }

            if (HasImage == false)
            {
                MessageBox.Show(Resources.frmJewelMaster_btnSave_Click_Please_select_file_to_upload_, Constants.ALERTMESSAGEHEADER);
                return;
            }

            var jewelMaster = new JewelMaster();

            if (false == string.IsNullOrEmpty(txtJewelNo.Text))
            {
                jewelMaster = _jewelService.GetJewelsByJewelNo(txtJewelNo.Text);
            }

            decimal dimWt;

            if (!Decimal.TryParse(txtDiamondWt.Text, out dimWt))
            {
                MessageBox.Show(Resources.frmJewelMaster_btnSave_Click_Please_select_proper_dia_Wt_, Constants.ALERTMESSAGEHEADER);
                return;
            }

            decimal netWt;

            if (!Decimal.TryParse(txtNetWt.Text, out netWt))
            {
                MessageBox.Show(Resources.frmJewelMaster_btnSave_Click_Please_select_proper_net_Wt_, Constants.ALERTMESSAGEHEADER);
                return;
            }

            decimal grsWt;

            if (!Decimal.TryParse(txtGrsWt.Text, out grsWt))
            {
                MessageBox.Show(Resources.frmJewelMaster_btnSave_Click_Please_select_proper_grs_Wt_, Constants.ALERTMESSAGEHEADER);
                return;
            }

            jewelMaster.StyleNo          = txtStyleNo.Text;
            jewelMaster.JewelDescription = cboJewelDesc.Text;
            jewelMaster.MetalColor       = cboMetalColor.Text;
            jewelMaster.DiamondPcs       = Convert.ToInt32(txtDiamondPcs.Text);
            jewelMaster.DiamondWt        = dimWt;
            jewelMaster.GrsWt            = grsWt;
            jewelMaster.NetWt            = netWt;
            jewelMaster.AccessedBy       = 0;
            jewelMaster.AccessedDate     = DateTime.Now;

            var filePath = Path.Combine(_winSettingProvider.ImageDirectory, ImageExtension.GetImageName(txtStyleNo.Text));

            if (File.Exists(fileDialog.FileName))
            {
                File.Copy(fileDialog.FileName, filePath, true);
            }

            var jewelRequest = new JewelMasterRequest()
            {
                JewelMaster = jewelMaster
            };

            var jewelMasterResponse = _jewelService.CreateJewelMaster(jewelRequest);

            if (false == jewelMasterResponse.IsValid)
            {
                MessageBox.Show(jewelMasterResponse.AllErrors.ErrorMessageString(), Constants.ALERTMESSAGEHEADER);
                return;
            }

            groupBox.Enabled        = btnSave.Enabled = false;
            btnPrintSticker.Enabled = true;

            GenerateBarcodeTag(jewelMaster);

            MessageBox.Show("Record saved!");
        }