public void GetFreeOfferProducts(int iOfficeNo) { if (cbBranch.SelectedValue != null) { oServiceDB = new ServiceDB(); DataSet ds = oServiceDB.GetFreeOfferProducts(cbCompany.SelectedValue.ToString(), cbBranch.SelectedValue.ToString(), CommonData.FinancialYear, iOfficeNo); if (ds.Tables[0].Rows.Count > 0) { lblOfferID.Text = "1"; btnDelete.Enabled = true; txtOfferNo.Text = ds.Tables[0].Rows[0]["FPM_OFFER_NUMBER"].ToString(); txtDescription.Text = ds.Tables[0].Rows[0]["FPM_OFFER_DESCRIPTION"].ToString(); string status = ds.Tables[0].Rows[0]["FPM_OFFER_STATUS"].ToString(); if (status.ToUpper() == "RUNNING") { chkActive.Checked = true; } else { chkActive.Checked = false; } dtFromdate.Value = ds.Tables[0].Rows[0]["FPM_OFFER_VALID_FROM"].ToString() == "" ? Convert.ToDateTime(CommonData.CurrentDate) : Convert.ToDateTime(ds.Tables[0].Rows[0]["FPM_OFFER_VALID_FROM"]); txtToDate.Text = ds.Tables[0].Rows[0]["FPM_OFFER_VALID_TO"].ToString() == "" ? Convert.ToDateTime(CommonData.CurrentDate).ToString("dd/MM/yyyy") : Convert.ToDateTime(ds.Tables[0].Rows[0]["FPM_OFFER_VALID_TO"]).ToString(); if (ds.Tables[0].Rows[0]["FPM_OFFER_STATUS"].ToString() == "RUNNING") { chkActive.Checked = true; } else { chkActive.Checked = false; } } else { btnDelete.Enabled = false; chkActive.Checked = true; lblOfferID.Text = "0"; } if (ds.Tables[1].Rows.Count > 0) { cmbProducts.SelectedValue = ds.Tables[1].Rows[0]["ProductID"].ToString(); txtQty.Text = ds.Tables[1].Rows[0]["FPMS_SOLD_UNITS"].ToString(); txtMinQty.Text = ds.Tables[1].Rows[0]["MinUnits"].ToString(); txtMaxQty.Text = ds.Tables[1].Rows[0]["MaxUnits"].ToString(); } else { cmbProducts.SelectedIndex = 0; txtQty.Text = ""; txtMinQty.Text = ""; txtMaxQty.Text = ""; } if (ds.Tables[2].Rows.Count > 0) { dtFreeProducts(ds.Tables[2]); } } }