// Save the uploaded file
If (myfile. postedfile! = NULL)
{
If (myfile. postedfile. filename. Length = 0)
{
This. lbscript. Text = "<script language = JavaScript> alert ('Select Upload File! '); </SCRIPT> ";
Return;
}
Imgstream = myfile. postedfile. inputstream;
Imglen = myfile. postedfile. contentlength;
Imgfiletype = "Doc ";
Imgbinarydata = new byte [imglen];
Imgstream. Read (imgbinarydata, 0, imglen );
}
Else
{
Imgbinarydata = new byte [0];
}
Bool result = insertlog (int32.parse (session ["userid"]. tostring (), ACC. simpletanslate (this. textbox1.text), int32.parse (this. dropdownlist1.selecteditem. value), system. datetime. now, imgbinarydata, ACC. simpletanslate (this. textbox2.text ));
/// <Summary>
/// Save the objectdict File
/// </Summary>
/// <Param name = "FILENAME"> </param>
/// <Param name = "mediatypeid"> </param>
/// <Param name = "imgbinarydata"> </param>
/// <Param name = "imgfiletype"> </param>
/// <Param name = "objectid"> </param>
/// <Returns> </returns>
Public static bool insertlog (INT userid, string content, int typeid, datetime date, byte [] imgbinarydata, string note)
{
String strlog = NULL;
Sqlconnection Cn = new sqlconnection (system. configuration. configurationsettings. deleettings ["db_pmms_string"]);
String SQL = "pmmsoa_log_savelog ";
Sqlparameter [] paras = new sqlparameter [6];
Paras [0] = pmmsweb. dataaccessor. commonfun. sqlhelper. newparameter ("@ userid", userid );
Paras [1] = pmmsweb. dataaccessor. commonfun. sqlhelper. newparameter ("@ content", content );
Paras [2] = pmmsweb. dataaccessor. commonfun. sqlhelper. newparameter ("@ typeid", typeid );
Paras [3] = pmmsweb. dataaccessor. commonfun. sqlhelper. newparameter ("@ date", date );
Paras [4] = pmmsweb. dataaccessor. commonfun. sqlhelper. newparameter ("@ attachment", imgbinarydata );
Paras [5] = pmmsweb. dataaccessor. commonfun. sqlhelper. newparameter ("@ note", note );
// Paras [4] = pmmsweb. dataaccessor. commonfun. sqlhelper. newparameter ("@ note", objectid );
Sqlcommand cmd = pmmsweb. dataaccessor. commonfun. sqlhelper. createcommand (SQL, CN, commandtype. storedprocedure, paras );
Try
{
Using (CN)
{
CN. open ();
Cmd. executenonquery ();
CN. Close ();
Strlog = string. Format ("[work log] The form is added successfully! Details: content = {0 }. ", Content );
Return true;
}
}
Catch (exception ex)
{
Strlog = string. Format ("[work log] The form is added successfully! Details: content = {0 }. ", Content );
Return false;
}
Finally
{
// Write logs
Pmmsweb. dataaccessor. commonfun. Logger. writeuserlog (strlog );
}
}