Ejemplo n.º 1
0
        private void FillAssetsDetails()
        {
            objFixedAssetDB = new FixedAssetsDB();
            DataTable dt = new DataTable();

            if (txtAssetSLNo.Text != "")
            {
                try
                {
                    dt = objFixedAssetDB.GetFixedAssetsData(txtAssetSLNo.Text.ToString()).Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        flagUpdate = true;

                        //txtAssetTagNo.ReadOnly = true;
                        //txtAssetCost.ReadOnly = true;

                        //dtpGivenDate.Enabled = false;
                        cbToComp.Enabled   = false;
                        cbToBranch.Enabled = false;
                        //txtEcode.ReadOnly = true;

                        txtAssetSLNo.Tag = dt.Rows[0]["AssetId"].ToString();

                        cbAssetType.SelectedValue  = dt.Rows[0]["Asset_Type"].ToString();
                        cbAssetMake.SelectedValue  = dt.Rows[0]["Asset_Make"].ToString();
                        cbAssetModel.SelectedValue = dt.Rows[0]["Asset_Model"].ToString();

                        dtpGivenDate.Value    = Convert.ToDateTime(dt.Rows[0]["Given_Date"].ToString());
                        cbStatus.SelectedItem = dt.Rows[0]["Status"].ToString();

                        txtAssetTagNo.Text = dt.Rows[0]["TagNo"].ToString();
                        txtAssetCost.Text  = dt.Rows[0]["AssetCost"].ToString();
                        AssetMovementId    = Convert.ToInt32(dt.Rows[0]["Movement_Id"].ToString());

                        TrnNo = Convert.ToInt32(dt.Rows[0]["Trn_No"].ToString());
                        if (dt.Rows[0]["Trn_Type"].ToString().Equals("BR2GC"))
                        {
                            cbTrnType.Text = "BR2EMPLOYEE";
                        }
                        else
                        {
                            cbTrnType.Text = dt.Rows[0]["Trn_Type"].ToString();
                        }

                        cbToComp.SelectedValue   = dt.Rows[0]["AtComp"].ToString();
                        cbToBranch.SelectedValue = dt.Rows[0]["AtBranch"].ToString();
                        txtDept.Text             = dt.Rows[0]["DeptName"].ToString();
                        txtDesig.Text            = dt.Rows[0]["DesigName"].ToString();
                        txtContactNo.Text        = dt.Rows[0]["ContNo"].ToString();


                        string ToEcode = dt.Rows[0]["To_Ecode"].ToString();
                        txtEcode.Text = ToEcode;
                        txtEcode_KeyUp(null, null);

                        if (txtContactNo.Text.Length == 0)
                        {
                            txtContactNo.Text = dt.Rows[0]["ContNo"].ToString();
                        }
                    }
                    else if (dt.Rows.Count == 0)
                    {
                        GenerateAssetSLNo();

                        flagUpdate   = false;
                        isDetlUpdate = false;

                        TrnNo              = 0;
                        AssetMovementId    = 0;
                        dtpGivenDate.Value = DateTime.Today;

                        cbToComp.SelectedIndex = 0;

                        cbToBranch.SelectedIndex = -1;
                        txtEcode.Text            = "";
                        txtEName.Text            = "";

                        cbAssetType.SelectedIndex  = 0;
                        cbAssetModel.SelectedIndex = -1;
                        cbAssetMake.SelectedIndex  = -1;


                        cbStatus.SelectedIndex = 0;
                        txtDesig.Text          = "";
                        txtDept.Text           = "";
                        dtpGivenDate.Enabled   = true;

                        cbToComp.Enabled       = true;
                        cbToBranch.Enabled     = true;
                        txtEcode.ReadOnly      = false;
                        txtAssetTagNo.ReadOnly = false;
                        txtAssetCost.ReadOnly  = false;

                        txtAssetTagNo.Text      = "";
                        txtAssetCost.Text       = "";
                        cbTrnType.SelectedIndex = 0;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    objFixedAssetDB = null;
                    dt = null;
                }
            }
        }
