Пример #1
0
    private void Loadchklist()
    {
        try
        {
            objSundriModel       = new SundriesModel();
            objSundriModel.OrgID = GlobalSession.OrgID;
            objSundriModel.YrCD  = GlobalSession.YrCD;

            string  uri       = string.Format(" Sundri/ChkList");
            DataSet dsChklist = CommonCls.ApiPostDataSet(uri, objSundriModel);
            if (dsChklist.Tables.Count > 0)
            {
                DataTable dtChkAviable   = dsChklist.Tables["AvailableList"];
                DataTable dtChkAllocated = dsChklist.Tables["AllocatedList"];

                ViewState["dtCheckListAvailable"] = dtChkAviable;
                chkAvailable.DataSource           = dtChkAviable;
                chkAvailable.DataTextField        = "AccName";
                chkAvailable.DataValueField       = "AccCode";
                chkAvailable.DataBind();

                ChkSelected.DataSource     = dtChkAllocated;
                ChkSelected.DataTextField  = "SundriHeadName";
                ChkSelected.DataValueField = "AccCode";
                ChkSelected.DataBind();
                if (dtChkAllocated.Columns.Count > 0)
                {
                    ViewState["CheckListViewSelect"] = dtChkAllocated;
                }
                else
                {
                }
                //chkAvailable.Items.Insert(0, new ListItem("-- Select --", "0"));
            }
        }
        catch (Exception ex)
        {
        }
    }
Пример #2
0
    protected void btnAdd_Click(object sender, EventArgs e)       //buttaon Add For The List
    {
        try
        {
            lblMsg.Text = lblMsg.CssClass = "";

            bool flag = false;
            foreach (ListItem item in chkAvailable.Items)
            {
                if (item.Selected)
                {
                    flag = true;
                    break;
                }
            }

            if (!flag)
            {
                ShowMessage("Please Check First In Available List!", false);
                return;
            }

            DataTable dtCheckList          = new DataTable();
            DataTable dtCheckListAvailable = new DataTable();
            if (ViewState["CheckListViewSelect"] == null)
            {
                dtCheckList.Columns.Add("SundriHeadName");
                dtCheckList.Columns.Add("AccCode");
            }
            else
            {
                //if (((DataTable)ViewState["CheckListViewSelect"]).Columns.Count==0)
                //{
                //    dtCheckList.Columns.Add("AccName");
                //    dtCheckList.Columns.Add("AccCode");
                //}
                dtCheckList = (DataTable)ViewState["CheckListViewSelect"];
            }
            int i = 0;
            dtCheckListAvailable = (DataTable)ViewState["dtCheckListAvailable"];
            foreach (ListItem item in chkAvailable.Items)
            {
                if (item.Selected)
                {
                    DataRow dr = dtCheckList.NewRow();
                    //dr["AccName"] = item.Text;
                    dr["SundriHeadName"] = item.Text;
                    dr["AccCode"]        = item.Value.ToString();
                    dtCheckList.Rows.Add(dr);

                    dtCheckListAvailable.Rows.RemoveAt(i);

                    ViewState["dtCheckListAvailable"] = dtCheckListAvailable;
                }
                else
                {
                    i++;
                }
            }
            ViewState["CheckListViewSelect"] = dtCheckList;
            ChkSelected.DataSource           = dtCheckList;
            ChkSelected.DataValueField       = "AccCode";
            ChkSelected.DataTextField        = "SundriHeadName";
            ChkSelected.DataBind();

            chkAvailable.DataSource     = dtCheckListAvailable;
            chkAvailable.DataTextField  = "AccName";
            chkAvailable.DataValueField = "AccCode";
            chkAvailable.DataBind();
        }
        catch (Exception ex)
        {
        }
    }
Пример #3
0
    protected void btnRemove_Click(object sender, EventArgs e) //button Remove For The List
    {
        try
        {
            lblMsg.Text = lblMsg.CssClass = "";

            DataTable dtCheckList          = new DataTable();
            DataTable dtCheckListAvailable = new DataTable();
            if (ViewState["CheckListViewSelect"] == null)
            {
                dtCheckList.Columns.Add("AccName");
                dtCheckList.Columns.Add("AccCode");
            }
            else
            {
                dtCheckList = (DataTable)ViewState["CheckListViewSelect"];
            }
            int i = 0;
            dtCheckListAvailable = (DataTable)ViewState["dtCheckListAvailable"];
            foreach (ListItem item in ChkSelected.Items)
            {
                if (item.Selected)
                {
                    if (MatchInd(item.Value.ToString()) == 0)
                    {
                        DataRow dr = dtCheckListAvailable.NewRow();

                        dr["AccName"] = item.Text;
                        dr["AccCode"] = item.Value.ToString();

                        dtCheckListAvailable.Rows.Add(dr);

                        dtCheckList.Rows.RemoveAt(i);

                        ViewState["dtCheckListAvailable"] = dtCheckListAvailable;
                        ShowMessage("Item Removed Successfully.", true);
                    }
                    else
                    {
                        i++;
                        ShowMessage("Item Not Removed Because Invoice Created Using That.", false);
                        break;
                    }
                }
                else
                {
                    i++;
                }
            }

            ViewState["CheckListViewSelect"] = dtCheckList;
            ChkSelected.DataSource           = dtCheckList;
            ChkSelected.DataValueField       = "AccCode";
            ChkSelected.DataTextField        = "SundriHeadName";
            ChkSelected.DataBind();

            chkAvailable.DataSource     = dtCheckListAvailable;
            chkAvailable.DataTextField  = "AccName";
            chkAvailable.DataValueField = "AccCode";
            chkAvailable.DataBind();
        }
        catch (Exception ex)
        {
        }
    }