Thursday, October 28, 2010

Add Different Colors In Bar Chat In SSRS Report

01.Go to Chart Properties
02.Then Go Color and Click Expression.
03.Change Expression as follows.
=IIF(Fields!WeekDate.Value <(DateAdd("d", -7,Now().Today())),"RoyalBlue","Gold")

Tuesday, October 19, 2010

Update Plugin to CRM

01. Run Plug in Registration tool in CRM sdk.
02.Create connection and connect appropiate organization.
03.Register dll as Load Registration.
04.Create new Step for given name in Entity and Set Message as Create.

Create CRM plugin to Update Account Object Based On Address/ CRM 4

public class AccountCreatePlugin : IPlugin
{
public void Execute(IPluginExecutionContext context)
{
DynamicEntity entity = null;

// Check if the input parameters property bag contains a target
// of the create operation and that target is of type DynamicEntity.
if (context.InputParameters.Properties.Contains("Target") &&
context.InputParameters.Properties["Target"] is DynamicEntity)
{
// Obtain the target business entity from the input parmameters.
entity = (DynamicEntity)context.InputParameters.Properties["Target"];

// Verify that the entity represents an account.
if (entity.Name != EntityName
.customeraddress
.ToString()) { return; }
}
else
{
return;
}

try
{
//Get Address ID
if (context.OutputParameters.Properties.Contains("id"))
{
Guid regardingobjectid =
new Guid(context.OutputParameters.Properties["id"].ToString());
string regardingobjectidType = EntityName.customeraddress.ToString();

ColumnSet accountColumns = new ColumnSet();
accountColumns.AddColumn("city");
accountColumns.AddColumn("country");
// accountColumns.AddColumn("Account_CustomerAddress");
ICrmService service = (ICrmService)context.CreateCrmService(true);
customeraddress crmaddress =
(customeraddress)service.Retrieve(regardingobjectidType, regardingobjectid, accountColumns);

//Check Address is Belong to Account

if (crmaddress.objecttypecode.Value == EntityName.account.ToString())
{

ColumnSet accountColumns2 = new ColumnSet();
accountColumns.AddColumn("address1_city");

regardingobjectidType = crmaddress.objecttypecode.Value;
regardingobjectid = crmaddress.parentid.Value;

account crmaccount =
(account)service.Retrieve(regardingobjectidType, regardingobjectid, accountColumns2);

//Update Account Object
crmaccount.address1_city = crmaddress.city;

service.Update(crmaccount);



}

}





}
catch (System.Web.Services.Protocols.SoapException ex)
{
throw new Exception("An error occurred in the AccountCreateHandler plug-in.", ex);
}

Create CRM plugin to Create Address After Account Object Create CRM 4

namespace AccountCreatePlugin
{
public class AccountCreatePlugin : IPlugin
{
public void Execute(IPluginExecutionContext context)
{
DynamicEntity entity = null;

// Check if the input parameters property bag contains a target
// of the create operation and that target is of type DynamicEntity.
if (context.InputParameters.Properties.Contains("Target") &&
context.InputParameters.Properties["Target"] is DynamicEntity)
{
// Obtain the target business entity from the input parmameters.
entity = DynamicEntity)context.InputParameters.Properties["Target"];

// Verify that the entity represents an account.
if (entity.Name != EntityName.account
.ToString()) { return; }
}
else
{
return;
}

try
{

//Create Address Object
customeraddress address = new customeraddress();
address.line1 = "Line 1";
address.line2 = "Line 2";
address.city = "City";
address.stateorprovince = "State";
address.postalcode = "Zip";
address.country = "Sri lanka";



if (context.OutputParameters.Properties.Contains("id"))
{
//Get Guid
Guid regardingobjectid =
new Guid(context.OutputParameters.Properties["id"].ToString());
string regardingobjectidType = EntityName.customeraddress.ToString();

address.parentid = new Lookup();
address.parentid.type = EntityName.account.ToString();
address.parentid.Value = regardingobjectid;

//sets the objecttypecode value to that of the account system
address.objecttypecode = new EntityNameReference();

address.objecttypecode.Value = EntityName.account.ToString();

}

ICrmService service = (ICrmService)context.CreateCrmService(true);
service.Create(address);



}
catch (System.Web.Services.Protocols.SoapException ex)
{
throw new Exception("An error occurred in the AccountCreateHandler plug-in.", ex);
}
}


}


}

Sunday, October 10, 2010

Disable Back Button Not Include TextArea Or Input

<script type="text/javascript">

if (typeof window.event != 'undefined')
document.onkeydown = function()
{


if ((event.srcElement.tagName.toUpperCase() != 'TEXTAREA')|| (event.srcElement.tagName.toUpperCase() != 'INPUT'))
return (event.keyCode != 8);
}
else
document.onkeypress = function(e)
{

if (e.target.nodeName.toUpperCase() != 'TEXTAREA')
return (e.keyCode != 8);
}

</script>

Wednesday, October 6, 2010

Ajax Calender Extender Add To Grid View

 Calender not Display Properly within grid. So Add hidden textbox as target Control and set visibility false.
add calender extender and hidden text box within div . set div position relative. Then set hidden textbox date to textbox date using  OnClientDateSelectionChanged function as follows.

 <style type="text/css">
    .hiddenCol
    {
        visibility:hidden;
         padding:0;
         position:absolute;
         border:0;
        }
    </style>
   
  <script type="text/javascript">
        function checkDate(sender, args) {
        
            if (sender._selectedDate > new Date()) {
                alert("You cannot select a Future Date!");
                sender._selectedDate = new Date();
                // set the date back to the current date

            }

            sender._textbox.set_Value(sender._selectedDate.format(sender._format));
            var hiddenId=(sender._element.id);
            var elem = hiddenId.split('_');
            var textId = elem[0] + '_' + elem[1] + '_txtChequeDate';
            document.getElementById(textId).value = document.getElementById(hiddenId).value;
          
       }
          </script>

///---------------------------In Grid View
 
<asp:TemplateField HeaderText="ChequeDate">
                                        <ItemTemplate>
                                            <table>
                                                <tr>
                                                    <td>
                                                        <asp:TextBox ID="txtChequeDate" runat="server"  CssClass="Textboxstyle" Enabled="false"
                                                            TabIndex="17" Width="100px"></asp:TextBox>
                                                        <div style="padding: 0; position: relative;" >
                                                             <cc1:CalendarExtender ID="calDocDate" runat="server" TargetControlID="hidChequeDate"
                                                                PopupButtonID="btnChequeDate" OnClientDateSelectionChanged="checkDate2"  />
                                                                 <asp:TextBox ID="hidChequeDate"    Width="0px" Height="0px" runat="server" CssClass="hiddenCol"  />
                                                        </div>
                                                    </td>
                                                    <td valign="top">
                                                        <asp:Button ID="btnChequeDate" runat="server" BorderStyle="None" BorderWidth="0px"
                                                            CssClass="calender" Enabled="false" TabIndex="18" />
                                                    </td>
                                                </tr>
                                            </table>
                                         </ItemTemplate>                                               
                                    </asp:TemplateField>