Exemple #1
0
        protected void btnsave_Click(object sender, EventArgs e)
        {
            try
            {
                EventLogger log  = new EventLogger(config);
                BALItem     lcls = new BALItem();
                if (ItemID.Value != null && ItemID.Value != "")
                {
                    lcls.ItemID = Convert.ToInt64(ItemID.Value);
                }
                //txtitemid.Text = Convert.ToString(lcls.ItemID);
                //lcls.ItemShortName = txtitemid.Text;
                lcls.ItemDescription = txtItemDesc.Text;
                lcls.CategoryID      = Convert.ToInt64(drdItemCategory.SelectedValue);
                lcls.QtyPack         = Convert.ToInt64(txtQty.Text);
                lcls.NDC             = txtNDC.Text;
                decimal E = 0;
                E = Convert.ToDecimal(txtunitvalue.Text) / Convert.ToInt64(txtQty.Text);
                lcls.EachPrice         = Convert.ToDecimal(E.ToString());
                lcls.UnitPriceCurrency = Convert.ToString(drdUnitpriceType.SelectedValue);
                lcls.UnitPriceValue    = Convert.ToDecimal(txtunitvalue.Text);
                lcls.UOM           = Convert.ToInt64(ddlUOM.SelectedValue);
                lcls.GPBillingCode = txtgpbill.Text;
                //if (chkstan.Checked == true)
                //{
                //    lcls.Standard = true;
                //}
                //else
                //{
                //    lcls.Standard = false;
                //}
                //if (chknonstan.Checked == true)
                //{
                //    lcls.NonStandard = true;
                //}
                //else
                //{
                //    lcls.NonStandard = false;
                //}
                lcls.CreatedBy      = defaultPage.UserId;
                lcls.CreatedOn      = DateTime.Now;
                lcls.LastModifiedBy = defaultPage.UserId;
                lcls.LastModifiedOn = DateTime.Now;
                if (!ValidateLoookups(lclsservice))
                {
                    return;
                }
                bool isdescvalid = false;
                bool idgpcdoe    = false;
                if (chkactive.Checked == true)
                {
                    lcls.IsActive = true;
                }
                else
                {
                    lcls.IsActive = false;
                }
                List <GetItemDescName_Result> lstitemdesc = lclsservice.GetItemDescName(txtItemDesc.Text).ToList();
                if (lstitemdesc.Count <= 0 || txtItemDesc.Text == "")
                {
                    isdescvalid = true;
                }
                else if (lstitemdesc[0].ItemID == Convert.ToInt64(lcls.ItemID))
                {
                    isdescvalid = true;
                }
                List <Validgpbillcode_Result> lstMaster = lclsservice.Validgpbillcode(txtgpbill.Text).ToList();
                if (lstMaster.Count <= 0 || txtgpbill.Text == "")
                {
                    idgpcdoe = true;
                }
                else if (lstMaster[0].ItemID == Convert.ToInt64(lcls.ItemID))
                {
                    idgpcdoe = true;
                }

                if (isdescvalid == true && idgpcdoe == true)
                {
                    string lstrMessage = lclsservice.InsertUpdateItem(lcls);
                    string msg         = Constant.MedicalSuppliesSaveMessage.Replace("ShowPopup('", "").Replace("<<Itemname>>", txtItemDesc.Text).Replace("');", "");
                    log.LogInformation(msg);
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", Constant.MedicalSuppliesSaveMessage.Replace("<<Itemname>>", txtItemDesc.Text), true);
                    BindItem();
                    txtSearchItem.Text = "";
                    Clear();
                }
                else
                {
                    if (isdescvalid == false)
                    {
                        string msg = Constant.MedicalSuppliesvailddescMessage.Replace("ShowwarningLookupPopup('", "").Replace("<<Itemname>>", txtItemDesc.Text).Replace("');", "");
                        log.LogWarning(msg);
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", Constant.MedicalSuppliesvailddescMessage.Replace("<<Itemname>>", txtItemDesc.Text), true);
                    }
                    else
                    {
                        string msg = Constant.MedicalSuppliesvaildgpMessage.Replace("ShowwarningLookupPopup('", "").Replace("<<Itemname>>", txtgpbill.Text).Replace("');", "");
                        log.LogWarning(msg);
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", Constant.MedicalSuppliesvaildgpMessage.Replace("<<Itemname>>", txtgpbill.Text), true);
                    }
                }
            }
            catch (Exception ex)
            {
                EventLogger log = new EventLogger(config);
                log.LogException(ex);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", Constant.MedicalSuppliesErrorMessage.Replace("<<Itemname>>", ex.Message), true);
            }
        }