コード例 #1
0
 private void LoadItemUnit()
 {
     try
     {
         List <ATTInvItemUnit> lstItemUnit = BLLInvItemUnit.GetItemList(null, "Y", true);
         Session["Item_ItemUnit"]            = lstItemUnit;
         this.DDLItemUnit_Rqd.DataSource     = lstItemUnit;
         this.DDLItemUnit_Rqd.DataTextField  = "ItemUnitName";
         this.DDLItemUnit_Rqd.DataValueField = "ItemUnitID";
         this.DDLItemUnit_Rqd.DataBind();
     }
     catch (Exception ex)
     {
         this.lblStatus.Text = ex.Message;
     }
 }
    private void LoadItems()
    {
        try
        {
            List <ATTInvItemUnit> lstItem = BLLInvItemUnit.GetItemList(null, null, false);
            Session["Item_ItemList"]        = lstItem;
            this.lstInvItems.DataSource     = lstItem;
            this.lstInvItems.DataTextField  = "ItemUnitName";
            this.lstInvItems.DataValueField = "ItemUnitID";

            this.lstInvItems.DataBind();
        }
        catch (Exception ex)
        {
            this.lblStatus.Text = ex.Message;
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strActive;

        strActive = chkActive.Checked ? "Y" : "N";
        ATTInvItemUnit itemObj = new ATTInvItemUnit
                                 (
            0,
            this.txtInvItem_Rqd.Text,
            strActive,
            this.User.UserName
                                 );

        ObjectValidation OV = BLLInvItemUnit.Validate(itemObj);

        if (OV.IsValid == false)
        {
            this.lblStatus.Text = OV.ErrorMessage;
            return;
        }

        List <ATTInvItemUnit> lstItem = (List <ATTInvItemUnit>)Session["Item_ItemList"];

        try
        {
            if (this.lstInvItems.SelectedIndex < 0)
            {
                itemObj.Action = "A";
            }
            else
            {
                itemObj.Action     = "E";
                itemObj.ItemUnitID = int.Parse(this.lstInvItems.SelectedValue);
            }

            BLLInvItemUnit.SaveItemUnit(itemObj);

            if (this.lstInvItems.SelectedIndex < 0)
            {
                lstItem.Add(itemObj);
            }
            else
            {
                lstItem[this.lstInvItems.SelectedIndex] = itemObj;
            }

            this.lblStatusMessage.Text = "Items successfully saved.";
            this.programmaticModalPopup.Show();

            this.lstInvItems.DataSource     = lstItem;
            this.lstInvItems.DataTextField  = "ItemUnitName";
            this.lstInvItems.DataValueField = "ItemUnitID";

            this.lstInvItems.DataBind();

            this.ClearInvItemUnitControl();
        }
        catch (Exception ex)
        {
            this.lblStatus.Text = ex.Message;
        }
    }