Esempio n. 1
0
    public string InsertCustomsType(ClsCustomsType data)
    {
        string errMsg = "";
        PuroTouchSQLDataContext puroTouchContext = new PuroTouchSQLDataContext();

        try
        {
            tblCustomsType oNewRow = new tblCustomsType()
            {
                CustomsType = data.CustomsType,
                CreatedBy   = data.CreatedBy,
                CreatedOn   = (DateTime?)data.CreatedOn,
                //UpdatedBy = data.UpdatedBy,
                //UpdatedOn = (DateTime?)data.UpdatedOn,
                ActiveFlag = data.ActiveFlag
            };



            puroTouchContext.GetTable <tblCustomsType>().InsertOnSubmit(oNewRow);
            // Submit the changes to the database.
            puroTouchContext.SubmitChanges();
        }
        catch (Exception ex)
        {
            errMsg = ex.Message.ToString();
        }
        return(errMsg);
    }
Esempio n. 2
0
    private ClsCustomsType populateObj(UserControl userControl)
    {
        ClsCustomsType oCType = new ClsCustomsType();

        oCType.idCustomsType = Convert.ToInt16((userControl.FindControl("lblCustomsTypeID") as Label).Text);

        oCType.CustomsType = (userControl.FindControl("txtCustomsType") as RadTextBox).Text;

        oCType.ActiveFlag = (userControl.FindControl("ActiveFlag") as RadButton).Checked;


        oCType.UpdatedBy = (string)(Session["userName"]);
        oCType.UpdatedOn = Convert.ToDateTime(DateTime.Now);
        return(oCType);
    }
Esempio n. 3
0
 protected void rgCustoms_UpdateCommand(object sender, GridCommandEventArgs e)
 {
     try
     {
         UserControl    userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
         Label          errorMsg    = (Label)userControl.FindControl("lblErrorMessage");
         ClsCustomsType oCType      = populateObj(userControl);
         oCType.idCustomsType = Convert.ToInt16((userControl.FindControl("lblCustomsTypeID") as Label).Text);
         string updateMsg = "";
         if (IsValid)
         {
             if (oCType != null)
             {
                 updateMsg = ct.UpdateCustomsType(oCType);
                 if (updateMsg == "")
                 {
                     pnlsuccess.Visible = true;
                     lblSuccess.Text    = "Successfully updated Customs Type " + "'" + oCType.CustomsType + "'";
                 }
                 else
                 {
                     errorMsg.Visible = true;
                     errorMsg.Text    = updateMsg;
                     e.Canceled       = true;
                 }
             }
         }
         else
         {
             // display error
             errorMsg.Visible = true;
             errorMsg.Text    = "Please enter Required fields";
             e.Canceled       = true;
         }
     }
     catch (Exception ex)
     {
         pnlDanger.Visible = true;
         lblDanger.Text    = ex.Message.ToString();
         e.Canceled        = true;
     }
 }
Esempio n. 4
0
    public string UpdateCustomsType(ClsCustomsType data)
    {
        string errMsg = "";
        PuroTouchSQLDataContext puroTouchContext = new PuroTouchSQLDataContext();

        try
        {
            if (data.idCustomsType > 0)
            {
                // Query the database for the row to be updated.
                var query =
                    from qdata in puroTouchContext.GetTable <tblCustomsType>()
                    where qdata.idCustomsType == data.idCustomsType
                    select qdata;

                // Execute the query, and change the column values
                // you want to change.
                foreach (tblCustomsType updRow in query)
                {
                    updRow.CustomsType   = data.CustomsType;
                    updRow.ActiveFlag    = data.ActiveFlag;
                    updRow.idCustomsType = data.idCustomsType;
                    updRow.UpdatedBy     = data.UpdatedBy;
                    updRow.UpdatedOn     = data.UpdatedOn;
                }

                // Submit the changes to the database.
                puroTouchContext.SubmitChanges();
            }
            else
            {
                errMsg = "There is No Customs Type with ID = " + "'" + data.idCustomsType + "'";
            }
        }
        catch (Exception ex)
        {
            errMsg = ex.Message.ToString();
        }
        return(errMsg);
    }