Exemplo n.º 1
0
 public static bool SaveRelationType(ATTRelationType obj)
 {
     try
     {
         return(DLLRelationType.SaveRelationType(obj));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        int    relationID   = 0;
        string relationName = this.txtRelationType_Rqd.Text.Trim();
        List <ATTRelationType> RelationTypeList = (List <ATTRelationType>)Session["RelationTypeList"];
        ATTRelationType        RelationType     = new ATTRelationType(relationID, relationName);

        if (this.lstRelationTypes.SelectedIndex > -1)
        {
            RelationType.RelationTypeID = RelationTypeList[this.lstRelationTypes.SelectedIndex].RelationTypeID;
            RelationType.Action         = "E";
        }
        else
        {
            RelationType.Action = "A";
        }
        if (this.txtCardinality.Text.Trim() != "")
        {
            RelationType.RelationTypeCardinality = int.Parse(this.txtCardinality.Text.Trim());
        }

        try
        {
            BLLRelationType.SaveRelationType(RelationType);
            if (this.lstRelationTypes.SelectedIndex > -1)
            {
                RelationTypeList[this.lstRelationTypes.SelectedIndex] = RelationType;
            }
            else
            {
                RelationTypeList.Add(RelationType);
            }

            this.lstRelationTypes.DataSource = RelationTypeList;
            this.lstRelationTypes.DataBind();
            this.txtRelationType_Rqd.Text       = "";
            this.lstRelationTypes.SelectedIndex = -1;
            this.lblStatusMessage.Text          = "Successfully Saved.";
            this.programmaticModalPopup.Show();
        }
        catch (Exception ex)
        {
            this.lblStatusMessage.Text = ex.Message;
            this.programmaticModalPopup.Show();
        }
    }
        public static bool SaveRelationType(ATTRelationType obj)
        {
            string SP = "";

            if (obj.Action == "A")
            {
                SP = "SP_ADD_RELATION_TYPES";
            }
            else if (obj.Action == "E")
            {
                SP = "SP_EDIT_RELATION_TYPES";
            }

            List <OracleParameter> paramArray = new List <OracleParameter>();

            GetConnection     getConn = new GetConnection();
            OracleTransaction Tran    = getConn.GetDbConn().BeginTransaction();

            paramArray.Add(Utilities.GetOraParam(":RELATION_TYPE_ID", obj.RelationTypeID, OracleDbType.Int64, ParameterDirection.InputOutput));
            paramArray.Add(Utilities.GetOraParam(":RELATION_TYPE_NAME", obj.RelationTypeName, OracleDbType.Varchar2, ParameterDirection.Input));
            paramArray.Add(Utilities.GetOraParam(":RELATION_TYPE_CARDINALITY", obj.RelationTypeCardinality, OracleDbType.Int64, ParameterDirection.Input));

            try
            {
                SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, SP, paramArray.ToArray());

                int relationTypeID = int.Parse(paramArray[0].Value.ToString());
                obj.RelationTypeID = relationTypeID;
                Tran.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                Tran.Rollback();
                throw ex;
            }
            finally
            {
                getConn.CloseDbConn();
            }
        }
Exemplo n.º 4
0
        public static List <ATTRelationType> GetRelationTypes(int?relationTypeID, int FlagForDefault)
        {
            List <ATTRelationType> lstRelationTypes = new List <ATTRelationType>();

            foreach (DataRow row in DLLRelationType.GetRelationType(relationTypeID).Rows)
            {
                ATTRelationType obj = new ATTRelationType(int.Parse(row["RELATION_TYPE_ID"].ToString()),
                                                          ((row["RELATION_TYPE_NAME"] == System.DBNull.Value) ? "" : (string)row["RELATION_TYPE_NAME"]));
                int?relationTypeCardinality = null;
                if (row["RELATION_TYPE_CARDINALITY"] != System.DBNull.Value)
                {
                    relationTypeCardinality = int.Parse(row["RELATION_TYPE_CARDINALITY"].ToString());
                }
                obj.RelationTypeCardinality = relationTypeCardinality;
                lstRelationTypes.Add(obj);
            }
            if (FlagForDefault == 0)
            {
                lstRelationTypes.Insert(0, new ATTRelationType(0, "छान्नुहोस"));
            }

            return(lstRelationTypes);
        }
Exemplo n.º 5
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (this.txtRelationType_Rqd.Text == "")
        {
            this.lblStatusMessage.Text = "**र्कपया सम्बन्धको प्रकार भर्नुहोस्";
            this.programmaticModalPopup.Show();
            this.txtRelationType_Rqd.Focus();
            return;
        }
        int    relationID   = 0;
        string relationName = this.txtRelationType_Rqd.Text.Trim();
        List <ATTRelationType> RelationTypeList = (List <ATTRelationType>)Session["RelationTypeList"];
        ATTRelationType        RelationType     = new ATTRelationType(relationID, relationName);

        if (this.lstRelationTypes.SelectedIndex > -1)
        {
            RelationType.RelationTypeID = RelationTypeList[this.lstRelationTypes.SelectedIndex].RelationTypeID;
            RelationType.Action         = "E";
        }
        else
        {
            RelationType.Action = "A";
        }
        if (this.txtCardinality.Text.Trim() != "")
        {
            RelationType.RelationTypeCardinality = int.Parse(this.txtCardinality.Text.Trim());
        }
        bool exists = RelationTypeList.Exists(delegate(ATTRelationType obj)
        {
            return(obj.RelationTypeName == RelationType.RelationTypeName);
        }
                                              );

        if (exists)
        {
            this.lblStatusMessage.Text = "**सोहि नामको सम्बन्धको प्रकार पहिले नै उपलब्द छ";
            this.programmaticModalPopup.Show();
            this.txtRelationType_Rqd.Text       = "";
            this.txtCardinality.Text            = "";
            this.lstRelationTypes.SelectedIndex = -1;
            return;

            this.txtRelationType_Rqd.Focus();
        }
        try
        {
            BLLRelationType.SaveRelationType(RelationType);
            if (this.lstRelationTypes.SelectedIndex > -1)
            {
                RelationTypeList[this.lstRelationTypes.SelectedIndex] = RelationType;
            }
            else
            {
                RelationTypeList.Add(RelationType);
            }

            if (lstRelationTypes.SelectedIndex == -1)
            {
                this.lblStatusMessage.Text = "Relation Type Saved Successfully .";
                this.programmaticModalPopup.Show();
            }
            else
            {
                this.lblStatusMessage.Text = "Relation Type Updated Successfully .";
                this.programmaticModalPopup.Show();
            }
            this.lstRelationTypes.DataSource = RelationTypeList;
            this.lstRelationTypes.DataBind();
            this.txtRelationType_Rqd.Text       = "";
            this.txtCardinality.Text            = "";
            this.lstRelationTypes.SelectedIndex = -1;
            this.txtRelationType_Rqd.Focus();
        }
        catch (Exception ex)
        {
            this.lblStatusMessage.Text = ex.Message;
            this.programmaticModalPopup.Show();
        }
    }