Ejemplo n.º 2
0
        private void FillAssetsDetails()
        {
            objAssetDB = new FixedAssetsDB();
            DataTable dt = new DataTable();

            if (txtAssetSLNo.Text != "")
            {
                try
                {
                    dt = objAssetDB.GetFixedAssetsData(txtAssetSLNo.Text.ToString()).Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        isHeadUpdate = true;

                        cbAssetType.Enabled     = false;
                        cbAssetMake.Enabled     = false;
                        cbAssetModel.Enabled    = false;
                        cbSupplier.Enabled      = false;
                        dtpPurchaseDate.Enabled = false;
                        txtAssetTagNo.ReadOnly  = true;
                        txtAssetCost.ReadOnly   = true;

                        dtpGivenDate.Enabled = false;
                        cbToComp.Enabled     = false;
                        cbToBranch.Enabled   = false;
                        txtToEcode.ReadOnly  = true;
                        cbTrnType.Enabled    = false;

                        txtAssetSLNo.Tag           = dt.Rows[0]["AssetId"].ToString();
                        cbAssetType.SelectedValue  = dt.Rows[0]["Asset_Type"].ToString();
                        cbAssetMake.SelectedValue  = dt.Rows[0]["Asset_Make"].ToString();
                        cbAssetModel.SelectedValue = dt.Rows[0]["Asset_Model"].ToString();
                        cbSupplier.SelectedValue   = dt.Rows[0]["Supplier_Id"].ToString();

                        if (dt.Rows[0]["Purchase_Date"].ToString().Length > 0)
                        {
                            dtpPurchaseDate.Value = Convert.ToDateTime(dt.Rows[0]["Purchase_Date"]);
                        }
                        dtpGivenDate.Value    = Convert.ToDateTime(dt.Rows[0]["Given_Date"].ToString());
                        cbStatus.SelectedItem = dt.Rows[0]["Status"].ToString();
                        AssetMovementId       = Convert.ToInt32(dt.Rows[0]["Movement_Id"].ToString());
                        txtAssetTagNo.Text    = dt.Rows[0]["TagNo"].ToString();
                        txtAssetCost.Text     = dt.Rows[0]["AssetCost"].ToString();

                        TrnNo = Convert.ToInt32(dt.Rows[0]["Trn_No"].ToString());
                        if (dt.Rows[0]["Trn_Type"].ToString().Equals("BR2GC"))
                        {
                            cbTrnType.Text = "BR2EMPLOYEE";
                        }
                        else
                        {
                            cbTrnType.Text = dt.Rows[0]["Trn_Type"].ToString();
                        }
                        cbToComp.Text            = dt.Rows[0]["To_Comp_Name"].ToString();
                        cbToBranch.SelectedValue = dt.Rows[0]["To_Branch"].ToString();

                        string ToEcode = dt.Rows[0]["To_Ecode"].ToString();
                        if (ToEcode.Length > 3)
                        {
                            txtToEcode.Text = ToEcode;
                        }
                    }
                    else if (dt.Rows.Count == 0)
                    {
                        isHeadUpdate = false;
                        isDetlUpdate = false;
                        //cbAssetType.SelectedIndex = 0;
                        GenerateAssetSLNo();
                        //cbAssetMake.SelectedIndex = -1;
                        //cbAssetModel.SelectedIndex = -1;
                        cbSupplier.SelectedIndex = 0;
                        dtpPurchaseDate.Value    = DateTime.Today;
                        dtpGivenDate.Value       = DateTime.Today;
                        cbTrnType.SelectedIndex  = 0;
                        cbToComp.SelectedIndex   = 0;

                        cbToBranch.SelectedIndex = -1;
                        txtToEcode.Text          = "";
                        txtToEName.Text          = "";
                        dtConfigDetl.Rows.Clear();
                        gvAssetConfigDetails.Rows.Clear();
                        cbStatus.SelectedIndex = 0;

                        cbAssetType.Enabled     = true;
                        cbAssetMake.Enabled     = true;
                        cbAssetModel.Enabled    = true;
                        cbSupplier.Enabled      = true;
                        dtpPurchaseDate.Enabled = true;
                        cbTrnType.Enabled       = true;

                        dtpGivenDate.Enabled = true;

                        cbToComp.Enabled       = true;
                        cbToBranch.Enabled     = true;
                        txtToEcode.ReadOnly    = false;
                        txtAssetTagNo.ReadOnly = false;
                        txtAssetCost.ReadOnly  = false;

                        txtAssetTagNo.Text = "";
                        txtAssetCost.Text  = "";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    objAssetDB = null;
                    dt         = null;
                }
            }
        }