コード例 #1
0
        // not handling OBJECT ID at the moment as i don't know how you will impliment it
        protected void frmApprovalStatusMasters_ItemInserting(object sender, FormViewInsertEventArgs e)
        {
            // get the textbox value and use it to create a new record in Project
            TextBox txtStatus     = (TextBox)frmApprovalStatusMasters.FindControl("txtStatus");
            TextBox txtObjectType = (TextBox)frmApprovalStatusMasters.FindControl("txtObjectType");
            TextBox txtHierarchy  = (TextBox)frmApprovalStatusMasters.FindControl("txtHierarchy");

            using (Models.TLGX_MAPPEREntities1 myEntity = new Models.TLGX_MAPPEREntities1())
            {
                Models.m_Approval_StatusMaster myApprovalStatusMaster = new Models.m_Approval_StatusMaster()
                {
                    Appr_status_id   = Guid.NewGuid(),
                    Status           = txtStatus.Text.Trim(),
                    Object_type      = txtObjectType.Text.Trim(),
                    Object_id        = Guid.Empty,                          // dummying in a GUID
                    Status_hierarchy = int.Parse(txtHierarchy.Text.Trim()), // you'll need to add validation on this bit
                    CREATE_DATE      = DateTime.Now,
                    CREATE_USER      = System.Web.HttpContext.Current.User.Identity.Name
                };

                myEntity.m_Approval_StatusMaster.Add(myApprovalStatusMaster);
                myEntity.SaveChanges();

                // refresh page however you like, but you'll need to set focus to the Appproval Role Master tab
            }
        }
コード例 #2
0
        public bool SetApprovalStatusMasterData(List <Approval_Status_Master_Contract_Record> statusmaster)
        {
            bool ret = false;

            try
            {
                using (TLGX_MAPPEREntities1 context = new TLGX_MAPPEREntities1())
                {
                    foreach (Approval_Status_Master_Contract_Record statusrec in statusmaster)
                    {
                        Models.m_Approval_StatusMaster nStatRec = context.m_Approval_StatusMaster.Single(u => u.Appr_status_id == statusrec.Appr_status_id);
                        if (nStatRec == null)
                        {
                            nStatRec = new Models.m_Approval_StatusMaster
                            {
                                Appr_status_id   = Guid.NewGuid(),
                                Object_id        = statusrec.Object_id,
                                Object_type      = statusrec.Object_type,
                                Status           = statusrec.Status,
                                Status_hierarchy = statusrec.Status_hierarchy
                            };
                            context.m_Approval_StatusMaster.Add(nStatRec);
                        }
                        else
                        {
                            nStatRec.Object_id        = statusrec.Object_id;
                            nStatRec.Object_type      = statusrec.Object_type;
                            nStatRec.Status           = statusrec.Status;
                            nStatRec.Status_hierarchy = statusrec.Status_hierarchy;
                        }
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(ret);
        }