コード例 #1
0
        /// <summary>
        /// Function to fill material receipt details 
        /// </summary>
        public void MaterialReceiptDetailsFill()
        {
            List<DataTable> ListObj = new List<DataTable>();
            List<DataTable> ListObjDetals = new List<DataTable>();
            MaterialReceiptBll bllMaterialReceiptMaster = new MaterialReceiptBll();
            MaterialReceiptBll bllMaterialReceiptDetails = new MaterialReceiptBll();
            decimal decMaterialReceiptMasterId = 0;
            try
            {
                if (!isEditFill)
                {
                    if (cmbCashOrParty.SelectedValue != null)
                    {
                        if (cmbCashOrParty.SelectedValue.ToString() != "System.Data.DataRowView" && cmbCashOrParty.Text != "System.Data.DataRowView")
                        {
                            GridComboFill();
                            decMaterialReceiptMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
                            ListObj = bllMaterialReceiptMaster.MaterialReceiptMasterViewByReceiptMasterId(decMaterialReceiptMasterId);
                            if (ListObj[0].Rows.Count > 0)
                            {
                                cmbCurrency.SelectedValue = ListObj[0].Rows[0].ItemArray[7];
                            }
                            ListObjDetals = bllMaterialReceiptDetails.MaterialReceiptDetailsViewByMaterialReceiptMasterIdWithRemainingByNotInCurrPI
                                    (decMaterialReceiptMasterId, decPurchaseMasterId, decPurchaseInvoiceVoucherTypeId);
                            if (ListObjDetals[0].Rows.Count > 0)
                            {
                                if (dgvProductDetails.DataSource == null)
                                {
                                    dgvProductDetails.Rows.Clear();
                                }
                                else
                                {
                                    ((DataTable)dgvProductDetails.DataSource).Rows.Clear();

                                }

                                int i = 0;
                                foreach (DataRow dr in ListObjDetals[0].Rows)
                                {
                                    dgvProductDetails.Rows.Add();
                                    dgvProductDetails.Rows[i].Cells["dgvtxtPurchaseDetailsId"].Value = dr["purchaseDetailsId"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = dr["purchaseOrderDetailsId"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvtxtMaterialReceiptDetailsId"].Value = dr["materialReceiptDetailsId"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvtxtProductId"].Value = dr["productId"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvtxtBarcode"].Value = dr["barcode"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvtxtProductCode"].Value = dr["productCode"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvtxtProductName"].Value = dr["productName"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvtxtQuantity"].Value = dr["qty"].ToString();
                                    UnitComboFill(Convert.ToDecimal(dr["productId"].ToString()), i, dgvProductDetails.Rows[i].Cells["dgvcmbUnit"].ColumnIndex);
                                    dgvProductDetails.Rows[i].Cells["dgvtxtUnitConversionId"].Value = dr["unitConversionId"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(dr["unitId"].ToString());
                                    dgvProductDetails.Rows[i].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(dr["godownId"].ToString()); ;
                                    dgvProductDetails.Rows[i].Cells["dgvcmbRack"].Value = Convert.ToDecimal(dr["rackId"].ToString()); ;
                                    BatchComboFill(Convert.ToDecimal(dr["productId"].ToString()), i, dgvProductDetails.Rows[i].Cells["dgvcmbBatch"].ColumnIndex);
                                    dgvProductDetails.Rows[i].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(dr["batchId"].ToString());
                                    dgvProductDetails.Rows[i].Cells["dgvtxtRate"].Value = dr["rate"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvtxtGrossValue"].Value = dr["grossValue"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvtxtDiscountPercent"].Value = dr["discountPercent"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvtxtDiscount"].Value = dr["discount"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvtxtNetValue"].Value = dr["netvalue"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvcmbTax"].Value = Convert.ToDecimal(dr["taxId"].ToString());
                                    dgvProductDetails.Rows[i].Cells["dgvtxtTaxAmount"].Value = dr["taxAmount"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvtxtAmount"].Value = dr["Amount"].ToString();
                                    dgvProductDetails.Rows[i].Cells["dgvcmbUnit"].ReadOnly = true;
                                    i++;
                                }
                                dgvProductDetails.AllowUserToAddRows = false;
                            }
                            else
                            {
                                if (dgvProductDetails.DataSource == null)
                                {
                                    dgvProductDetails.Rows.Clear();
                                }
                                else
                                {
                                    ((DataTable)dgvProductDetails.DataSource).Rows.Clear();
                                }
                            }
                            SerialNo();
                            GridviewReadOnlySettings("Against MaterialReceipt");
                        }

                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PI20:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }