示例#1
0
        protected void gvKantorCabang_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            ActivityLog    log       = new ActivityLog();
            ActivityLogBll logBll    = new ActivityLogBll();
            string         host      = Request.UserHostName;
            string         ipaddress = Request.UserHostAddress;
            string         userName  = Session["user"].ToString();

            if (String.IsNullOrEmpty(ipaddress))
            {
                ipaddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            }
            log.HostName  = host;
            log.IPAddress = ipaddress;
            log.Action    = "Insert";
            log.UserName  = userName;

            try
            {
                Hashtable ht = new Hashtable();
                ht.Add("@branch_name-varchar-200", e.NewValues["branch_name"].ToString());
                ht.Add("@branch_details-varchar-560", e.NewValues["branch_details"].ToString());
                ht.Add("@head_of_branch-varchar-200", e.NewValues["head_of_branch"].ToString());
                ht.Add("@head_title-varchar-200", e.NewValues["head_title"].ToString());
                ht.Add("@branch_addr-varchar-560", e.NewValues["branch_addr"].ToString());
                //ht.Add("@province_code-int", e.NewValues["province_code"].ToString());
                ht.Add("@branch_code-varchar-10", e.NewValues["branch_code"].ToString());
                ht.Add("@created_by-varchar-99", Session["user"]);


                bll.InsertData(ht);
                log.Type        = "S";
                log.Description = log.Action + ' ' + "Sukses oleh id" + ' ' + userName;
                e.Cancel        = true;
                gvKantorCabang.CancelEdit();
                GetData();
            }
            catch (Exception ex)
            {
                log.Type        = "E";
                log.Description = "Insert Error : " + ex.Message;
            }
            finally
            {
                logBll.InsertActivity(log);
            }
        }