//  To get 'Stakeholder Relationship Manager' record of 'Active' or 'Inactive' from database by stored procedure
 public DataTable LoadActiveStakeholderRelationshipManager(int LoggedInUser, string returnmsg, bool IsActive)
 {
     SqlConnection Conn = new SqlConnection(ConnStr);
     //  'uspGetStakeholderRelationshipManagerDetails' stored procedure is used to get specific records from Stakeholder Relationship Manager table
     SqlDataAdapter DAdapter = new SqlDataAdapter("uspGetStakeholderRelationshipManagerDetails", Conn);
     DAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
     DAdapter.SelectCommand.Parameters.AddWithValue("@LoggedInUser", LoggedInUser);
     DAdapter.SelectCommand.Parameters.AddWithValue("@RetMsg", returnmsg);
     DAdapter.SelectCommand.Parameters.AddWithValue("@IsActive", IsActive);
     DataSet DSet = new DataSet();
     try
     {
         DAdapter.Fill(DSet, "StakeholderRelationshipManager");
         return DSet.Tables["StakeholderRelationshipManager"];
     }
     catch
     {
         throw;
     }
     finally
     {
         DSet.Dispose();
         DAdapter.Dispose();
         Conn.Close();
         Conn.Dispose();
     }
 }
 public void Dispose()
 {
     if (!_isDisposed)         // only dispose if has not been disposed;
     {
         myDataSet?.Dispose(); // only dispose if myDataSet is not null;
     }
 }
Пример #3
0
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        //get song name and value
        DropDownList2.Visible = true;
        string videoQuery = "SELECT video_id,video_name FROM video where singer_id =" + dropSingerValue.ToString() + ";";

        SqlDataAdapter da2 = new SqlDataAdapter(videoQuery, conn);
        DataSet ds2 = new DataSet();
        da2.Fill(ds2);
        if (ds2.Tables[0].Rows.Count > 0)
        {
            SingerName = DropDownList1.SelectedItem.Text;
            SongName = "";
            ds2.Dispose(); DropDownList2.Items.Clear();
            DropDownList2.DataSource = ds2;
            DropDownList2.DataTextField = "video_name";
            DropDownList2.DataValueField = "video_id";
            DropDownList2.DataBind();
            DropDownList2.Items.Insert(0, new ListItem("-- Select Video --", "0"));
        }
        else
        {
            Response.Write("no data");
            // Response.End();

        }
    }
 //  To get 'WS1 Status' record of both 'Active','Inactive' type from database by stored procedure
 public DataTable LoadWS1Status(int LoggedInUser, string Ret)
 {
     SqlConnection Conn = new SqlConnection(ConnStr);
     //  'uspGetWS1StatusDetails' stored procedure is used to get both 'Active','Inactive' type records from WS1 Status table
     SqlDataAdapter DAdapter = new SqlDataAdapter("Masters.uspGetWS1StatusDetails", Conn);
     DAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
     DAdapter.SelectCommand.Parameters.AddWithValue("@LoggedInUser", LoggedInUser);
     DAdapter.SelectCommand.Parameters.AddWithValue("@RetMsg", Ret);
     DataSet DSet = new DataSet();
     try
     {
         DAdapter.Fill(DSet, "WS1Status");
         return DSet.Tables["WS1Status"];
     }
     catch
     {
         throw;
     }
     finally
     {
         DSet.Dispose();
         DAdapter.Dispose();
         Conn.Close();
         Conn.Dispose();
     }
 }
Пример #5
0
    protected void ddlGrade_SelectedIndexChanged(object sender, EventArgs e)
    {
        //If no Grade is Selected.
        if (ddlGrade.SelectedIndex != -1)
        {
            //Clear the excisting Items
            ddlClass.Items.Clear();
            //Clear the excisting Items
            ddlClass.Items.Add(new ListItem("Select Class", "Empty"));
            //Execute Query and
            OdbcDataAdapter adpClassList = DB_Connect.ExecuteQuery("SELECT DISTINCT CLASS_CODE FROM student_class WHERE SC_GRADE='" + ddlGrade.SelectedValue + "'");
            adpClassList.SelectCommand.CommandType = CommandType.Text;
            DataSet dsClassList = new DataSet();
            adpClassList.Fill(dsClassList);
            if (dsClassList.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dsClassList.Tables[0].Rows.Count; i++)
                {
                    ListItem lstClassList = new ListItem();
                    // or your index which is correct in your dataset
                    lstClassList.Value = dsClassList.Tables[0].Rows[i][0].ToString();
                    // or your index which is correct in your dataset
                    lstClassList.Text = dsClassList.Tables[0].Rows[i][0].ToString();
                    ddlClass.Items.Add(lstClassList);
                }
            }
            dsClassList.Dispose();

        }
    }
Пример #6
0
 protected void ddlClass_SelectedIndexChanged(object sender, EventArgs e)
 {
     //If no Grade is Selected.
     if (ddlClass.SelectedIndex != -1)
     {
         ddlStudent.Items.Clear();
         ddlStudent.Items.Add(new ListItem("Select Student", "empty"));
         OdbcDataAdapter adpNameList = DB_Connect.ExecuteQuery("SELECT `NAME_INITIALS` FROM `student_mast` S, `student_class` SC WHERE SC.SC_YEAR = YEAR(CURDATE()) AND SC.SC_GRADE='" + ddlGrade.SelectedIndex + "' AND SC.CLASS_CODE = '" + ddlClass.SelectedValue + "' AND SC.ADMISSION_NO = S.ADMISSION_NO");
         adpNameList.SelectCommand.CommandType = CommandType.Text;
         DataSet dsNameList = new DataSet();
         adpNameList.Fill(dsNameList);
         if (dsNameList.Tables[0].Rows.Count > 0)
         {
             for (int i = 0; i < dsNameList.Tables[0].Rows.Count; i++)
             {
                 ListItem lstNameList = new ListItem();
                 // or your index which is correct in your dataset
                 lstNameList.Value = dsNameList.Tables[0].Rows[i][0].ToString();
                 // or your index which is correct in your dataset
                 lstNameList.Text = dsNameList.Tables[0].Rows[i][0].ToString();
                 ddlStudent.Items.Add(lstNameList);
             }
         }
         dsNameList.Dispose();
     }
 }
Пример #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try {
            string componentName = Request["componentName"];
            string tokenName = Request["tokenName"];
            string tokenValue = string.Empty;
            DataSet ds = new DataSet();

            SqlCommand cmd = new SqlCommand("dbo.FSFPL_RestoreEditableContent");
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("ComponentName", componentName);
            cmd.Parameters.AddWithValue("TokenName", tokenName);
            SqlConnection conn = new SqlConnection(SiteConfig.ConnectionString);
            cmd.Connection = conn;
            SqlDataAdapter sqlda = new SqlDataAdapter(cmd);
            sqlda.Fill(ds);
            // return data for display
            tokenValue = ds.Tables[0].Rows[0]["TokenValue"].ToString();
            // cleanup
            conn.Close();
            ds.Dispose();
            cmd.Dispose();
            sqlda.Dispose();
            Response.Write(tokenValue);
        } catch (Exception ex) {
            Response.Write(ex.Message);
        }
    }
Пример #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["kullanici"] != null || Session["yonetici"] != null)
        {

        }
        else
        {
            Response.Redirect("KullaniciGiris.aspx");
        }
        try
        {
            Yardimci.baglanti.Open();
            SqlCommand sinif_cek = new SqlCommand();
            sinif_cek.CommandText = "SELECT SINIF_ID, SINIF_AD FROM SINIFLAR";
            sinif_cek.Connection = Yardimci.baglanti;
            DataSet ds = new DataSet();
            SqlDataAdapter adp = new SqlDataAdapter(sinif_cek);
            adp.Fill(ds, "SINIFLAR");
            dwSiniflar.DataSource = ds.Tables["SINIFLAR"];
            dwSiniflar.DataBind();
            ds.Dispose();
            adp.Dispose();
            Yardimci.baglanti.Close();
        }
        catch (Exception hata)
        {
            Yardimci.baglanti.Close();
            lbl_sonuc.Text = hata.Message;
        }
    }
 //  To get 'Curriculum' record of both 'Active','Inactive' type from database by stored procedure
 public DataTable LoadCurriculum(int LoggedInUser, string Ret)
 {
     SqlConnection Conn = new SqlConnection(ConnStr);
     //  'uspGetIntakeFormCurriculum' stored procedure is used to get both 'Active','Inactive' type records from Curriculum table
     SqlDataAdapter DAdapter = new SqlDataAdapter("Transactions.uspGetIntakeFormCurriculum", Conn);
     DAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
     DAdapter.SelectCommand.Parameters.AddWithValue("@LoggedInUser", LoggedInUser);
     DAdapter.SelectCommand.Parameters.AddWithValue("@RetMsg", Ret);
     DataSet DSet = new DataSet();
     try
     {
         DAdapter.Fill(DSet, "Curriculum");
         return DSet.Tables["Curriculum"];
     }
     catch
     {
         throw;
     }
     finally
     {
         DSet.Dispose();
         DAdapter.Dispose();
         Conn.Close();
         Conn.Dispose();
     }
 }
Пример #10
0
 protected string MailBodyOlustur(int FirmaId, DateTime KalBitTar)
 {
     EFDal ed = new EFDal();
     string MailBody = "";
     MailBody += "<table border=\"1\"><tr>" +
                     "<td><b>Marka</b></td>" +
                     "<td><b>Model</b></td>" +
                     "<td><b>Seri No</b></td>" +
                     "<td><b>Kalibrasyon Tarihi</b></td>" +
                     "<td><b>Sertifika No</b></td>" +
                     "<td><b>Ölçüm Aralığı</b></td>" +
                 "</tr>";
     DataSet ds = new DataSet();
     ds = ed.FirmaIDveKalTardanCihazListesiDon(FirmaId, KalBitTar);
     for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
     {
         MailBody += "<tr>";
         string Marka = "<td>" + ds.Tables[0].Rows[i]["IMALATCI"].ToString() + "</td>";
         string Model = "<td>" + ds.Tables[0].Rows[i]["MODEL"].ToString() + "</td>";
         string SeriNo = "<td>" + ds.Tables[0].Rows[i]["SERINO"].ToString() + "</td>";
         string KalBitTar2 = "<td>" + ds.Tables[0].Rows[i]["KALBITTAR"].ToString().Replace(" 00:00:00", "") + "</td>";
         string SertifikaNo = "<td>" + ds.Tables[0].Rows[i]["SERTIFIKANO"].ToString() + "</td>";
         string OlcAraligi = "<td>" + ds.Tables[0].Rows[i]["OLCUMARALIGI"].ToString() + "</td>";
         MailBody += Marka + Model + SeriNo + KalBitTar2 + SertifikaNo + OlcAraligi + "</tr>";
     }
     MailBody += "</table>";
     ds.Dispose();
     return MailBody;
 }
Пример #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["kullanici"] != null || Session["yonetici"] != null)
        {

        }
        else
        {
            Response.Redirect("KullaniciGiris.aspx");
        }
        try
        {
            Yardimci.baglanti.Open();
                SqlCommand ogretmen_cek = new SqlCommand();
                ogretmen_cek.CommandText = "SELECT * FROM OGRETMENLER_VIEW2";
                ogretmen_cek.Connection = Yardimci.baglanti;
                DataSet ds = new DataSet();
                SqlDataAdapter adp = new SqlDataAdapter(ogretmen_cek);
                adp.Fill(ds, "OGRETMENLER_VIEW2");
                dwOgretmenler.DataSource = ds.Tables["OGRETMENLER_VIEW2"];
                dwOgretmenler.DataBind();
                ds.Dispose();
                adp.Dispose();
                Yardimci.baglanti.Close();
        }
        catch (Exception hata)
        {
            Yardimci.baglanti.Close();
            lbl_sonuc.Text = hata.Message;
        }
    }
Пример #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if ( Session["yonetici"] != null)
        {

        }
        else
        {
            Response.Redirect("KullaniciGiris.aspx");
        }
        try
        {
            Yardimci.baglanti.Open();
            SqlCommand kullanici_Cek = new SqlCommand();
            kullanici_Cek.CommandText = "SELECT * FROM KULLANICILAR";
            kullanici_Cek.Connection = Yardimci.baglanti;
            DataSet ds = new DataSet();
            SqlDataAdapter adp = new SqlDataAdapter(kullanici_Cek);
            adp.Fill(ds, "KULLANICILAR");
            dwKullanicilar.DataSource = ds.Tables["KULLANICILAR"];
            dwKullanicilar.DataBind();
            ds.Dispose();
            adp.Dispose();

            Yardimci.baglanti.Close();
        }
        catch (Exception hata)
        {
            Yardimci.baglanti.Close();
            lbl_sonuc1.Text = hata.Message;
        }
    }
Пример #13
0
 //  To get 'SubMenu' record of 'Active' or 'Inactive' from database by stored procedure
 public DataTable LoadActiveSubMenu(bool IsActive,int LoggedInUser, string RetMsg)
 {
     SqlConnection Conn = new SqlConnection(ConnString);
     //  'uspGetSubMenuDetails' stored procedure is used to get specific records from SubMenu table
     SqlDataAdapter DAdapter = new SqlDataAdapter("uspGetSubMenuDetails", Conn);
     DAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
     DataSet DSet = new DataSet();
     try
     {
         DAdapter.SelectCommand.Parameters.AddWithValue("@IsActive", IsActive);
         DAdapter.SelectCommand.Parameters.AddWithValue("@LoggedInUser", LoggedInUser);
         DAdapter.SelectCommand.Parameters.AddWithValue("@RetMsg", RetMsg);
         DAdapter.Fill(DSet, "Masters.SubMenu");
         return DSet.Tables["Masters.SubMenu"];
     }
     catch
     {
         throw;
     }
     finally
     {
         DSet.Dispose();
         DAdapter.Dispose();
         Conn.Close();
         Conn.Dispose();
     }
 }
Пример #14
0
        /// <summary>
        /// Global execute query.
        /// </summary>
        /// <param name="passKey">The pass key.</param>
        /// <param name="username">The username.</param>
        /// <param name="procName">Name of the proc.</param>
        /// <param name="paramList">The parameter list.</param>
        /// <returns>DataSet.</returns>
        public DataSet ws_GlobalExecuteQuery(string passKey, string username, string procName, SPParam[] paramList)
        {
            if (!ValidationAndEncryptDecrypt.ValidateKey(passKey))
            {
                return(null);
            }

            DataSet dsCheck = SpParamHelpers.CheckSpParams(procName, "", paramList);

            if (dsCheck != null)
            {
                return(dsCheck);
            }

            SqlConnection  dbConn     = null;
            SqlCommand     sqlCmd     = null;
            SqlDataAdapter sqlAdapter = null;
            DataSet        ds         = null;

            try
            {
                dbConn = GetOpenSqlConnection("");

                sqlCmd = new SqlCommand(procName, dbConn)
                {
                    CommandType = CommandType.StoredProcedure, CommandTimeout = 0
                };

                foreach (SPParam p in paramList)
                {
                    SqlParameter param = sqlCmd.Parameters.AddWithValue(p.Name, p.Value);
                    if (p.Value == null)
                    {
                        param.IsNullable = true;
                        param.Value      = DBNull.Value;
                    }
                }

                ds         = new DataSet();
                sqlAdapter = new SqlDataAdapter {
                    SelectCommand = sqlCmd
                };
                sqlAdapter.Fill(ds);
                return(ds);
                //}
            }
            catch (Exception e)
            {
                WriteEventLogEntry(e, procName, paramList);
                return(HandleExceptionHelper.HandleSqlException(e, procName, paramList));
            }
            finally
            {
                ds?.Dispose();
                sqlAdapter?.Dispose();
                sqlCmd?.Dispose();
                CloseConnection(dbConn);
            }
        }
Пример #15
0
 public void Dispose()
 {
     CommitChanges();
     _usersDataSet?.Dispose();
     _categoriesDataSet?.Dispose();
     _usersAdapter?.Dispose();
     _categoriesAdapter?.Dispose();
     _connection?.Dispose();
 }
Пример #16
0
 protected void GorevIDdenGrdiBagla(int GorevId)
 {
     EFDal ed = new EFDal();
     DataSet ds = new DataSet();
     ds = ed.GorevFirmaDon(GorevId);
     GridView1.DataSource = ds;
     GridView1.DataBind();
     ds.Dispose();
 }
Пример #17
0
        public void Dispose()
        {
            _excelDataReader?.Dispose();
            _excelDataReader = null;

            _fileStream?.Dispose();
            _fileStream = null;

            _data?.Dispose();
            _data = null;
        }
Пример #18
0
    public int FormRUSM(int IDMAIN)
    {
        command = new SqlCommand("DELETE TECHNOLOG_VVV..RUSM;", conbase01);
        conbase01.Open();
        command.CommandTimeout = 1200;
        command.ExecuteNonQuery();
        conbase01.Close();

        int IDMt = IDMAIN;
        //int IDMt = 1202423;
        da.SelectCommand = new SqlCommand();
        da.SelectCommand.CommandText = " SELECT ID FROM  " + BAZA + "..DATAEXT "
        + " WHERE IDMAIN=" + IDMt.ToString() + " and MNFIELD=921 AND MSFIELD='$b' AND SORT='Изданиекартографическое'";
        da.SelectCommand.Connection = conbase03;
        da.SelectCommand.CommandTimeout = 1200;
        DataSet ds921 = new DataSet();
        int K921 = da.Fill(ds921);
        ds921.Dispose();
        if (K921 > 0)
        {
            return 1; // Карты не обрабатываются
        }
        PBJ2RUSM(IDSession, IDMt, "n"); // Создание таблицы RUSM

        da.SelectCommand = new SqlCommand();
        da.SelectCommand.CommandText = " SELECT ID,POL "
        + " FROM TECHNOLOG_VVV..RUSM "
        + " WHERE IDMAIN=" + IDMt.ToString() + " and session='" + IDSession + "'"
        + " AND MET=102";
        da.SelectCommand.Connection = conbase01;
        da.SelectCommand.CommandTimeout = 1200;
        DataSet dsZ = new DataSet();
        int K102 = da.Fill(dsZ);
        if (K102 > 0)
        {
            K102 = Int32.Parse(dsZ.Tables[0].Rows[0]["ID"].ToString());
            P102 = dsZ.Tables[0].Rows[0]["POL"].ToString().Replace("'", "~") + (char)31 + "2VGBILGEO";
            R = " UPDATE TECHNOLOG_VVV..RUSM SET POL =N'" + P102 + "' WHERE ID=" + K102;
            command = new SqlCommand(R, conbase01);
            conbase01.Open();
            command.CommandTimeout = 1200;
            command.ExecuteNonQuery();
            conbase01.Close();
        }

        //CONTROL101(IDSession, IDMt); // Проверка поля Языки

        OBR98(IDSession, IDMt, "n"); // ФОРМИРОВАНИЕ ПОЛЯ 801 - Источник записи
        //=========================================================================================================Саша, здесь RUSM сформирована=======================================
        return 0;

        // цикл по IDM
    }
Пример #19
0
 protected void ddlStudentName_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ddlStudentName.SelectedIndex != -1)
     {
         OdbcDataAdapter adpAdNoList = DB_Connect.ExecuteQuery("SELECT S.`ADMISSION_NO` FROM `student_mast` S, `student_class` SC WHERE SC.SC_YEAR = YEAR(CURDATE()) AND SC.SC_GRADE='" + ddlGrade.SelectedIndex + "' AND S.NAME_INITIALS='" + ddlStudentName.SelectedValue + "'AND SC.CLASS_CODE = '" + ddlClass.SelectedValue + "' AND SC.ADMISSION_NO = S.ADMISSION_NO");
         adpAdNoList.SelectCommand.CommandType = CommandType.Text;
         DataSet dsAdNoList = new DataSet();
         adpAdNoList.Fill(dsAdNoList);
         adNo = dsAdNoList.Tables[0].Rows[0][0].ToString();
         dsAdNoList.Dispose();
     }
 }
Пример #20
0
        /// <summary>
        /// Asynchronous load for loading multiple select in a data set. Each query
        /// is supposed to be separated by a ;
        /// </summary>
        /// <param name="sqlQuery">Composed query in the data set</param>
        /// <returns>A dataset with the loaded datatable</returns>
        public override async Task <DataSet> AsyncDataSetLoad(string sqlQuery)

        {
            DataSet         set   = new DataSet();
            DataTable       table = null;
            OdbcDataAdapter da    = null;
            OdbcCommand     cmd   = null;

            try
            {
                if (_connection.State != ConnectionState.Open)
                {
                    _connection.ConnectionString = _connectionString;

                    await _connection.OpenAsync();
                }

                OdbcTransaction dbTransaction = _connection.BeginTransaction();
                IList <string>  queryPart     = Regex.Split(sqlQuery, ";");
                object          region        = new object();
                int             i             = 0;

                foreach (string query in queryPart)
                {
                    lock (region)
                    {
                        cmd   = new OdbcCommand(queryPart[i++], _connection, dbTransaction);
                        table = new DataTable();
                        da    = new OdbcDataAdapter(cmd);
                    }
                    await Task.Run(() =>
                    {
                        da.Fill(table);
                    }).ConfigureAwait(false);

                    set.Tables.Add(table);
                }
            }
            catch (System.Exception e)
            {
                set = null;
                throw new DataLayerException(e.Message, e);
            }
            finally
            {
                Close();
                set?.Dispose();
                cmd?.Dispose();
                da?.Dispose();
            }
            return(set);
        }
Пример #21
0
        private bool disposedValue = false; // Pour détecter les appels redondants


        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _dataset?.Dispose();
                    _dataset = null;
                }

                disposedValue = true;
            }
        }
Пример #22
0
    public string FillLegal()
    {
        string tbl = "admin";
        string sqlStr = "SELECT * FROM " + tbl;
        string legal = string.Empty;

        try
        {
            OleDbConnection cnn = new OleDbConnection(Base.cnnStr);
            OleDbDataAdapter oda = new OleDbDataAdapter(sqlStr, cnn);
            OleDbCommand cmd = new OleDbCommand(sqlStr, cnn);
            cnn.Open();
            OleDbDataReader drr = cmd.ExecuteReader();

            DataSet ds = new DataSet();

            oda.Fill(ds, "admin");

            while (drr.Read())
            {
                legal = EncDec.Decrypt(drr["legal"].ToString(), Base.hashKey);
                break;
            }

            drr.Close();
            cnn.Close();

            cmd.Dispose();
            drr.Dispose();
            ds.Dispose();
            oda.Dispose();
            cnn.Dispose();

            cmd = null;
            drr = null;
            ds = null;
            oda = null;
            cnn = null;
        }
        catch
        {
            legal = errInvalidLegal;
        }
        finally
        {
            tbl = null;
            sqlStr = null;
        }

        return legal;
    }
    public void fnLoadPage1()
    {
        try
        {

            _objMasters = new clsMasters();
            _objMasters.ScreenInd = Masters.AgentCommission;

            if (Session["Role"].ToString() == "Admin")
            {
                _objMasters.Type = "AD";
                _objMasters.DistributorID = Convert.ToInt32(Session["UserID"].ToString());
            }
            else if (Session["Role"].ToString() == "DB")
            {
                _objMasters.Type = "AG";
                _objMasters.DistributorID = Convert.ToInt32(Session["UserID"].ToString());
            }

            _objDataSet = (DataSet)_objMasters.fnGetData();

            if (_objDataSet.Tables[0].Rows.Count > 0)
            {
                gvOperators.DataSource = _objDataSet.Tables[0];
                gvOperators.DataBind();
                ViewState["OperatorName"] = _objDataSet.Tables[0];
                btnUpdate.Visible = false;
                btnDelete.Visible = false;
                btnCancel.Visible = false;
                btnAdd.Visible = true;
            }

        }
        catch (Exception ex)
        {
          //  LogError("Masters_frmOperatorNameaspx.aspx", "fnLoadPage", DateTime.Now, ex.Message.ToString());
          //  Response.Redirect("../Error.aspx", false);
            //Logger.Log(Logger.LogType.Log_In_DB, ex,true);
            //Logger.Log(ex, Session["APRUserName"].ToString());
            lblmessage.Text = ex.Message;
        }
        finally
        {
            _objMasters = null;
            if (_objDataSet != null)
            {
                _objDataSet.Dispose();
            }
        }
    }
        private bool disposedValue = false; // Для определения избыточных вызовов

        void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _backupDataStreamReader?.Dispose();
                    _dataSet?.Dispose();
                }

                _dataSet      = null;
                disposedValue = true;
            }
        }
Пример #25
0
        public void Dispose()
        {
            sentence?.Dispose();
            resultSentence?.Dispose();
            dc1?.Dispose();
            dc2?.Dispose();
            dc3?.Dispose();

            sentence       = null;
            resultSentence = null;
            dc1            = null;
            dc2            = null;
            dc3            = null;
        }
Пример #26
0
 protected void BtnAddGrp_Click(object sender, EventArgs e)
 {
     if (DrpDwnGroupStd.SelectedIndex != -1)
     {
         OdbcDataAdapter adpAdNoList = DB_Connect.ExecuteQuery("SELECT S.`FMOBILE_NO` FROM `student_mast` S, `student_class` SC WHERE SC.SC_YEAR = YEAR(CURDATE()) AND SC.SC_GRADE='" + DrpDwnGroupGrade.SelectedIndex + "' AND S.NAME_INITIALS='" + DrpDwnGroupStd.SelectedValue + "'AND SC.CLASS_CODE = '" + DrpDwnGroupCla.SelectedValue + "' AND SC.ADMISSION_NO = S.ADMISSION_NO");
         adpAdNoList.SelectCommand.CommandType = CommandType.Text;
         DataSet dsAdNoList = new DataSet();
         adpAdNoList.Fill(dsAdNoList);
         string MobNo = dsAdNoList.Tables[0].Rows[0][0].ToString();
         lblMobNo.Text = MobNo.ToString();
         DrpdwnStdList.Items.Add(new ListItem(MobNo, MobNo));
         Label28.Text = MobNo+" is added.";
         dsAdNoList.Dispose();
     }
 }
Пример #27
0
        private void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    foreach (var table in _tables)
                    {
                        table.Dispose();
                    }
                    _dataset?.Dispose();
                }

                _disposedValue = true;
            }
        }
Пример #28
0
            public void Dispose()
            {
                if (m_disposed)
                {
                    return;
                }

                try
                {
                    DataSubscriber?.Dispose();
                    Metadata?.Dispose();
                }
                finally
                {
                    m_disposed = true;
                }
            }
Пример #29
0
    public DataSet buscarClienteAll()
    {
        SqlCommand cmdBuscar = new SqlCommand();
        cmdBuscar.Connection = conectarBD.Conectar();
        cmdBuscar.CommandText = "buscar_ClienteAll";             // Nombre del procedimiento almacenado
        cmdBuscar.CommandType = CommandType.StoredProcedure;    // Indicar que se ejecuta un Procedimiento en vez de una Query
        SqlDataAdapter daBuscar = new SqlDataAdapter(cmdBuscar);

        DataSet dsBuscar = new DataSet();                       // DataSet para cargar los datos
        daBuscar.Fill(dsBuscar, "mitabla");                      // Llena el DataSet con el resultado y lo nombra con un alias "mitabla"
        // Libera los objetos, memoria y cierra la conexion
        daBuscar.Dispose();
        dsBuscar.Dispose();
        conectarBD.cerrarSQL();

        return dsBuscar;
    }
Пример #30
0
    public DataTable Consulta(string SQL, SqlParameter[] param)
    {
        SqlCommand cmd = null;
            SqlDataAdapter sda = null;
            DataSet ds = null;

            try
            {
                cmd = new SqlCommand();

                cmd.CommandType = CommandType.Text;
                cmd.CommandText = SQL;
                cmd.Connection = conn;

                cmd.Parameters.Clear();

                if (param != null)
                {
                    foreach (SqlParameter p in param)
                        cmd.Parameters.Add(p);
                }

                sda = new SqlDataAdapter(cmd);
                ds = new DataSet();
                sda.Fill(ds);

                return ds.Tables.Count > 0 ? ds.Tables[0] : null;
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                if (cmd != null)
                {
                    cmd.Parameters.Clear();
                    if (cmd.Connection.State == ConnectionState.Open) cmd.Connection.Close();
                    cmd.Dispose();
                }

                if (ds != null) ds.Dispose();
                if (sda != null) sda.Dispose();
            }
    }
Пример #31
0
    public DataSet buscarClienteX(string txtCliente, string BuscarPor)
    {
        SqlCommand cmdBuscar = new SqlCommand();
        cmdBuscar.Connection = conectarBD.Conectar();
        cmdBuscar.CommandText = BuscarPor;             // Nombre del procedimiento almacenado
        cmdBuscar.CommandType = CommandType.StoredProcedure;    // Indicar que se ejecuta un Procedimiento en vez de una Query
        cmdBuscar.Parameters.AddWithValue("@texto_buscar", txtCliente);    // Los parametros del procedimiento, si tuviera
        SqlDataAdapter daBuscar = new SqlDataAdapter(cmdBuscar);

        DataSet dsBuscar = new DataSet();                       // DataSet para cargar los datos
        daBuscar.Fill(dsBuscar, "mitabla");                      // Llena el DataSet con el resultado y lo nombra con un alias "mitabla"
        // Libera los objetos, memoria y cierra la conexion
        daBuscar.Dispose();
        dsBuscar.Dispose();
        conectarBD.cerrarSQL();

        return dsBuscar;
    }
Пример #32
0
 protected void ddlGrade_SelectedIndexChanged(object sender, EventArgs e)
 {
     ddlSubject.Items.Clear();
         ddlSubject.Items.Add(new ListItem("Select Subject", "empty"));
         OdbcDataAdapter adpSubjectList = DB_Connect.ExecuteQuery("SELECT SUBJECT,SUBJECT_CODE FROM subjects_mast WHERE Grade_" + ddlGrade.SelectedItem.Value );
         adpSubjectList.SelectCommand.CommandType = CommandType.Text;
         DataSet dsSubjectList = new DataSet();
         adpSubjectList.Fill(dsSubjectList);
         if (dsSubjectList.Tables[0].Rows.Count > 0)
         {
             for (int i = 0; i < dsSubjectList.Tables[0].Rows.Count; i++)
             {
                 ListItem lstSubjectList = new ListItem();
                 lstSubjectList.Value = dsSubjectList.Tables[0].Rows[i][1].ToString(); // or your index which is correct in your dataset
                 lstSubjectList.Text = dsSubjectList.Tables[0].Rows[i][0].ToString(); // or your index which is correct in your dataset
                 ddlSubject.Items.Add(lstSubjectList);
             }
         }
         dsSubjectList.Dispose();
 }
    public void fnLoadPage1()
    {
        try
        {

            _objMasters = new clsMasters();
            _objMasters.ScreenInd = Masters.ListOfAmounts;
            _objDataSet = (DataSet)_objMasters.fnGetData();

            if (_objDataSet != null)
            {

                if (_objDataSet.Tables[0].Rows.Count > 0)
                {
                    gvOperators.DataSource = _objDataSet.Tables[0];
                    gvOperators.DataBind();
                    ViewState["OperatorName"] = _objDataSet.Tables[0];
                    btnUpdate.Visible = false;
                    btnDelete.Visible = false;
                    btnCancel.Visible = false;
                    btnAdd.Visible = true;
                }
            }

        }
        catch (Exception ex)
        {
           // LogError("Masters_frmOperatorNameaspx.aspx", "fnLoadPage", DateTime.Now, ex.Message.ToString());
            Response.Redirect("../Error.aspx", false);
            //Logger.Log(Logger.LogType.Log_In_DB, ex,true);
            //Logger.Log(ex, Session["APRUserName"].ToString());
        }
        finally
        {
            _objMasters = null;
            if (_objDataSet != null)
            {
                _objDataSet.Dispose();
            }
        }
    }
Пример #34
0
 protected void rptBind()        //repeater数据绑定
 {
     DB db = new DB();
     int n = 4 * (Convert.ToInt32(lbPage.Text) - 1);
     SqlConnection myCon = db.GetCon();
     myCon.Open();
     string sqlstr = "SELECT TOP 4 jobskyerID,dutyInTime,dutyOutTime,toJobskyerID,flag0,flag1 FROM myDutyTime WHERE jobskyerID='" + Session["jobskyerID"] + "' and jobskyerID not in (select top (@n) jobskyerID from FILES where jobskyerID='" + Session["jobskyerID"] + "')";
     SqlCommand mycom = new SqlCommand(sqlstr, myCon);
     mycom.Parameters.Add("n", n);
     SqlDataAdapter da = new SqlDataAdapter(mycom);
     DataSet ds = new DataSet();
     da.Fill(ds);
     ds.Dispose();
     da.Dispose();
     myCon.Close();
     if (ds != null)
     {
         this.Repeater1.DataSource = ds;
         this.Repeater1.DataBind();
     }
 }
Пример #35
0
    private DataTable ReadXml(string fileName)
    {
        DataTable table = new DataTable();
        DataSet dataset = new DataSet();

        try
        {
            if (System.IO.File.Exists(fileName))
                dataset.ReadXml(fileName);
            if (dataset.Tables.Count > 0)
                table = dataset.Tables[0].Copy();

            return table;
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex);
            return table;
        }
        finally { dataset.Dispose(); }
    }
Пример #36
0
    private void changeImage()
    {
        OdbcDataAdapter adpClassList = DB_Connect.ExecuteQuery("SELECT ADMISSION_NO, PID FROM photograph_album WHERE ADMISSION_NO='098'");
        adpClassList.SelectCommand.CommandType = CommandType.Text;
        DataSet dsClassList = new DataSet();
        adpClassList.Fill(dsClassList);
        if (dsClassList.Tables[0].Rows.Count > 0)
        {

            for (int i = 0; i < dsClassList.Tables[0].Rows.Count; i++)
            {
                Console.Beep();
                if (i == turn)
                {
                    Image1.ImageUrl = "~/Logged_Pages/Academic_Reports/Reports/stdImg.ashx?id=" + dsClassList.Tables[0].Rows[i][0].ToString() + "&pid=" + dsClassList.Tables[0].Rows[i][1].ToString();
                    Label1.Text = "trn=" + turn + " ~/Logged_Pages/Academic_Reports/Reports/stdImg.ashx?id=" + dsClassList.Tables[0].Rows[i][0].ToString() + "&pid=" + dsClassList.Tables[0].Rows[i][1].ToString();
                }
            }
        }
        dsClassList.Dispose();
    }
Пример #37
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         Yardimci.baglanti.Open();
         SqlCommand ogretmen_cek = new SqlCommand();
         ogretmen_cek.CommandText = "SELECT * FROM OGRETMENLER_VIEW";
         ogretmen_cek.Connection = Yardimci.baglanti;
         DataSet ds = new DataSet();
         SqlDataAdapter adp = new SqlDataAdapter(ogretmen_cek);
         adp.Fill(ds, "OGRETMENLER_VIEW");
         dwOgretmenler.DataSource = ds.Tables["OGRETMENLER_VIEW"];
         dwOgretmenler.DataBind();
         ds.Dispose();
         adp.Dispose();
         Yardimci.baglanti.Close();
     }
     catch (Exception)
     {
         Yardimci.baglanti.Close();
         throw;
     }
 }
Пример #38
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         Yardimci.baglanti.Open();
         SqlCommand konu_cek = new SqlCommand();
         konu_cek.CommandText = "SELECT * FROM KONULAR_VIEW";
         konu_cek.Connection = Yardimci.baglanti;
         DataSet ds = new DataSet();
         SqlDataAdapter adp = new SqlDataAdapter(konu_cek);
         adp.Fill(ds, "KONULAR_VIEW");
         dwKonular.DataSource = ds.Tables["KONULAR_VIEW"];
         dwKonular.DataBind();
         ds.Dispose();
         adp.Dispose();
         Yardimci.baglanti.Close();
     }
     catch (Exception)
     {
         Yardimci.baglanti.Close();
         throw;
     }
 }
Пример #39
0
 // Disposes of the metadata object. There is no corresponding creation method
 // because the metadata is received through the subscriber event.
 private void ReleaseMetadata(DataSet metadata)
 {
     metadata?.Dispose();
 }
Пример #40
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //string sSQL = "Insert Into tShop(Shopname,UserID) Values('Test',1)";

        //utils.RunSQLStringQuery(sSQL);

        //Post back to either sandbox or live
        //string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
        string         strSandbox = "https://www.paypal.com/cgi-bin/webscr";
        HttpWebRequest req        = (HttpWebRequest)WebRequest.Create(strSandbox);

        //Set values for the request back
        req.Method      = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        byte[] param      = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
        string strRequest = Encoding.ASCII.GetString(param);

        strRequest       += "&cmd=_notify-validate";
        req.ContentLength = strRequest.Length;

        //Send the request to PayPal and get the response
        StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);

        streamOut.Write(strRequest);
        streamOut.Close();
        StreamReader streamIn    = new StreamReader(req.GetResponse().GetResponseStream());
        string       strResponse = streamIn.ReadToEnd();

        streamIn.Close();

        int    iShipID = utils.ToN(Request.QueryString["sid"]);
        string sGUID   = utils.ToS(Request.QueryString["g"]);

        if (strResponse == "VERIFIED")
        {
            SqlParameter[] oParams2 =
            {
                new SqlParameter("@PayPalID",       utils.ToS(Request.Form["txn_id"])),
                new SqlParameter("@PurchaseAmount", utils.ToD(Request.Form["mc_gross"])),
                new SqlParameter("@TaxAmount",      utils.ToD(Request.Form["tax"])),
                new SqlParameter("@ShipAmount",     utils.ToD(Request.Form["shipping"])),
                new SqlParameter("@ShipID",         utils.ToN(iShipID)),
                new SqlParameter("@OrderDate",      utils.ToS(Request.Form["payment_date"])),
                new SqlParameter("@PayPalTXNID",    utils.ToS(Request.Form["txn_id"])),
                new SqlParameter("@ProductID",      utils.ToN(Request.Form["item_number"])),
                new SqlParameter("@Qty",            utils.ToN(Request.Form["quantity"])),
                new SqlParameter("@OptionID",       utils.ToN(Request.Form["custom"])),
                new SqlParameter("@payer_email",    utils.ToS(Request.Form["payer_email"])),
                new SqlParameter("@Firstname",      utils.ToS(Request.Form["first_name"])),
                new SqlParameter("@Lastname",       utils.ToS(Request.Form["last_name"])),
                new SqlParameter("@Address",        utils.ToS(Request.Form["address_street"])),
                new SqlParameter("@Suburb",         utils.ToS(Request.Form["address_city"])),
                new SqlParameter("@State",          utils.ToS(Request.Form["address_state"])),
                new SqlParameter("@PostCode",       utils.ToN(Request.Form["address_zip"])),
                new SqlParameter("@Country",        utils.ToS(Request.Form["address_country"])),
            };
            DataSet dsOrder = utils.ReturnDataset(oParams2, "sp_Insert_Order");

            int OrderID = utils.ToN(dsOrder.Tables[0].Rows[0]["myNewID"]);

            dsOrder.Dispose();

            Session["PayPalID"]  = utils.ToS(Request.Form["txn_id"]);
            Session["ProductID"] = utils.ToN(Request.Form["item_number"]);

            SqlParameter[] oParams =
            {
                new SqlParameter("@OrderID", OrderID)
            };

            DataSet dsDetails = utils.ReturnDataset(oParams, "sp_Get_OrderDetails");

            string sToEmail = utils.ToS(dsDetails.Tables[0].Rows[0]["SellerEmail"]);
            string sToName  = utils.ToS(dsDetails.Tables[0].Rows[0]["SellerName"]);
            string sProduct = utils.ToS(dsDetails.Tables[0].Rows[0]["ProductName"]) + " " + utils.ToS(dsDetails.Tables[0].Rows[0]["ProductOption"]);

            dsDetails.Dispose();
            //send email(s)
            SendEmail(sToEmail, sToName, sProduct, OrderID, utils.ToS(Request.Form["quantity"]));
            SendBuyerEmail(utils.ToS(Request.Form["payer_email"]), utils.ToS(Request.Form["first_name"]) + " " + utils.ToS(Request.Form["last_name"]), sProduct, OrderID, utils.ToS(Request.Form["txn_id"]), utils.ToS(Request.Form["mc_gross"]), utils.ToS(Request.Form["shipping"]), utils.ToS(Request.Form["quantity"]), sGUID);
        }
        else if (strResponse == "INVALID")
        {
            //string sSQL2 = "Insert Into tShop(Shopname,UserID) Values('Test invalid',1)";

            //utils.RunSQLStringQuery(sSQL2);


            //string uploadPath = Server.MapPath("~/uploads");

            //using (StreamWriter writer =
            //new StreamWriter(Path.Combine(uploadPath, "invalid.txt")))
            //{
            //    foreach (string key in Request.Form.Keys)
            //    {
            //        writer.WriteLine(key + ": " + Request.Form[key] + "\r\n");
            //        //Response.Write(key + ": " + Request.Form[key] + "<br/>");
            //    }

            //}
        }
        else
        {
            //string sSQL2 = "Insert Into tShop(Shopname,UserID) Values('Test something else',1)";

            //utils.RunSQLStringQuery(sSQL2);

            //string uploadPath = Server.MapPath("~/uploads");

            //using (StreamWriter writer =
            //new StreamWriter(Path.Combine(uploadPath, "other.txt")))
            //{
            //    foreach (string key in Request.Form.Keys)
            //    {
            //        writer.WriteLine(key + ": " + Request.Form[key] + "\r\n");
            //        //Response.Write(key + ": " + Request.Form[key] + "<br/>");
            //    }

            //}
        }
    }
        private void fnFetchStudent()
        {
            {
                if (txtElgFormNo.Text != "")
                {
                    Elg_FormNo       = txtElgFormNo.Text.Trim();
                    hidIsBlank.Value = Elg_FormNo;
                }

                else
                {
                    Elg_FormNo       = "0-0-0-0";
                    hidIsBlank.Value = "";
                }

                int      cnt = 0;
                string   str = Elg_FormNo;
                int      pos = str.IndexOf('-');
                string[] arr = new string[] { "0", "0", "0", "0" };
                Regex    objNotNaturalPattern = new Regex("^([0-9]){16}$");

                if (objNotNaturalPattern.IsMatch(txtPRN.Text.Trim()))
                {
                    PRNumber = txtPRN.Text.Trim();
                }
                hidPRN.Value = PRNumber;
                InstituteID  = hidInstID.Value;

                while (pos != -1)
                {
                    str = str.Substring(pos + 1);
                    pos = str.IndexOf('-');
                    cnt++;
                }
                if (cnt == 3)
                {
                    arr = new string[4];
                    arr = Elg_FormNo.Split('-');   //UniID = arr[0], InstID = arr[1], Year = arr[2], StudID = arr[3]
                    for (int i = 0; i < 4; i++)
                    {
                        if (arr[i] == "")
                        {
                            arr[i] = "0";
                        }
                    }
                }
                DataSet ds = new DataSet();
                try
                {
                    //if (rbWithInv_Simple.Checked == true)
                    //{
                    //    ds = clsEligibilityDBAccess.Check_IA_Student_Exists_RegStu(arr[0], arr[1], arr[2], arr[3], txtPRN.Text, hidInstID.Value, txtApplicationFrmNo.Text.Trim());
                    //    hidWithOrWithoutInv.Value = "WithInv";
                    //    hidInv.Value = "1";
                    //}

                    //else if (rbWithoutInv_Simple.Checked == true)
                    //{
                    ds = clsEligibilityDBAccess.Check_IA_Student_Exists_bypassInv_RegStu(arr[0], arr[1], arr[2], arr[3], txtPRN.Text, hidInstID.Value, txtApplicationFrmNo.Text.Trim());
                    hidWithOrWithoutInv.Value = "WithoutInv";

                    hidInv.Value = "0";
                    //  }

                    if ((ds.Tables == null || ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0 || ds.Tables[0] == null))
                    {
                        if (hidIsBack.Value != "True")
                        {
                            //***************
                            dgRegPendingStudents1.Visible = false;
                            tblDGRegPendingStudents.Style.Remove("display");
                            tblDGRegPendingStudents.Style.Add("display", "none");
                            lblGridName.Text = "The Student's data with Eligibility Form Number " + txtElgFormNo.Text.Trim() + "  might have processed or haven't uploaded yet.So please check the status to verify.";
                            lblGridName.Style.Remove("display");
                            lblGridName.Style.Add("display", "block");
                            divDGNote.Style.Remove("display");
                            divDGNote.Style.Add("display", "none");
                        }
                        else if (hidIsBack.Value == "True")
                        {
                            // if Student's eligibility is just processed and Simple search is restored and no matching record is found
                            txtElgFormNo.Text        = "";
                            txtPRN.Text              = "";
                            txtApplicationFrmNo.Text = "";
                            hidIsBack.Value          = "False";
                        }
                    }
                    else if (ds.Tables[0].Rows.Count > 0)
                    {
                        hidElgFormNo.Value         = txtElgFormNo.Text.Trim();
                        hidAppFormNo.Value         = ds.Tables[0].Rows[0]["AdmissionFormNo"].ToString();
                        hidpkStudentID.Value       = ds.Tables[0].Rows[0]["pkStudentID"].ToString();
                        hidpkYear.Value            = ds.Tables[0].Rows[0]["pkYear"].ToString();
                        hidpkFacID.Value           = ds.Tables[0].Rows[0]["pkFacID"].ToString();
                        hidpkCrID.Value            = ds.Tables[0].Rows[0]["pkCrID"].ToString();
                        hidpkMoLrnID.Value         = ds.Tables[0].Rows[0]["pkMoLrnID"].ToString();
                        hidpkPtrnID.Value          = ds.Tables[0].Rows[0]["pkPtrnID"].ToString();
                        hidpkBrnID.Value           = ds.Tables[0].Rows[0]["pkBrnID"].ToString();
                        hidpkCrPrDetailsID.Value   = ds.Tables[0].Rows[0]["pkCrPrDetails"].ToString();
                        hidCollElgFlag.Value       = ds.Tables[0].Rows[0]["CollegeEligibilityFlag"].ToString();
                        hidCollElgFlagReason.Value = ds.Tables[0].Rows[0]["Reason"].ToString();
                        hidPRN.Value = ds.Tables[0].Rows[0]["PRN"].ToString();
                        hid_fk_AcademicYr_ID.Value = ds.Tables[0].Rows[0]["fkAcademicYearID"].ToString();

                        //*****************
                        dgRegPendingStudents1.Visible = true;
                        tblDGRegPendingStudents.Style.Remove("display");
                        tblDGRegPendingStudents.Style.Add("display", "block");
                        lblGridName.Style.Remove("display");
                        lblGridName.Style.Add("display", "block");
                        divDGNote.Style.Remove("display");
                        divDGNote.Style.Add("display", "block");
                        //divAcademicYr.Style.Add("display", "none");
                        tblSelect.Style.Add("display", "block");


                        dgRegPendingStudents1.DataSource = ds;
                        dgRegPendingStudents1.DataBind();

                        //lblGrid.Text = "Please click on the Student Name to select the Student whose Eligibility for a particular " + lblCr.Text + " is to be processed";
                        tblDGRegPendingStudents.Attributes.Add("style", "display:block");
                        //******
                        lblGridName.Style.Add("display", "none");

                        if (hidCollElgFlag.Value == "4")
                        {
                            hidElgStatusColl.Value = "1";
                        }

                        else
                        {
                            hidElgStatusColl.Value = "0";
                        }

                        if (ds.Tables[0].Rows[0]["CollegeEligibilityFlag"].ToString() == "1")
                        {
                            hidCollElgFlag.Value       = "1";
                            hidCollElgFlagReason.Value = ds.Tables[0].Rows[0]["Reason"].ToString();
                        }

                        if (ds.Tables[0].Rows[0]["CollegeEligibilityFlag"].ToString() == "2")
                        {
                            hidCollElgFlag.Value = "2";
                        }
                        if (ds.Tables[0].Rows[0]["CollegeEligibilityFlag"].ToString() == "3")
                        {
                            hidCollElgFlag.Value = "3";
                        }
                        if (ds.Tables[0].Rows[0]["CollegeEligibilityFlag"].ToString() == "4")
                        {
                            hidCollElgFlag.Value = "4";
                        }
                        if (ds.Tables[0].Rows[0]["CollegeEligibilityFlag"].ToString() == "5")
                        {
                            hidCollElgFlag.Value = "5";
                        }

                        hidCollElgFlagReason.Value = ds.Tables[0].Rows[0]["Reason"].ToString();

                        // Commented by Shivani Server.Transfer("ELGV2_ManualProcess_reg_Students__2.aspx?Search=" + searchType.ToString() + "&withORWithoutInv=" + withORWithoutInv.ToString());
                    }

                    else
                    {
                        //***************
                        dgRegPendingStudents1.Visible = false;
                        tblDGRegPendingStudents.Style.Remove("display");
                        tblDGRegPendingStudents.Style.Add("display", "none");
                        lblGridName.Text = "Please Enter the Valid Eligibility Form Number.";
                        lblGridName.Style.Remove("display");
                        lblGridName.Style.Add("display", "block");
                        divDGNote.Style.Remove("display");
                        divDGNote.Style.Add("display", "none");
                    }
                }

                catch (Exception ex)
                {
                    // throw new Exception(ex.Message);
                }
                finally
                {
                    ds.Dispose();
                }
            }
        }
    public string getDatosDialogo(bool bSoloTextos, int nIdDialogo, bool bEsGestor)
    {
        string sResultado = "";

        try
        {
            DataSet ds = DIALOGOALERTAS.ObtenerDialogoAlerta(nIdDialogo, int.Parse(Session["NUM_EMPLEADO_ENTRADA"].ToString()), bEsGestor);
            #region Datos cabecera del diálogo
            if (!bSoloTextos)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow oFila = ds.Tables[0].Rows[0];
                    txtIdDialogo.Text = ((int)oFila["t831_iddialogoalerta"]).ToString("#,###");
                    if (oFila["t831_flr"] != DBNull.Value)
                    {
                        txtFLR.Text = ((DateTime)oFila["t831_flr"]).ToShortDateString();
                    }
                    txtProyecto.Text = ((int)oFila["t301_idproyecto"]).ToString("#,###") + " - " + oFila["t301_denominacion"].ToString();

                    string sTooltip = "<label style=width:70px;>Proyecto:</label>" + ((int)oFila["t301_idproyecto"]).ToString("#,###") + " - " + oFila["t301_denominacion"].ToString().Replace("\"", "&#34;").Replace(((char)39).ToString(), "&#39;"); //(char)34, (char)39
                    sTooltip += "<br><label style=width:70px;>Responsable:</label>" + oFila["Responsable"].ToString().Replace("\"", "&#34;");
                    sTooltip += "<br><label style=width:70px;>Interlocutor:</label>" + oFila["Interlocutor"].ToString().Replace("\"", "&#34;");
                    sTooltip += "<br><label style=width:70px;>" + Estructura.getDefCorta(Estructura.sTipoElem.NODO) + ":</label>" + oFila["t303_denominacion"].ToString().Replace("\"", "&#34;").Replace(((char)39).ToString(), "&#39;");
                    sTooltip += "<br><label style=width:70px;>Cliente:</label>" + oFila["t302_denominacion"].ToString().Replace("\"", "&#34;").Replace(((char)39).ToString(), "&#39;");

                    txtProyecto.Attributes.Add("onmouseover", "showTTE('" + Utilidades.escape(sTooltip) + "');");
                    txtProyecto.Attributes.Add("onmouseout", "hideTTE();");


                    txtAsunto.Text             = oFila["t820_denominacion"].ToString();
                    txtEstado.Text             = oFila["t827_denominacion"].ToString();
                    txtEstado.ToolTip          = oFila["t827_descripcion"].ToString();
                    hdnIdEstado.Value          = oFila["t827_idestadodialogoalerta"].ToString();
                    hdnEntePromotor.Value      = oFila["t831_entepromotor"].ToString();
                    hdnIdResponsableProy.Value = oFila["t314_idusuario_responsable"].ToString();
                    txtMes.Text        = (oFila["t831_anomesdecierre"] != DBNull.Value)? Fechas.AnnomesAFechaDescLarga((int)oFila["t831_anomesdecierre"]) :"";
                    hdnIdDAlerta.Value = oFila["t820_idalerta"].ToString();
                    //if (oFila["t314_idusuario_responsable"].ToString() == Session["UsuarioActual"].ToString())
                    //    sEsResponsableProyecto = "true";
                    if ((bool)oFila["bInterlocutor"])
                    {
                        sEsInterlocutorProyecto = "true";
                    }
                }
            }
            #endregion

            #region Textos del diálogo
            StringBuilder sb         = new StringBuilder();
            DateTime      dtAux      = DateTime.Parse("01/01/1900");
            string        sCellWidth = "";

            sb.Append("<table id='tblTextos' class='texto' style='width:880px; background-color:#ece4de' cellspacing='0' cellpadding='0' border='0'>");
            sb.Append(@"<colgroup>
                            <col style='width:60px;' />
                            <col style='width:160px;' />
                            <col style='width:220px;' />
                            <col style='width:220px;' />
                            <col style='width:160px;' />
                            <col style='width:60px;' />
                        </colgroup>");

            foreach (DataRow oFila in ds.Tables[1].Rows)
            {
                sCellWidth = (oFila["t832_texto"].ToString().Length > 40) ? "455px" : (oFila["t832_texto"].ToString().Length * 11).ToString() + "px";

                if (((DateTime)oFila["t832_fechacreacion"]).ToShortDateString() != dtAux.ToShortDateString())
                {
                    dtAux = (DateTime)oFila["t832_fechacreacion"];
                    sb.Append("<tr>");
                    sb.Append("<td colspan='6' style='padding-top:4px;'>");
                    sb.Append("<div style='margin-left:270px; width:300px; height:34px; background-image:url(../../../../Images/imgFondoFecha.gif);background-repeat:no-repeat; text-align:center; padding-top:8px; font-size:13pt;'>" + ((DateTime)oFila["t832_fechacreacion"]).ToLongDateString() + "</div>");
                    sb.Append("</td>");
                    sb.Append("</tr>");
                }

                sb.Append("<tr>");
                if (oFila["t832_posicion"].ToString() == "I")
                {
                    sb.Append("<td style='vertical-align:bottom; padding-bottom: 10px;'>");

                    if (oFila["t001_idficepi"] == DBNull.Value)
                    {
                        sb.Append(@"<img src='../../../../Images/imgDiamanteDialogo.png' style='width:60px; height:90px;' border='0' />");
                    }
                    else
                    {
                        sb.Append(@"<img src='" + (((int)oFila["tiene_foto"] == 0) ? "../../../../Images/imgSmile.gif" : "../../../Inicio/ObtenerFotoByFicepi.aspx?nF=" + oFila["t001_idficepi"].ToString()) + @"' style='width:60px; height:auto;' border='0' />");
                    }
                    sb.Append(@"<nobr class='NBR W60' style='text-align:center' title='" + oFila["Profesional"].ToString() + @"'>" + oFila["t001_nombre"].ToString() + @"</nobr>");

                    sb.Append("</td>");

                    sb.Append("<td colspan='3' style='padding-left:5px;'>");
                    sb.Append(@"<table class='texto' style='float:left; margin-bottom:20px;' cellspacing='0' cellpadding='0' border='0'>
                            <tr style='height:9px;'>
                                <td background='../../../../Images/Tabla/ConvIzda/1.gif' style='width:34px;'></td>
                                <td background='../../../../Images/Tabla/ConvIzda/2.gif' style='width:" + sCellWidth + @";'></td>
                                <td background='../../../../Images/Tabla/ConvIzda/3.gif' style='width:81px; height:9px;background-repeat:no-repeat;'></td>
                            </tr>
                            <tr>
                                <td background='../../../../Images/Tabla/ConvIzda/4.gif' style='width:34px;'>&nbsp;</td>
                                <td background='../../../../Images/Tabla/ConvIzda/5.gif' style='font-size:11pt; width:" + sCellWidth + @";'>
                                    <!-- Inicio del contenido propio de la tabla -->
                                    " + oFila["t832_texto"].ToString().Replace(((char)10).ToString(), "<br>") + @"
                                    <!-- Fin del contenido propio de la tabla -->
                                </td>
                                <td background='../../../../Images/Tabla/ConvIzda/6.gif' style='width:81px;background-repeat:repeat-y;'></td>
                            </tr>
                            <tr style='height:55px;'>
                                <td background='../../../../Images/Tabla/ConvIzda/7.gif' style='width:34px;'></td>
                                <td background='../../../../Images/Tabla/ConvIzda/8.gif' style='width:" + sCellWidth + @";'></td>
                                <td background='../../../../Images/Tabla/ConvIzda/9.gif' style='width:81px; font-size:13pt; vertical-align:top; padding-left:15px; padding-top:10px; background-repeat:no-repeat;'>" + Fechas.HoraACadenaLarga((DateTime)oFila["t832_fechacreacion"]) + @"</td>
                            </tr>
                        </table>");
                    sb.Append("</td>");
                    sb.Append("<td colspan='2'></td>");
                }
                else //lado derecho
                {
                    sb.Append("<td colspan='2'></td>");
                    sb.Append("<td colspan='3' style='text-align:right; padding-right:5px;'>");// vertical-align: text-bottom;
                    //sb.Append("<img src='../../../../Images/imgW2.gif' />");

                    sb.Append(@"<table class='texto' style='table-layout:fixed; float:right; margin-bottom:20px;' cellspacing='0' cellpadding='0' border='0'>
                        <tr style='height:11px;'>
                            <td background='../../../../Images/Tabla/ConvDcha/1.gif' style='width:80px;'></td>
                            <td background='../../../../Images/Tabla/ConvDcha/2.gif' style='width:" + sCellWidth + @";'></td>
                            <td background='../../../../Images/Tabla/ConvDcha/3.gif' style='width:37px;'></td>
                        </tr>
                        <tr>
                            <td background='../../../../Images/Tabla/ConvDcha/4.gif' style='width:80px;'>&nbsp;</td>
                            <td background='../../../../Images/Tabla/ConvDcha/5.gif' style='font-size:11pt; text-align: left;width:" + sCellWidth + @";'>
                                <!-- Inicio del contenido propio de la tabla -->" +
                              oFila["t832_texto"].ToString().Replace(((char)10).ToString(), "<br>") + @"
                                <!-- Fin del contenido propio de la tabla -->
                            </td>
                            <td background='../../../../Images/Tabla/ConvDcha/6.gif' style='width:37px;'></td>
                        </tr>
                        <tr style='height:54px;'>
                            <td background='../../../../Images/Tabla/ConvDcha/7.gif' 
                                style='width:80px; font-size:13pt; vertical-align:top; padding-top:10px;'>
                                <span style='margin-right:15px;'>" + Fechas.HoraACadenaLarga((DateTime)oFila["t832_fechacreacion"]) + @"</span></td>
                            <td background='../../../../Images/Tabla/ConvDcha/8.gif' style='width:" + sCellWidth + @";'></td>
                            <td background='../../../../Images/Tabla/ConvDcha/9.gif' style='width:37px;'></td>
                        </tr>
                        </table>");

                    sb.Append("</td>");
                    sb.Append("<td style='vertical-align:bottom; padding-bottom: 10px;'>");

                    if (oFila["t001_idficepi"] == DBNull.Value)
                    {
                        sb.Append(@"<img src='../../../../Images/imgDiamanteDialogo.png' style='width:60px; height:90px;' border='0' />");
                    }
                    else
                    {
                        sb.Append(@"<img src='" + (((int)oFila["tiene_foto"] == 0) ? "../../../../Images/imgSmile.gif" : "../../../Inicio/ObtenerFotoByFicepi.aspx?nF=" + oFila["t001_idficepi"].ToString()) + @"' style='width:60px; height:auto;' border='0' />");
                    }
                    sb.Append(@"<nobr class='NBR W60' style='text-align:center' title='" + oFila["Profesional"].ToString() + @"'>" + oFila["t001_nombre"].ToString() + @"</nobr>");
                    sb.Append("</td>");
                }
                sb.Append("</tr>");
            }
            ds.Dispose();
            sb.Append("</table>");

            sResultado = "OK@#@" + sb.ToString();

            #endregion
        }
        catch (Exception ex)
        {
            sResultado = "Error@#@" + Errores.mostrarError("Error al obtener los datos del diálogo.", ex);
        }
        return(sResultado);
    }
    private void ReportQuery()
    {
        string constr = "";

        if (txt_sampleQuery.Text.Trim() != "")
        {
            constr += " and t_M_SampleInfor.SampleID like '%" + txt_sampleQuery.Text.Trim() + "%'";
        }
        if (txt_QueryTime.Text.Trim() != "")
        {
            constr += " and  (year(AccessDate)= '" + DateTime.Parse(txt_QueryTime.Text.Trim() + " 00:00:00").Year + "' AND month(AccessDate)= '" + DateTime.Parse(txt_QueryTime.Text.Trim() + " 00:00:00").Month + "' and day(AccessDate)= '" + DateTime.Parse(txt_QueryTime.Text.Trim() + " 00:00:00").Day + "')";
        }
        if (txt_Itemquery.Text.Trim() != "")
        {
            constr += " and (t_M_ANItemInf.AIName like '%" + txt_Itemquery.Text.Trim() + "%' or LOWER(t_M_ANItemInf.AICode) like '%LOWER(" + txt_Itemquery.Text.Trim() + ")%')";
        }

        string strSql = "select t_MonitorItemDetail.id, t_MonitorItemDetail.MonitorItem,t_M_ANItemInf.AIName 监测项,t_M_SampleInfor.SampleID AS 样品编号,t_M_ReporInfo.Ulevel ,t_M_SampleInfor.SampleAddress 采样点 ,t_M_SampleInfor.SampleDate AS 采样时间," +
                        "t_M_SampleInfor.AccessDate AS 接样时间, " +
                        " t_M_SampleInfor.TypeID, t_M_AnalysisMainClassEx.ClassName AS 样品类型,t_M_SampleInfor.SampleProperty 样品性状,ProjectName 项目名称," +
                        " t_M_ReporInfo.chargeman 项目负责人,t_MonitorItemDetail.zpto,t_MonitorItemDetail.flag,t_M_SampleInfor.id " +
                        " FROM t_M_ReporInfo inner join  t_M_SampleInfor on t_M_ReporInfo.id=t_M_SampleInfor.ReportID  INNER JOIN" +
                        " t_M_AnalysisMainClassEx ON " +
                        "  t_M_SampleInfor.TypeID = t_M_AnalysisMainClassEx.ClassID inner join t_MonitorItemDetail on t_MonitorItemDetail.SampleID=t_M_SampleInfor.id and t_MonitorItemDetail.delflag=0  inner join t_M_ANItemInf on t_M_ANItemInf.id=t_MonitorItemDetail.MonitorItem where t_MonitorItemDetail.flag=" + drop_status.SelectedValue.ToString() + " and t_M_SampleInfor.StatusID=1  " + constr + " ORDER BY t_M_SampleInfor.AccessDate";

        ds = new MyDataOp(strSql).CreateDataSet();
        DataColumn dcc = new DataColumn("紧急程度");

        ds.Tables[0].Columns.Add(dcc);


        string  str    = "select * from t_R_UserInfo";
        DataSet dsuser = new MyDataOp(str).CreateDataSet();

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            DataRow[] druser = dsuser.Tables[0].Select("userid='" + dr["项目负责人"] + "'");
            if (druser.Length > 0)
            {
                dr["项目负责人"] = druser[0]["Name"].ToString();
            }

            if (dr["Ulevel"].ToString() == "1")
            {
                dr["紧急程度"] = "紧急";
            }
            else
            {
                dr["紧急程度"] = "一般";
            }


            //if (dr["StatusID"].ToString() == "0")
            //    dr["样品状态"] = "登记中";
            //else
            //    dr["样品状态"] = "已提交";
        }
        if (ds.Tables[0].Rows.Count == 0)
        {
            //没有记录仍保留表头
            ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
            grdvw_List.DataSource = ds;
            grdvw_List.DataBind();
            int intColumnCount = grdvw_List.Rows[0].Cells.Count;
            grdvw_List.Rows[0].Cells.Clear();
            grdvw_List.Rows[0].Cells.Add(new TableCell());
            grdvw_List.Rows[0].Cells[0].ColumnSpan = intColumnCount;
        }
        else
        {
            grdvw_List.DataSource = ds;
            grdvw_List.DataBind();
        }
        ds.Dispose();
    }
Пример #44
0
        //第一种生成订单编号的方法
        public static string ddbh(string bs, string rq, string counter, int lsmcd)
        {
            int    a; int c; int id;
            string b = ""; string d = "";
            string ddbhyy    = "";
            string counteryy = "";
            string rqyy      = "";
            string qybh      = common_file.common_app.qybh;

            BLL.Common B_Common = new Hotel_app.BLL.Common();
            DataSet    DS_temp  = B_Common.GetList("select * from Qcounter", "id>=0" + common_file.common_app.yydh_select);

            if (DS_temp != null && DS_temp.Tables[0].Rows.Count > 0)
            {
                counteryy = DS_temp.Tables[0].Rows[0][counter].ToString();
                rqyy      = DS_temp.Tables[0].Rows[0][rq].ToString();
            }

            if (counteryy == "")
            {
                B_Common.ExecuteSql("update Qcounter set " + rq + "='" + DateTime.Today.ToString() + "'," + counter + "=0 where id>=0" + common_file.common_app.yydh_select);
            }
            else
            {
                if (Convert.ToDateTime(rqyy) == DateTime.Today)
                {
                    c = Convert.ToInt32(counteryy);
                    c = c + 1;
                    B_Common.ExecuteSql("update Qcounter set " + counter + "=" + c.ToString() + " where id>=0" + common_file.common_app.yydh_select);
                }
                else
                {
                    B_Common.ExecuteSql("update Qcounter set " + rq + "='" + DateTime.Today.ToString() + "'," + counter + "=0 where id>=0" + common_file.common_app.yydh_select);
                }

                DS_temp = B_Common.GetList("select * from Qcounter", "id>=0" + common_file.common_app.yydh_select);
                if (DS_temp != null && DS_temp.Tables[0].Rows.Count > 0)
                {
                    counteryy = DS_temp.Tables[0].Rows[0][counter].ToString();
                    rqyy      = DS_temp.Tables[0].Rows[0][rq].ToString();
                }
                a = counteryy.ToString().Length;
                b = lsm(a, lsmcd);
                d = DateTime.Today.Year.ToString();
                if (DateTime.Today.Month.ToString().Length == 1)
                {
                    d = d + "0";
                }
                d = d + DateTime.Today.Month.ToString();
                if (DateTime.Today.Day.ToString().Length == 1)
                {
                    d = d + "0";
                }
                d      = d + DateTime.Today.Day.ToString();
                d      = d + DateTime.Now.Hour.ToString();
                d      = d + DateTime.Now.Minute.ToString();
                d      = d + DateTime.Now.Second.ToString();
                ddbhyy = qybh + bs + d + b + counteryy.ToString();
            }

            DS_temp.Dispose();
            return(ddbhyy);
        }
Пример #45
0
 public void Dispose()
 {
     _dataSet?.Dispose();
 }
Пример #46
0
        public static List <AutoInfoMaster> AutoInfoMaster_selectall()
        {
            SQLHelper             dbo       = new SQLHelper();
            DataSet               ds        = new DataSet();
            List <AutoInfoMaster> modellist = new List <AutoInfoMaster>();

            try
            {
                SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("action", "selectall"),
                };

                ds = dbo.RunProcedure("usp_AutoInfoMaster", parameters, "AutoFeatures");
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        AutoInfoMaster model = new AutoInfoMaster();
                        model.Id              = Convert.ToInt32(dr["Id"]);
                        model.AutoDealerId    = Convert.ToInt32(dr["AutoDealerId"]);
                        model.AutoDealerName  = Convert.ToString(dr["AutoDealerName"]);
                        model.AutoName        = Convert.ToString(dr["AutoName"]);
                        model.AutoDescription = Convert.ToString(dr["AutoDescription"]);
                        model.AutoLocation    = Convert.ToString(dr["AutoLocation"]);
                        model.AutoMake        = Convert.ToString(dr["AutoMake"]);
                        model.AutoModel       = Convert.ToString(dr["AutoModel"]);
                        model.Price           = Convert.ToString(dr["Price"]);
                        model.Year            = Convert.ToInt32(dr["Year"]);
                        model.Kilometers      = Convert.ToInt32(dr["Kilometers"]);
                        model.AutoType        = Convert.ToString(dr["AutoType"]);
                        model.Color           = Convert.ToString(dr["Color"]);
                        model.InteriorColor   = Convert.ToString(dr["InteriorColor"]);
                        model.GearBox         = Convert.ToString(dr["GearBox"]);
                        model.Seats           = Convert.ToInt32(dr["Seats"]);
                        model.Specs           = Convert.ToString(dr["Specs"]);
                        model.Doors           = Convert.ToInt32(dr["Doors"]);
                        model.Cylinders       = Convert.ToInt32(dr["Cylinders"]);
                        model.Wheels          = Convert.ToInt32(dr["Wheels"]);
                        model.FuelType        = Convert.ToString(dr["FuelType"]);
                        model.IsActive        = Convert.ToBoolean(dr["IsActive"]);
                        if (dr["CreatedDateTime"] != DBNull.Value)
                        {
                            model.CreatedDateTime = Convert.ToDateTime(dr["CreatedDateTime"]);
                        }
                        model.CreatedBy = Convert.ToString(dr["CreatedBy"]);
                        if (dr["UpdatedDateTime"] != DBNull.Value)
                        {
                            model.UpdatedDateTime = Convert.ToDateTime(dr["UpdatedDateTime"]);
                        }
                        model.UpdatedBy      = Convert.ToString(dr["UpdatedBy"]);
                        model.FirstImage     = Convert.ToString(dr["FirstImage"]);
                        model.DealerImage    = Convert.ToString(dr["DealerImage"]);
                        model.AutoFeatures   = Convert.ToString(dr["AutoFeatures"]);
                        model.AutoLatitude   = Convert.ToString(dr["AutoLatitude"]);
                        model.AutoLongitude  = Convert.ToString(dr["AutoLongitude"]);
                        model.AutoMakeId     = Convert.ToInt32(dr["AutoMakeId"]);
                        model.Comments       = Convert.ToString(dr["Comments"]);
                        model.AutoModelId    = Convert.ToInt32(dr["AutoModelId"]);
                        model.AutoFolderPath = Convert.ToString(dr["AutoFolderPath"]);
                        model.Condition      = Convert.ToString(dr["Condition"]);
                        model.AutoTypeId     = Convert.ToInt32(dr["AutoTypeId"]);
                        modellist.Add(model);
                    }
                }
                return(modellist);
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Error Occured in " + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString() + " Error Message: " + ex.Message);
            }
            finally
            {
                if (ds != null)
                {
                    ds.Dispose();
                }

                if (modellist != null)
                {
                    modellist = null;
                }
            }
        }
    public void BindStaff()
    {
        try
        {
            string getcolcode = rs.GetSelectedItemsValueAsString(cbl_clg);
            string deptcode   = "";
            for (int item = 0; item < cbl_dept.Items.Count; item++)
            {
                if (cbl_dept.Items[item].Selected == true)
                {
                    if (deptcode == "")
                    {
                        deptcode = cbl_dept.Items[item].Value;
                    }
                    else
                    {
                        deptcode = deptcode + ',' + cbl_dept.Items[item].Value;
                    }
                }
            }
            if (deptcode != "")
            {
                deptcode = "and st.dept_code in(" + deptcode + ")";
            }

            string designcode = "";
            for (int item = 0; item < cbl_desig.Items.Count; item++)
            {
                if (cbl_desig.Items[item].Selected == true)
                {
                    if (designcode == "")
                    {
                        designcode = "'" + cbl_desig.Items[item].Value + "'";
                    }
                    else
                    {
                        designcode = designcode + ',' + "'" + cbl_desig.Items[item].Value + "'";
                    }
                }
            }
            if (designcode != "")
            {
                designcode = "and st.desig_code in(" + designcode + ")";
            }

            string catecode = "";
            for (int item = 0; item < cbl_staffc.Items.Count; item++)
            {
                if (cbl_staffc.Items[item].Selected == true)
                {
                    if (catecode == "")
                    {
                        catecode = "'" + cbl_staffc.Items[item].Value + "'";
                    }
                    else
                    {
                        catecode = catecode + ',' + "'" + cbl_staffc.Items[item].Value + "'";
                    }
                }
            }
            if (catecode != "")
            {
                catecode = " and st.category_code in(" + catecode + ")";
            }
            string type = "";
            for (int item = 0; item < cbl_stype.Items.Count; item++)
            {
                if (cbl_stype.Items[item].Selected == true)
                {
                    if (type == "")
                    {
                        type = "'" + cbl_stype.Items[item].Value + "'";
                    }
                    else
                    {
                        type = type + ',' + "'" + cbl_stype.Items[item].Value + "'";
                    }
                }
            }
            if (type != "")
            {
                type = " and st.stftype in(" + type + ")";
            }

            string strstaffquery = "select distinct sm.staff_name,st.staff_code from stafftrans st,staffmaster sm where st.staff_code=sm.staff_code and sm.settled=0 and sm.resign=0 and st.latestrec=1 " + deptcode + " " + designcode + " " + catecode + " " + type + " and college_code in('" + getcolcode + "')";
            ds.Dispose();
            ds.Reset();
            ds = d2.select_method(strstaffquery, hat, "Text");
            cbl_staffCode.DataSource     = ds;
            cbl_staffCode.DataTextField  = "staff_name";
            cbl_staffCode.DataValueField = "staff_code";
            cbl_staffCode.DataBind();
            for (int item = 0; item < cbl_staffCode.Items.Count; item++)
            {
                cbl_staffCode.Items[item].Selected = true;
            }

            if (cbl_staffCode.Items.Count > 0)
            {
                cb_staffCode.Checked = true;
                txt_staffCode.Text   = "Staff (" + cbl_staffCode.Items.Count + ")";
            }
            else
            {
                cb_staffCode.Checked = false;
                txt_staffCode.Text   = "---Select---";
            }
        }
        catch (Exception ex)
        {
        }
    }
Пример #48
0
        public JsonResult PrimarySalesUpload()
        {
            string Calendardata         = Request["CalendarMonth"];
            string Type                 = Request["UploadType"];
            string Monthname            = Calendardata.Substring(0, Calendardata.IndexOf("-"));
            int    SelectedMonth        = DateTime.ParseExact(Monthname, "MMM", new CultureInfo("en-US")).Month;
            string Yearnumber           = Calendardata.Substring(Calendardata.IndexOf("-") + 1);
            int    SelectedYear         = Int32.Parse(Yearnumber);
            int    UploadType           = Int32.Parse(Type);
            HttpFileCollectionBase file = Request.Files;

            if (Request.Files.Count > 0 && Request.Files[0].FileName.EndsWith(".xls"))
            {
                try
                {
                    Ds = new DataSet();
                    Ds = ExcelImport.ImportExcelXML(Request.Files[0], true, false);

                    // return Json(size);
                    //DataSet dsMaster = new DataSet();
                    //dsMaster = Bl.GetPrimarySalesMasterData("MASTER_VALIDATE");
                    // Excel to temp table



                    //File Name Validation
                    //if (Ds_Validate.Tables[0].Rows.Count > 0)
                    //{
                    //    foreach (DataRow row_val in Ds_Validate.Tables[0].Rows)
                    //    {
                    //        //validating filename
                    //        if (file.FileName.ToString() == row_val["Uploaded_file_name"].ToString()) //&&
                    //            return Json("FileExists");

                    //    }
                    //}

                    //Excel Row No check


                    //Header sheet - column name Validation
                    var      xlHDRColumnNames = Ds.Tables[0].Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToArray <string>();
                    string[] HeaderColumns    = new string[] { "Depot_Name", "Region_Name", "Region_Ref_Key",
                                                               "Stockiest_Name", "Stockiest_Ref_Key", "Document_Type_Name", "Document_Number", "Document_Date",
                                                               "Product_Name", "Product_Ref_Key", "Batch_Number", "Net_Quantity", "Free_Quantity", "Net_Value", "Excel_Row_No" };
                    bool ValidHdrColumns = false;
                    //if (xlHDRColumnNames.Any())
                    //{
                    //    ValidHdrColumns = xlHDRColumnNames.SequenceEqual(HeaderColumns);
                    //    if (!ValidHdrColumns)
                    //    {
                    //        return Json("HeaderInvalidColumns");
                    //    }
                    //}

                    for (int i = 0; i < xlHDRColumnNames.Length; i++)
                    {
                        for (int j = 0; j < HeaderColumns.Length; j++)
                        {
                            if (xlHDRColumnNames[i] == HeaderColumns[j])
                            {
                                ValidHdrColumns = true;
                            }
                        }
                    }
                    if (!ValidHdrColumns)
                    {
                        return(Json("DetailsInvalidColumns"));
                    }

                    foreach (DataRow row_xl in Ds.Tables[0].Rows)
                    {
                        DateTime dtFormat;
                        if ((!DateTime.TryParseExact(row_xl["Document_Date"].ToString().Trim(), "yyyy-MM-dd", new CultureInfo("en-GB"), DateTimeStyles.None, out dtFormat)))
                        {
                            //DataFormatInvalid = true;
                            return(Json("Please update Date format should be YYYY-MM-DD"));
                        }
                        string docdate     = row_xl["Document_Date"].ToString();
                        int    docYear     = Int32.Parse(docdate.Substring(0, docdate.IndexOf("-")));
                        string NameofMonth = DateTime.ParseExact(row_xl["Document_Date"].ToString(), "yyyy-MM-dd", null).ToString("MMMM");
                        int    docMonth    = DateTimeFormatInfo.CurrentInfo.MonthNames.ToList().IndexOf(NameofMonth) + 1;
                        if (docMonth != SelectedMonth || docYear != SelectedYear)
                        {
                            return(Json("Month and Year Of Document Date in Excel Should be Same as Selected Month and Year in dropdown"));
                        }
                    }
                    //Details sheet - column name Validation
                    //var xlDTLColumnNames = Ds.Tables[1].Columns.Cast<DataColumn>().Select(x => x.ColumnName).ToArray<string>();
                    //string[] DetailColumns = new string[] {"Region_Name", "Depot_Name", "Stockiest_Ref_Key1", "Document_Type",
                    //                                      "Document_Number","Document_Date","Transaction_Mode","Product_Name","Product_Ref_Key1",
                    //                                           "Batch_Number", "Sales_Quantity", "Free_Quantity", "Sales_Rate"};
                    //bool ValidDTLColumns = true;
                    //if (xlDTLColumnNames.Any())
                    //{
                    //    ValidDTLColumns = xlDTLColumnNames.SequenceEqual(DetailColumns);
                    //    if (!ValidDTLColumns)
                    //    {
                    //        return Json("DetailInvalidColumns");
                    //    }
                    //}

                    //asynchronous method call
                    string CompanyCode      = _objCurrentInfo.GetCompanyCode();
                    string UserCode         = _objCurrentInfo.GetUserCode();
                    string ConnectionString = _objCurrentInfo.GetConnectionString();
                    string SubDomain        = _objCurrentInfo.GetSubDomain();
                    string strGuid          = Guid.NewGuid().ToString();
                    Task   task             = Task.Factory.StartNew(() =>
                    {
                        if (PrimarySalesTempUpload(CompanyCode, Ds.Tables[0], UserCode, ConnectionString, strGuid) == true)
                        {
                            //   ProcessPrimarySalesUpload(Ds, Ds_Validate, dsMaster, file.FileName.ToString(), CompanyCode, UserCode, ConnectionString, SubDomain);
                            PrimarySalesValidation(CompanyCode, UserCode, strGuid, Request.Files[0].FileName.ToString(), ConnectionString, SelectedMonth, SelectedYear, UploadType);
                        }
                    });

                    return(Json("Uploaded"));
                }
                catch (Exception ex)
                {
                    return(Json("Not Uploaded"));
                }
                finally
                {
                    Ds.Dispose();
                    //Ds_Validate.Dispose();
                }
            }
            else
            {
                return(Json("Invalid File"));
            }
            //return Json("Not Uploaded");
        }
    protected void btngo_Click(object sender, EventArgs e)
    {
        try
        {
            lblgrperr.Text = "";
            ds.Dispose();
            ds = da.select_method("select * from sysobjects where name='tbl_DeptGrouping' and Type='U'", hat, "text ");
            if (ds.Tables[0].Rows.Count > 0)
            {
            }
            else
            {
                int p = da.insert_method(" create table tbl_DeptGrouping (Groupcode nvarchar(100),Deptcode nvarchar(100),type nvarchar(100),college_code nvarchar(100))", hat, "text");
            }
            hide();
            lblerrormsg.Visible = true;
            FpSpread2.Sheets[0].RowHeader.Visible = false;
            FpSpread2.Sheets[0].Rows.Count        = 0;
            FpSpread2.SaveChanges();
            FpSpread2.CommandBar.Visible = false;
            string groupnn = "";
            if (ddltitlename.Items.Count > 0)
            {
                groupnn = ddltitlename.SelectedItem.Value.ToString();
                groupnn = " and Groupcode ='" + groupnn + "'";
            }
            else
            {
                lblerrmsg2.Text    = "Please Create Atleast One group";
                lblerrmsg2.Visible = true;
                return;
            }
            FpSpread2.Sheets[0].ColumnCount           = 3;
            FpSpread2.Sheets[0].ColumnHeader.RowCount = 1;
            FpSpread2.Sheets[0].AutoPostBack          = false;
            FpSpread2.Sheets[0].Columns[0].Locked     = true;
            FpSpread2.Sheets[0].Columns[1].Locked     = true;
            darkStyle.Font.Bold       = true;
            darkStyle.Font.Name       = "Book Antiqua";
            darkStyle.Font.Size       = FontUnit.Medium;
            darkStyle.HorizontalAlign = HorizontalAlign.Center;
            darkStyle.BackColor       = ColorTranslator.FromHtml("#0CA6CA");
            darkStyle.ForeColor       = Color.Black;
            FpSpread2.Sheets[0].ColumnHeader.DefaultStyle     = darkStyle;
            FpSpread2.Sheets[0].ColumnHeader.Cells[0, 0].Text = "S.No";
            FpSpread2.Sheets[0].ColumnHeader.Cells[0, 1].Text = "Deptartment Name";

            FpSpread2.Sheets[0].ColumnHeader.Cells[0, 2].Text = "Select";
            FpSpread2.Sheets[0].Columns[0].HorizontalAlign    = HorizontalAlign.Center;
            FpSpread2.Sheets[0].Columns[2].HorizontalAlign    = HorizontalAlign.Center;
            FpSpread2.Sheets[0].Columns[0].Locked             = true;
            FpSpread2.Sheets[0].Columns[1].Locked             = true;
            FpSpread2.Sheets[0].Columns[0].Width = 40;
            FpSpread2.Sheets[0].Columns[1].Width = 220;
            FpSpread2.Sheets[0].Columns[2].Width = 50;
            //FpSpread1.Sheets[0].Columns[2].Locked = true;

            //FpSpread2.Sheets[0].Columns[2].Locked = true;

            //bindsubjectpdf();
            FpSpread2.Sheets[0].RowCount = 0;

            FpSpread2.SaveChanges();
            count = 0;

            collegecode = ddlcollege.SelectedValue.ToString();
            for (int i = 0; i < chklstdegree.Items.Count; i++)
            {
                if (chklstdegree.Items[i].Selected == true)
                {
                    if (course_id == "")
                    {
                        course_id = "" + chklstdegree.Items[i].Value.ToString() + "";
                    }
                    else
                    {
                        course_id = course_id + "," + "" + chklstdegree.Items[i].Value.ToString() + "";
                    }
                }
            }

            if (group_user.Contains(';'))
            {
                string[] group_semi = group_user.Split(';');
                group_user = group_semi[0].ToString();
            }
            ds2.Dispose();
            ds2.Reset();
            if (course_id.Trim() != "")
            {
                if (course_id.ToString().Trim() != "")
                {
                    if (singleuser == "True")
                    {
                        ds2.Dispose();
                        ds2.Reset();
                        string strquery = "select distinct department.dept_name,department.dept_code from degree,department,course,deptprivilages where course.course_id=degree.course_id and department.dept_code=degree.dept_code and course.college_code = degree.college_code and department.college_code = degree.college_code and degree.course_id in(" + course_id + ") and degree.college_code=" + collegecode + "  and deptprivilages.Degree_code=degree.Degree_code and user_code=" + usercode + " ";
                        ds2 = da.select_method_wo_parameter(strquery, "Text");
                    }
                    else
                    {
                        ds2.Dispose();
                        ds2.Reset();
                        string strquery1 = "select distinct department.dept_name,department.dept_code from degree,department,course,deptprivilages where course.course_id=degree.course_id and department.dept_code=degree.dept_code and course.college_code = degree.college_code and department.college_code = degree.college_code and degree.course_id in(" + course_id + ") and degree.college_code=" + collegecode + "  and deptprivilages.Degree_code=degree.Degree_code and group_code=" + group_user + "";
                        ds2 = da.select_method_wo_parameter(strquery1, "Text");
                    }
                }
                if (ds2.Tables[0].Rows.Count > 0)
                {
                    ds.Clear();
                    string slq = " select Deptcode,(select dept_name from Department d where tbl_DeptGrouping.Deptcode=d.dept_code)dept_name,(select textval from textvaltable t where tbl_DeptGrouping.Groupcode=t.TextCode)as grp  from tbl_DeptGrouping where type='" + ddltype.SelectedItem.Text.ToString() + "' and college_code='" + ddlcollege.SelectedItem.Value.ToString() + "' " + groupnn + "";

                    ds  = da.select_method_wo_parameter(slq, "Text");
                    slq = "";
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        FpSpread2.Sheets[0].Rows.Count++;

                        FpSpread2.Sheets[0].Cells[FpSpread2.Sheets[0].Rows.Count - 1, 0].Text = Convert.ToString(i + 1);
                        // FpSpread2.Sheets[0].Cells[FpSpread2.Sheets[0].Rows.Count - 1, 2].CellType = txtceltype;
                        FpSpread2.Sheets[0].Cells[FpSpread2.Sheets[0].Rows.Count - 1, 1].Text   = Convert.ToString(ds.Tables[0].Rows[i]["dept_name"].ToString());
                        FpSpread2.Sheets[0].Cells[FpSpread2.Sheets[0].Rows.Count - 1, 1].Tag    = Convert.ToString(ds.Tables[0].Rows[i]["Deptcode"].ToString());;
                        FpSpread2.Sheets[0].Cells[FpSpread2.Sheets[0].RowCount - 1, 2].CellType = chkboxcol;

                        if (slq == "")
                        {
                            slq = ds.Tables[0].Rows[i][0].ToString();
                        }
                        else
                        {
                            slq = slq + "','" + ds.Tables[0].Rows[i][0].ToString();
                        }
                    }
                    //if (ds.Tables[0].Rows.Count>0)
                    //{
                    //    ddltitlename.SelectedIndex = ddltitlename.Items.IndexOf(ddltitlename.Items.FindByValue(ds.Tables[0].Rows[0][2].ToString()));
                    //}
                    FpSpread2.Sheets[0].PageSize = FpSpread2.Sheets[0].RowCount;


                    FpSpread2.SaveChanges();
                    if (slq.Trim() != "")
                    {
                        slq = "Dept_code not in ('" + slq + "')";
                        ds2.Tables[0].DefaultView.RowFilter = slq;
                        dv = ds2.Tables[0].DefaultView;
                    }
                    else
                    {
                        dv = ds2.Tables[0].DefaultView;
                    }
                    movdiv.Visible = true;
                    FpSpread1.Sheets[0].RowHeader.Visible = false;

                    FpSpread1.CommandBar.Visible = false;

                    FpSpread1.Sheets[0].ColumnCount           = 3;
                    FpSpread1.Sheets[0].ColumnHeader.RowCount = 1;
                    darkStyle.Font.Bold       = true;
                    darkStyle.Font.Name       = "Book Antiqua";
                    darkStyle.Font.Size       = FontUnit.Medium;
                    darkStyle.HorizontalAlign = HorizontalAlign.Center;
                    darkStyle.BackColor       = ColorTranslator.FromHtml("#0CA6CA");
                    darkStyle.ForeColor       = Color.Black;
                    FpSpread1.Sheets[0].ColumnHeader.DefaultStyle = darkStyle;
                    FpSpread1.Sheets[0].AutoPostBack                  = false;
                    FpSpread1.Sheets[0].Columns[0].Locked             = true;
                    FpSpread1.Sheets[0].Columns[1].Locked             = true;
                    FpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].Text = "S.No";
                    FpSpread1.Sheets[0].ColumnHeader.Cells[0, 1].Text = "Deptartment Name";

                    FpSpread1.Sheets[0].ColumnHeader.Cells[0, 2].Text = "Select";
                    FpSpread1.Sheets[0].Columns[0].HorizontalAlign    = HorizontalAlign.Center;
                    FpSpread1.Sheets[0].Columns[2].HorizontalAlign    = HorizontalAlign.Center;
                    FpSpread1.Sheets[0].Columns[0].Locked             = true;
                    FpSpread1.Sheets[0].Columns[1].Locked             = true;
                    FpSpread1.Sheets[0].Columns[0].Width = 40;
                    FpSpread1.Sheets[0].Columns[1].Width = 220;
                    FpSpread1.Sheets[0].Columns[2].Width = 50;
                    //FpSpread1.Sheets[0].Columns[2].Locked = true;

                    //bindsubjectpdf();
                    FpSpread1.Sheets[0].RowCount = 0;

                    FpSpread1.SaveChanges();
                    for (int ii = 0; ii < dv.Count; ii++)
                    {
                        FpSpread1.Sheets[0].Rows.Count++;

                        FpSpread1.Sheets[0].Cells[FpSpread1.Sheets[0].Rows.Count - 1, 0].Text = Convert.ToString(ii + 1);
                        // FpSpread2.Sheets[0].Cells[FpSpread2.Sheets[0].Rows.Count - 1, 2].CellType = txtceltype;
                        FpSpread1.Sheets[0].Cells[FpSpread1.Sheets[0].Rows.Count - 1, 1].Text   = Convert.ToString(dv[ii]["dept_name"].ToString());
                        FpSpread1.Sheets[0].Cells[FpSpread1.Sheets[0].Rows.Count - 1, 1].Tag    = Convert.ToString(dv[ii]["dept_code"].ToString());;
                        FpSpread1.Sheets[0].Cells[FpSpread1.Sheets[0].RowCount - 1, 2].CellType = chkboxcol;

                        // FpSpread2.Sheets[0].Cells[FpSpread2.Sheets[0].Rows.Count - 1, 2].Text = ds.Tables[0].Rows[ii]["Reg_No"].ToString();
                    }
                    //int rowheigth = FpSpread1.Sheets[0].Rows[FpSpread1.Sheets[0].RowCount - 1].Height;
                    //rowheigth = rowheigth * FpSpread1.Sheets[0].Rows.Count;
                    //FpSpread1.Height = rowheigth + 100;
                    FpSpread1.Sheets[0].PageSize = FpSpread1.Sheets[0].RowCount;
                    FpSpread1.SaveChanges();

                    FpSpread1.Visible = true;
                }
            }
            else
            {
            }
        }


        catch
        {
        }
    }
        /// <summary>
        /// Is used to do a reverse entry of "Production Record" into the system
        /// </summary>
        /// <returns>message successfuly created or not</returns>
        protected override string DoIt()
        {
            if (M_Production_ID > 0)
            {
                //Copy Production Header
                ViennaAdvantage.Model.X_M_Production production = new ViennaAdvantage.Model.X_M_Production(GetCtx(), M_Production_ID, Get_Trx());

                string cnt    = "Select count(*) from m_production pro where pro.movementdate >" + GlobalVariable.TO_DATE(production.GetMovementDate(), true) + " and pro.processed='Y' ";
                int    trncnt = Util.GetValueOfInt(DB.ExecuteScalar(cnt));
                if (trncnt > 0)
                {
                    production.SetGOM01_IsRecordAvail(true);
                    production.Save(Get_TrxName());
                    return(Msg.GetMsg(GetCtx(), "Please Check some transaction already availble in future"));
                }
                else
                {
                    production.SetGOM01_IsRecordAvail(false);
                    production.Save(Get_TrxName());
                }

                //check production is Reversed or not, if Reversed then not to do anything
                if (production.IsReversed())
                {
                    return(Msg.GetMsg(GetCtx(), "AlreadyReversed"));
                }

                //Get data from Production Plan
                dsProductionPlan = DB.ExecuteDataset(@"SELECT AD_CLIENT_ID , AD_ORG_ID , DESCRIPTION , LINE , M_LOCATOR_ID , 
                                       M_PRODUCT_ID , M_PRODUCTIONPLAN_ID ,  M_PRODUCTION_ID  ,  PROCESSED  , PRODUCTIONQTY  M_WAREHOUSE_ID FROM M_ProductionPlan 
                                       WHERE IsActive = 'Y' AND M_PRODUCTION_ID = " + M_Production_ID, null, Get_Trx());

                //get data from production Line
                dsProductionLine = DB.ExecuteDataset(@"SELECT AD_CLIENT_ID , AD_ORG_ID , DESCRIPTION , LINE , M_ATTRIBUTESETINSTANCE_ID , M_LOCATOR_ID , 
                                       M_PRODUCT_ID ,  M_PRODUCTIONLINE_ID, M_PRODUCTIONPLAN_ID , M_PRODUCTION_ID  , PROCESSED  , MOVEMENTQTY , 
                                       C_UOM_ID , PLANNEDQTY , M_WAREHOUSE_ID FROM M_ProductionLine 
                                       WHERE IsActive = 'Y' AND M_PRODUCTION_ID = " + M_Production_ID, null, Get_Trx());


                // Create New record of Production Header with Reverse Entry
                X_M_Production productionTo = new X_M_Production(production.GetCtx(), 0, production.Get_Trx());
                try
                {
                    productionTo.Set_TrxName(production.Get_Trx());
                    PO.CopyValues(production, productionTo, production.GetAD_Client_ID(), production.GetAD_Org_ID());
                    productionTo.SetName("{->" + productionTo.GetName() + ")");
                    if (production.Get_ColumnIndex("DocumentNo") > 0)
                    {
                        productionTo.Set_Value("DocumentNo", ("{->" + productionTo.Get_Value("DocumentNo") + ")"));
                    }
                    productionTo.SetMovementDate(production.GetMovementDate()); //SI_0662 : not to create reverse record in current date, it should be created with the same date.
                    productionTo.SetProcessed(false);
                    if (!productionTo.Save(production.Get_Trx()))
                    {
                        production.Get_Trx().Rollback();
                        ValueNamePair pp = VLogger.RetrieveError();
                        _log.Log(Level.SEVERE, "Could Not create Production reverse entry. ERRor Value : " + pp.GetValue() + "ERROR NAME : " + pp.GetName());
                        throw new Exception("Could not create Production reverse entry");
                    }
                    else
                    {
                        #region create new record of Production Plan
                        if (dsProductionPlan != null && dsProductionPlan.Tables.Count > 0 && dsProductionPlan.Tables[0].Rows.Count > 0)
                        {
                            for (int i = 0; i < dsProductionPlan.Tables[0].Rows.Count; i++)
                            {
                                //Original Line
                                fromProdPlan = new X_M_ProductionPlan(GetCtx(), Util.GetValueOfInt(dsProductionPlan.Tables[0].Rows[i]["M_PRODUCTIONPLAN_ID"]), Get_Trx());

                                // Create New record of Production Plan with Reverse Entry
                                toProdPlan = new X_M_ProductionPlan(production.GetCtx(), 0, production.Get_Trx());
                                try
                                {
                                    toProdPlan.Set_TrxName(production.Get_Trx());
                                    PO.CopyValues(fromProdPlan, toProdPlan, fromProdPlan.GetAD_Client_ID(), fromProdPlan.GetAD_Org_ID());
                                    toProdPlan.SetProductionQty(Decimal.Negate(toProdPlan.GetProductionQty()));
                                    toProdPlan.SetM_Production_ID(productionTo.GetM_Production_ID());
                                    toProdPlan.SetProcessed(false);
                                    if (!toProdPlan.Save(production.Get_Trx()))
                                    {
                                        production.Get_Trx().Rollback();
                                        ValueNamePair pp = VLogger.RetrieveError();
                                        _log.Log(Level.SEVERE, "Could Not create Production Plan reverse entry. ERRor Value : " + pp.GetValue() + "ERROR NAME : " + pp.GetName());
                                        throw new Exception("Could not create Production Plan reverse entry");
                                    }
                                    else
                                    {
                                        #region check record exist on production line
                                        if (dsProductionLine != null && dsProductionLine.Tables.Count > 0 && dsProductionLine.Tables[0].Rows.Count > 0)
                                        {
                                            //check record exist on production line against production plan
                                            drProductionLine = dsProductionLine.Tables[0].Select("M_ProductionPlan_ID  = " + fromProdPlan.GetM_ProductionPlan_ID());
                                            if (drProductionLine.Length > 0)
                                            {
                                                for (int j = 0; j < drProductionLine.Length; j++)
                                                {
                                                    //Original Line
                                                    fromProdline = new X_M_ProductionLine(GetCtx(), Util.GetValueOfInt(drProductionLine[j]["M_PRODUCTIONLINE_ID"]), Get_Trx());

                                                    // Create New record of Production line with Reverse Entry
                                                    toProdline = new X_M_ProductionLine(production.GetCtx(), 0, production.Get_Trx());
                                                    try
                                                    {
                                                        toProdline.Set_TrxName(production.Get_Trx());
                                                        PO.CopyValues(fromProdline, toProdline, fromProdPlan.GetAD_Client_ID(), fromProdPlan.GetAD_Org_ID());
                                                        toProdline.SetMovementQty(Decimal.Negate(toProdline.GetMovementQty()));
                                                        toProdline.SetPlannedQty(Decimal.Negate(toProdline.GetPlannedQty()));
                                                        toProdline.SetM_Production_ID(productionTo.GetM_Production_ID());
                                                        toProdline.SetM_ProductionPlan_ID(toProdPlan.GetM_ProductionPlan_ID());
                                                        toProdline.SetReversalDoc_ID(fromProdline.GetM_ProductionLine_ID()); //maintain refernce of Orignal record on reversed record
                                                        toProdline.SetProcessed(false);
                                                        // if (!CheckQtyAvailablity(GetCtx(), toProdline.GetM_Warehouse_ID(), toProdline.GetM_Locator_ID(), toProdline.GetM_ProductContainer_ID(), toProdline.GetM_Product_ID(), toProdline.GetM_AttributeSetInstance_ID(), toProdline.GetMovementQty(), Get_Trx()))
                                                        if (!CheckQtyAvailablity(GetCtx(), toProdline.GetM_Warehouse_ID(), toProdline.GetM_Locator_ID(), 0, toProdline.GetM_Product_ID(), toProdline.GetM_AttributeSetInstance_ID(), toProdline.GetMovementQty(), Get_Trx()))
                                                        {
                                                            production.Get_Trx().Rollback();
                                                            ValueNamePair pp = VLogger.RetrieveError();
                                                            if (!string.IsNullOrEmpty(pp.GetName()))
                                                            {
                                                                throw new Exception("Could not create Production line reverse entry, " + pp.GetName());
                                                            }
                                                            else
                                                            {
                                                                throw new Exception("Could not create Production line reverse entry");
                                                            }
                                                        }
                                                        if (!toProdline.Save(production.Get_Trx()))
                                                        {
                                                            production.Get_Trx().Rollback();
                                                            ValueNamePair pp = VLogger.RetrieveError();
                                                            _log.Log(Level.SEVERE, "Could Not create Production Line reverse entry. ERRor Value : " + pp.GetValue() + "ERROR NAME : " + pp.GetName());
                                                            throw new Exception("Could not create Production line reverse entry");
                                                        }
                                                        else
                                                        {
                                                            // Create New record of Production line Policy (Material Policy) with Reverse Entry
                                                            sql.Clear();
                                                            sql.Append(@"INSERT INTO M_ProductionLineMA 
                                                                  (  AD_CLIENT_ID, AD_ORG_ID , CREATED , CREATEDBY , ISACTIVE , UPDATED , UPDATEDBY ,
                                                                    M_PRODUCTIONLINE_ID , M_ATTRIBUTESETINSTANCE_ID , MMPOLICYDATE , M_PRODUCTCONTAINER_ID, MOVEMENTQTY )
                                                                  (SELECT AD_CLIENT_ID, AD_ORG_ID , sysdate , CREATEDBY , ISACTIVE , sysdate , UPDATEDBY ,
                                                                      " + toProdline.GetM_ProductionLine_ID() + @" , M_ATTRIBUTESETINSTANCE_ID , MMPOLICYDATE , M_PRODUCTCONTAINER_ID,  -1 * MOVEMENTQTY
                                                                    FROM M_ProductionLineMA  WHERE M_ProductionLine_ID = " + fromProdline.GetM_ProductionLine_ID() + @" ) ");
                                                            int no = DB.ExecuteQuery(sql.ToString(), null, Get_Trx());
                                                            _log.Info("No of records saved on Meterial Policy against Production line ID : " + toProdline.GetM_ProductionLine_ID() + " are : " + no);
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        _log.Info("Error Occured during Production Reverse " + ex.ToString());
                                                        if (dsProductionLine != null)
                                                        {
                                                            dsProductionLine.Dispose();
                                                        }
                                                        if (dsProductionPlan != null)
                                                        {
                                                            dsProductionPlan.Dispose();
                                                        }
                                                        return(Msg.GetMsg(GetCtx(), "DocumentNotReversed" + result));
                                                    }
                                                }
                                            }
                                        }
                                        #endregion
                                    }
                                }
                                catch (Exception ex)
                                {
                                    _log.Info("Error Occured during Production Reverse " + ex.ToString());
                                    if (dsProductionLine != null)
                                    {
                                        dsProductionLine.Dispose();
                                    }
                                    if (dsProductionPlan != null)
                                    {
                                        dsProductionPlan.Dispose();
                                    }
                                    return(Msg.GetMsg(GetCtx(), "DocumentNotReversed" + result));
                                }
                            }
                        }
                        #endregion

                        result = productionTo.GetName();
                    }

                    //set Reversed as True
                    productionTo.SetIsReversed(true);
                    if (!productionTo.Save(production.Get_Trx()))
                    {
                        production.Get_Trx().Rollback();
                        ValueNamePair pp = VLogger.RetrieveError();
                        _log.Log(Level.SEVERE, "Could Not create Production reverse entry. ERRor Value : " + pp.GetValue() + "ERROR NAME : " + pp.GetName());
                        throw new Exception("Could not create Production reverse entry");
                    }

                    //Set reversed as true, Reverse Refernce on Orignal Document
                    production.SetIsReversed(true);
                    production.SetM_Ref_Production(productionTo.GetM_Production_ID());
                    if (!production.Save(production.Get_Trx()))
                    {
                        production.Get_Trx().Rollback();
                        ValueNamePair pp = VLogger.RetrieveError();
                        _log.Log(Level.SEVERE, "Could Not create Production reverse entry. ERRor Value : " + pp.GetValue() + "ERROR NAME : " + pp.GetName());
                        throw new Exception("Could not create Production reverse entry");
                    }
                }
                catch (Exception ex)
                {
                    _log.Info("Error Occured during Production Reverse " + ex.ToString());
                    if (dsProductionLine != null)
                    {
                        dsProductionLine.Dispose();
                    }
                    if (dsProductionPlan != null)
                    {
                        dsProductionPlan.Dispose();
                    }
                    return(Msg.GetMsg(GetCtx(), "DocumentNotReversed" + result));
                }
            }
            return(Msg.GetMsg(GetCtx(), "DocumentReversedSuccessfully" + result));
        }
Пример #51
0
    private string getCourseInfo()
    {
        StringBuilder sb = new StringBuilder();

        sb.Append("Course Details<br/>");
        sb.Append("Year: " + SectionDetails1.Year);
        sb.Append("<br/>Semester: " + SectionDetails1.Semester);
        sb.Append("<br/>Department: " + SectionDetails1.Department);
        sb.Append("<br/>Catalog Number: " + SectionDetails1.CatalogNumber);
        sb.Append("<br/>Section Number: " + SectionDetails1.SectionNumber);
        sb.Append("<br/>Start Date: " + SectionDetails1.DateStart);
        sb.Append("<br/>End Date: " + SectionDetails1.DateEnd);
        sb.Append("<br/>Capacity: " + SectionDetails1.Capacity);
        sb.Append("<br/><br/>");

        sb.Append("Faculty<ul>");
        ClsTempFaculty faculty = new ClsTempFaculty("MasterSchedule");

        faculty.SectionId = section.SectionId;
        DataSet facultyds = faculty.FillDs();

        for (int i = 0; i < facultyds.Tables[0].Rows.Count; i++)
        {
            sb.Append("<li>" + facultyds.Tables[0].Rows[i]["FacultyName"].ToString() + "</li>");
        }
        facultyds.Dispose();
        sb.Append("</ul><br/>");

        sb.Append("Meetings<br/><br/>");
        ClsTempMeeting meeting = new ClsTempMeeting("MasterSchedule");

        meeting.SectionId = section.SectionId;
        DataSet meetingds = meeting.FillDs();

        for (int i = 0; i < meetingds.Tables[0].Rows.Count; i++)
        {
            sb.Append("Meeting " + ((int)(i + 1)).ToString());
            sb.Append("<br/>Campus: " + meetingds.Tables[0].Rows[i]["Campus"].ToString());
            sb.Append("<br/>Room: " + meetingds.Tables[0].Rows[i]["Room"].ToString());
            sb.Append("<br/>Start Time: " + meetingds.Tables[0].Rows[i]["StartTime"].ToString());
            sb.Append("<br/>End Time: " + meetingds.Tables[0].Rows[i]["EndTime"].ToString());
            sb.Append("<br/>Days: " + meetingds.Tables[0].Rows[i]["Days"].ToString());
            sb.Append("<br/>Type: " + meetingds.Tables[0].Rows[i]["Type"].ToString());
            sb.Append("<br/><br/>");
        }
        meetingds.Dispose();

        sb.Append("Co-Listed Courses<ul>");
        ClsTempColink colink = new ClsTempColink("MasterSchedule");

        colink.SectionId = section.SectionId;
        DataSet colinkds = colink.FillDs();

        for (int i = 0; i < colinkds.Tables[0].Rows.Count; i++)
        {
            sb.Append("<li>" + colinkds.Tables[0].Rows[i]["Department"].ToString() + " - " + colinkds.Tables[0].Rows[i]["Course"].ToString() + " - " + colinkds.Tables[0].Rows[i]["Section"].ToString() + "</li>");
        }
        colinkds.Dispose();
        sb.Append("</ul><br/>");

        sb.Append("Cross Linked Courses<ul>");
        ClsTempLink link = new ClsTempLink("MasterSchedule");

        link.SectionId = section.SectionId;
        DataSet linkds = link.FillDs();

        for (int i = 0; i < linkds.Tables[0].Rows.Count; i++)
        {
            sb.Append("<li>" + linkds.Tables[0].Rows[i]["Department"].ToString() + " - " + linkds.Tables[0].Rows[i]["Course"].ToString() + " - " + linkds.Tables[0].Rows[i]["Section"].ToString() + "</li>");
        }
        linkds.Dispose();
        sb.Append("</ul><br/>");

        sb.Append("Co-requisite Courses<ul>");
        ClsTempCoreq coreq = new ClsTempCoreq("MasterSchedule");

        coreq.SectionId = section.SectionId;
        DataSet coreqds = coreq.FillDs();

        for (int i = 0; i < coreqds.Tables[0].Rows.Count; i++)
        {
            sb.Append("<li>" + coreqds.Tables[0].Rows[i]["Department"].ToString() + " - " + coreqds.Tables[0].Rows[i]["Course"].ToString() + " - " + coreqds.Tables[0].Rows[i]["Section"].ToString() + "</li>");
        }
        coreqds.Dispose();
        sb.Append("</ul><br/>");

        sb.Append("Comments<ul>");

        string InitiatorComments = string.Empty;

        if (string.IsNullOrEmpty(Comments_New1.Comments))
        {
            InitiatorComments = "No Comments.";
        }
        else
        {
            InitiatorComments = Comments_New1.Comments;
        }
        sb.Append("<br/>Initiator: " + InitiatorComments);
        sb.Append("</ul><br/>");

        return(sb.ToString());
    }
Пример #52
0
        protected override string DoIt()
        {
            query = "Select count(*) from  VARPT_Temp_Stock";
            int no = Util.GetValueOfInt(DB.ExecuteScalar(query, null, null));

            if (no > 0)
            {
                query = "Delete from  VARPT_Temp_Stock";

                no = DB.ExecuteQuery(query, null, null);
            }
            #region commented
            //            _Insert.Append(@"INSERT INTO  VARPT_Temp_Stock
            //                                   (AD_Client_ID,AD_Org_ID,value,m_product_category_id,C_UOM_ID,
            //                                  M_Locator_ID,MovementDate,M_Product_ID ,CurrentQty,m_warehouse_id)");

            //            StringBuilder sql=new StringBuilder();
            //            sql.Append(@"SELECT tr.ad_client_id,tr.ad_org_id,p.value,
            //                                   p.m_product_category_id,
            //                                   p.c_uom_id , tr.m_locator_ID , tr.movementdate ,
            //                                   tr.m_product_id,tr.currentqty,
            //                                   lc.m_warehouse_id FROM m_transaction tr INNER JOIN m_product p ON tr.m_product_id =p.m_product_id
            //                                 INNER JOIN m_locator lc ON tr.m_locator_id=lc.m_locator_id");



            //            if (MovementDate != null)
            //            {
            //                sql.Append("  where movementdate=" + GlobalVariable.TO_DATE(MovementDate, true));
            //            }
            //            if (M_Warehouse_ID != 0)
            //            {
            //                sql.Append("and  lc.m_warehouse_id=" + M_Warehouse_ID);
            //            }
            //            if (M_Product_ID != 0)
            //            {
            //                //sql.Append("and  tr.m_product_id=" + M_Product_ID);
            //                sql.Append(" and  p.m_product_id=" + M_Product_ID);

            //            }
            //            if (M_Product_Category_ID != 0)
            //            {
            //                //sql.Append("and  p.m_product_category_id=" + M_Product_Category_ID);
            //                sql.Append("and p.m_product_category_id=" + M_Product_Category_ID);
            //            }
            //            if (M_Locator_ID != 0)
            //            {
            //              //  sql.Append("and  tr.m_locator_ID=" + M_Locator_ID);
            //                sql.Append("and tr.m_locator_ID=" + M_Locator_ID);
            //            }
            //            sql.Append(" and tr.movementdate   IN (SELECT MAX(movementdate) FROM m_transaction trn INNER JOIN m_product pd ON trn.m_product_id =pd.m_product_id INNER JOIN m_locator lca ON trn.m_locator_id=lca.m_locator_id");
            //            if (MovementDate != null)
            //            {
            //                sql.Append(" where trn.movementdate=" + GlobalVariable.TO_DATE(MovementDate, true));
            //            }
            //            if (M_Warehouse_ID != 0)
            //            {
            //                sql.Append("and  lca.m_warehouse_id=" + M_Warehouse_ID);
            //            }
            //            if (M_Product_ID != 0)
            //            {
            //                //sql.Append("and  tr.m_product_id=" + M_Product_ID);
            //                sql.Append(" and pd.m_product_id=" + M_Product_ID);

            //            }
            //            if (M_Product_Category_ID != 0)
            //            {
            //                //sql.Append("and  p.m_product_category_id=" + M_Product_Category_ID);
            //                sql.Append(" and pd.m_product_category_id=" + M_Product_Category_ID);
            //            }
            //            if (M_Locator_ID != 0)
            //            {
            //                //  sql.Append("and  tr.m_locator_ID=" + M_Locator_ID);
            //                sql.Append(" and trn.m_locator_ID=" + M_Locator_ID);
            //            }
            //            sql.Append(")ORDER BY m_transaction_id DESC");
            //           // sql.Append(") ORDER BY m_transaction_id ASC");
            //            DataSet ds=DB.ExecuteDataset(sql.ToString(),null,null);
            //            if (ds != null)
            //            {

            //                if (ds.Tables[0].Rows.Count > 0)
            //                {
            //                    _Insert.Append(sql);
            //                     no = DB.ExecuteQuery(_Insert.ToString(), null, null);
            //                }
            //else
            //{ int no = 0;
            #endregion
            StringBuilder sql = new StringBuilder();
            _Insert = new StringBuilder();

            //MovementDate = new DateTime(MovementDate.Value.Year, MovementDate.Value.Month, (MovementDate.Value.Day + 1));
            MovementDate = MovementDate.Value.AddDays(1);

            _Insert.Append(@"INSERT INTO  VARPT_Temp_Stock 
                                   (AD_Client_ID,AD_Org_ID,value,m_product_category_id,C_UOM_ID,
                                  M_Locator_ID,MovementDate,M_Product_ID ,CurrentQty,m_warehouse_id)");
            sql = new StringBuilder();
            sql.Append(@"SELECT tr.ad_client_id,tr.ad_org_id,p.value,
                                   p.m_product_category_id,
                                   p.c_uom_id , tr.m_locator_ID , tr.movementdate ,
                                   tr.m_product_id,tr.currentqty,
                                   lc.m_warehouse_id FROM m_transaction tr INNER JOIN m_product p ON tr.m_product_id =p.m_product_id
                                 INNER JOIN m_locator lc ON tr.m_locator_id=lc.m_locator_id");
            if (MovementDate != null)
            {
                sql.Append(" where movementdate<" + GlobalVariable.TO_DATE(MovementDate, true));
            }
            if (M_Warehouse_ID != 0)
            {
                sql.Append(" and lc.M_Warehouse_ID=" + M_Warehouse_ID);
            }
            if (M_Product_ID != 0 && M_Product_Category_ID != 0 && M_Locator_ID != 0 && M_Warehouse_ID != 0)
            {
                sql.Append(" and  p.m_product_id=" + M_Product_ID);
                sql.Append("and p.m_product_category_id=" + M_Product_Category_ID);
                sql.Append("and tr.m_locator_ID=" + M_Locator_ID);
                sql.Append(" and tr.movementdate   IN (SELECT MAX(movementdate) FROM m_transaction trn INNER JOIN m_product pd ON trn.m_product_id =pd.m_product_id INNER JOIN m_locator lca ON trn.m_locator_id=lca.m_locator_id");
                sql.Append(" where trn.movementdate<" + GlobalVariable.TO_DATE(MovementDate, true));
                sql.Append(" and pd.m_product_id=" + M_Product_ID);
                sql.Append(" and pd.m_product_category_id=" + M_Product_Category_ID);
                sql.Append(" and trn.m_locator_ID=" + M_Locator_ID);
                sql.Append(" and lca.m_warehouse_id=" + M_Warehouse_ID);
                sql.Append(")ORDER BY m_transaction_id DESC");
                //_Insert.Append(sql);
                //no = DB.ExecuteQuery(_Insert.ToString(), null, null);
                DataSet dsProductlocator = DB.ExecuteDataset(sql.ToString(), null, null);
                if (dsProductlocator.Tables[0].Rows.Count > 0)
                {
                    int a = 0;
                    for (a = 0; a < dsProductlocator.Tables[0].Rows.Count; a++)
                    {
                        // if (Util.GetValueOfInt(dsProduct.Tables[0].Rows[]["M_Locator_Id"]) == _SelectedLocator)
                        //{
                        _Insert.Append("values(" + Util.GetValueOfInt(dsProductlocator.Tables[0].Rows[0]["Ad_client_ID"]) + @",
                                                 " + Util.GetValueOfInt(dsProductlocator.Tables[0].Rows[0]["Ad_Org_ID"]) + @",
                                                ' " + Util.GetValueOfString(dsProductlocator.Tables[0].Rows[0]["Value"]) + @"',
                                                 " + Util.GetValueOfInt(dsProductlocator.Tables[0].Rows[0]["m_product_category_id"]) + @",
                                                " + Util.GetValueOfInt(dsProductlocator.Tables[0].Rows[0]["C_Uom_id"]) + @",
                                                  " + Util.GetValueOfInt(dsProductlocator.Tables[0].Rows[0]["m_locator_ID"]) + @",
                                                     " + GlobalVariable.TO_DATE(Util.GetValueOfDateTime(dsProductlocator.Tables[0].Rows[0]["movementdate"]), true) + @",
                                                  " + Util.GetValueOfInt(dsProductlocator.Tables[0].Rows[0]["m_product_id"]) + @",
                                                 " + Util.GetValueOfInt(dsProductlocator.Tables[0].Rows[0]["currentqty"]) + @", 
                                                  " + Util.GetValueOfInt(dsProductlocator.Tables[0].Rows[0]["m_warehouse_id"]) + @")");
                        no = DB.ExecuteQuery(_Insert.ToString(), null, null);
                        dsProductlocator.Dispose();
                        if (a == 0)
                        {
                            break;
                        }
                        // }
                    }
                }
                else
                {
                    dsProductlocator.Dispose();
                }
            }
            else if (M_Product_ID != 0)
            {
                if (M_Locator_ID != 0)
                {
                    sql.Append(" and  p.m_product_id=" + M_Product_ID);
                    sql.Append("and tr.m_locator_ID=" + M_Locator_ID);
                    if (M_Product_Category_ID != 0)
                    {
                        sql.Append("and p.m_product_category_id=" + M_Product_Category_ID);
                    }
                    sql.Append(" and tr.movementdate   IN (SELECT MAX(movementdate) FROM m_transaction trn INNER JOIN m_product pd ON trn.m_product_id =pd.m_product_id  INNER JOIN m_locator lca ON trn.m_locator_id=lca.m_locator_id");
                    sql.Append(" where trn.movementdate<" + GlobalVariable.TO_DATE(MovementDate, true));
                    sql.Append(" and pd.m_product_id=" + M_Product_ID);
                    if (M_Warehouse_ID != 0)
                    {
                        sql.Append(" and lca.m_warehouse_id=" + M_Warehouse_ID);
                    }

                    if (M_Locator_ID != 0)
                    {
                        sql.Append(" and trn.m_locator_ID=" + M_Locator_ID);
                    }
                    if (M_Product_Category_ID != 0)
                    {
                        sql.Append(" and pd.m_product_category_id=" + M_Product_Category_ID);
                    }
                    sql.Append(")ORDER BY m_transaction_id DESC");
                    DataSet dsProdLocator = DB.ExecuteDataset(sql.ToString(), null, null);
                    if (dsProdLocator.Tables[0].Rows.Count > 0)
                    {
                        for (int a = 0; a < dsProdLocator.Tables[0].Rows.Count; a++)
                        {
                            // if (Util.GetValueOfInt(dsProduct.Tables[0].Rows[]["M_Locator_Id"]) == _SelectedLocator)
                            //{
                            _Insert.Append("values(" + Util.GetValueOfInt(dsProdLocator.Tables[0].Rows[0]["Ad_client_ID"]) + @",
                                                 " + Util.GetValueOfInt(dsProdLocator.Tables[0].Rows[0]["Ad_Org_ID"]) + @",
                                                ' " + Util.GetValueOfString(dsProdLocator.Tables[0].Rows[0]["Value"]) + @"',
                                                 " + Util.GetValueOfInt(dsProdLocator.Tables[0].Rows[0]["m_product_category_id"]) + @",
                                                " + Util.GetValueOfInt(dsProdLocator.Tables[0].Rows[0]["C_Uom_id"]) + @",
                                                  " + Util.GetValueOfInt(dsProdLocator.Tables[0].Rows[0]["m_locator_ID"]) + @",
                                                     " + GlobalVariable.TO_DATE(Util.GetValueOfDateTime(dsProdLocator.Tables[0].Rows[0]["movementdate"]), true) + @",
                                                  " + Util.GetValueOfInt(dsProdLocator.Tables[0].Rows[0]["m_product_id"]) + @",
                                                 " + Util.GetValueOfInt(dsProdLocator.Tables[0].Rows[0]["currentqty"]) + @", 
                                                  " + Util.GetValueOfInt(dsProdLocator.Tables[0].Rows[0]["m_warehouse_id"]) + @")");
                            no = DB.ExecuteQuery(_Insert.ToString(), null, null);
                            dsProdLocator.Dispose();
                            if (a == 0)
                            {
                                break;
                            }
                            // }
                        }
                    }
                    else
                    {
                        dsProdLocator.Dispose();
                    }
                    //_Insert.Append(sql);
                    //no = DB.ExecuteQuery(_Insert.ToString(), null, null);
                }
                else
                {
                    query = "select m_locator_id from m_locator where M_Warehouse_ID=" + M_Warehouse_ID;
                    DataSet dslocator = DB.ExecuteDataset(query, null, null);
                    if (dslocator.Tables[0].Rows.Count > 0)
                    {
                        for (int b = 0; b < dslocator.Tables[0].Rows.Count; b++)
                        {
                            _Insert = new StringBuilder();
                            _Insert.Append(@"INSERT INTO  VARPT_Temp_Stock 
                                   (AD_Client_ID,AD_Org_ID,value,m_product_category_id,C_UOM_ID,
                                  M_Locator_ID,MovementDate,M_Product_ID ,CurrentQty,m_warehouse_id)");
                            sql = new StringBuilder();
                            sql.Append(@"SELECT tr.ad_client_id,tr.ad_org_id,p.value,
                                   p.m_product_category_id,
                                   p.c_uom_id , tr.m_locator_ID , tr.movementdate ,
                                   tr.m_product_id,tr.currentqty,
                                   lc.m_warehouse_id FROM m_transaction tr INNER JOIN m_product p ON tr.m_product_id =p.m_product_id
                                 INNER JOIN m_locator lc ON tr.m_locator_id=lc.m_locator_id where movementdate<" + GlobalVariable.TO_DATE(MovementDate, true) + @"
                                      and lc.M_Warehouse_ID=" + M_Warehouse_ID + "  and lc.M_locator_id= " + dslocator.Tables[0].Rows[b]["M_Locator_ID"] + " and  p.m_product_id=" + M_Product_ID);
                            if (M_Product_Category_ID != 0)
                            {
                                sql.Append("and p.m_product_category_id=" + M_Product_Category_ID);
                            }
                            sql.Append(" and tr.movementdate   IN (SELECT MAX(movementdate) FROM m_transaction trn INNER JOIN m_product pd ON trn.m_product_id =pd.m_product_id  INNER JOIN m_locator lca ON trn.m_locator_id=lca.m_locator_id");
                            sql.Append(" where trn.movementdate<" + GlobalVariable.TO_DATE(MovementDate, true));
                            sql.Append(" and pd.m_product_id=" + M_Product_ID);
                            if (M_Warehouse_ID != 0)
                            {
                                sql.Append(" and lca.m_warehouse_id=" + M_Warehouse_ID);
                            }
                            sql.Append(" and trn.M_locator_id= " + dslocator.Tables[0].Rows[b]["M_Locator_ID"]);
                            if (M_Product_Category_ID != 0)
                            {
                                sql.Append(" and pd.m_product_category_id=" + M_Product_Category_ID);
                            }
                            sql.Append(")ORDER BY m_transaction_id DESC");
                            DataSet dsProduct = DB.ExecuteDataset(sql.ToString(), null, null);
                            if (dsProduct.Tables[0].Rows.Count > 0)
                            {
                                int a = 0;
                                for (a = 0; a < dsProduct.Tables[0].Rows.Count; a++)
                                {
                                    // if (Util.GetValueOfInt(dsProduct.Tables[0].Rows[]["M_Locator_Id"]) == _SelectedLocator)
                                    //{
                                    _Insert.Append("values(" + Util.GetValueOfInt(dsProduct.Tables[0].Rows[0]["Ad_client_ID"]) + @",
                                                 " + Util.GetValueOfInt(dsProduct.Tables[0].Rows[0]["Ad_Org_ID"]) + @",
                                                ' " + Util.GetValueOfString(dsProduct.Tables[0].Rows[0]["Value"]) + @"',
                                                 " + Util.GetValueOfInt(dsProduct.Tables[0].Rows[0]["m_product_category_id"]) + @",
                                                " + Util.GetValueOfInt(dsProduct.Tables[0].Rows[0]["C_Uom_id"]) + @",
                                                  " + Util.GetValueOfInt(dsProduct.Tables[0].Rows[0]["m_locator_ID"]) + @",
                                                     " + GlobalVariable.TO_DATE(Util.GetValueOfDateTime(dsProduct.Tables[0].Rows[0]["movementdate"]), true) + @",
                                                  " + Util.GetValueOfInt(dsProduct.Tables[0].Rows[0]["m_product_id"]) + @",
                                                 " + Util.GetValueOfInt(dsProduct.Tables[0].Rows[0]["currentqty"]) + @", 
                                                  " + Util.GetValueOfInt(dsProduct.Tables[0].Rows[0]["m_warehouse_id"]) + @")");
                                    no = DB.ExecuteQuery(_Insert.ToString(), null, null);
                                    dsProduct.Dispose();
                                    if (a == 0)
                                    {
                                        break;
                                    }
                                    // }
                                }
                            }
                            else
                            {
                                dsProduct.Dispose();
                            }
                            //_Insert.Append(sql);
                            //no = DB.ExecuteQuery(_Insert.ToString(), null, null);
                        }
                    }
                }
            }
            else
            {
                query = "select * from m_transaction where ad_client_ID=" + GetCtx().GetAD_Client_ID() + " order by M_product_ID";
                DataSet dstransaction = DB.ExecuteDataset(query, null, null);
                if (dstransaction.Tables[0].Rows.Count > 0)
                {
                    for (int j = 0; j < dstransaction.Tables[0].Rows.Count; j++)
                    {
                        if (!lst.Contains(new KeyValuePair <int, int>(Util.GetValueOfInt(dstransaction.Tables[0].Rows[j]["M_Product_ID"]), Util.GetValueOfInt(dstransaction.Tables[0].Rows[j]["M_Locator_ID"]))))
                        {
                            lst.Add(new KeyValuePair <int, int>(Util.GetValueOfInt(dstransaction.Tables[0].Rows[j]["M_Product_ID"]), Util.GetValueOfInt(dstransaction.Tables[0].Rows[j]["M_Locator_ID"])));
                            _SelectedLocator = Util.GetValueOfInt(dstransaction.Tables[0].Rows[j]["M_Locator_ID"]);

                            _Insert = new StringBuilder();
                            _Insert.Append(@"INSERT INTO  VARPT_Temp_Stock 
                                   (AD_Client_ID,AD_Org_ID,value,m_product_category_id,C_UOM_ID,
                                  M_Locator_ID,MovementDate,M_Product_ID ,CurrentQty,m_warehouse_id)");
                            sql = new StringBuilder();
                            sql.Append(@"SELECT tr.ad_client_id,tr.ad_org_id,p.value,
                                   p.m_product_category_id,
                                   p.c_uom_id , tr.m_locator_ID , tr.movementdate ,
                                   tr.m_product_id,tr.currentqty,
                                   lc.m_warehouse_id FROM m_transaction tr INNER JOIN m_product p ON tr.m_product_id =p.m_product_id
                                 INNER JOIN m_locator lc ON tr.m_locator_id=lc.m_locator_id
                            where   lc.M_Warehouse_ID=" + M_Warehouse_ID + " and tr.M_locator_id=" + _SelectedLocator + "  and p.m_product_id=" + dstransaction.Tables[0].Rows[j]["M_Product_ID"] + @" 
                                and movementdate<" + GlobalVariable.TO_DATE(MovementDate, true) + @"");
                            if (M_Locator_ID != 0)
                            {
                                sql.Append("and tr.m_locator_ID=" + M_Locator_ID);
                            }
                            if (M_Product_Category_ID != 0)
                            {
                                sql.Append("and p.m_product_category_id=" + M_Product_Category_ID);
                            }
                            sql.Append(" and tr.movementdate   IN (SELECT MAX(movementdate) FROM m_transaction trn INNER JOIN m_product pd ON trn.m_product_id =pd.m_product_id INNER JOIN m_locator lca ON trn.m_locator_id=lca.m_locator_id");
                            sql.Append(" WHERE  lca.m_warehouse_id=" + M_Warehouse_ID + " and trn.M_locator_id=" + _SelectedLocator + " and pd.m_product_id=" + dstransaction.Tables[0].Rows[j]["M_Product_ID"] + @" 
                            and trn.movementdate<" + GlobalVariable.TO_DATE(MovementDate, true));
                            if (M_Locator_ID != 0)
                            {
                                sql.Append(" and trn.m_locator_ID=" + M_Locator_ID);
                            }
                            if (M_Product_Category_ID != 0)
                            {
                                sql.Append(" and pd.m_product_category_id=" + M_Product_Category_ID);
                            }
                            sql.Append(")order by  m_transaction_id desc");
                            DataSet dsrecord = DB.ExecuteDataset(sql.ToString(), null, null);
                            if (dsrecord.Tables[0].Rows.Count > 0)
                            {
                                for (int a = 0; a < dsrecord.Tables[0].Rows.Count; a++)
                                {
                                    if (Util.GetValueOfInt(dsrecord.Tables[0].Rows[a]["M_Locator_Id"]) == _SelectedLocator)
                                    {
                                        _Insert.Append("values(" + Util.GetValueOfInt(dsrecord.Tables[0].Rows[a]["Ad_client_ID"]) + @",
                                                 " + Util.GetValueOfInt(dsrecord.Tables[0].Rows[a]["Ad_Org_ID"]) + @",
                                                ' " + Util.GetValueOfString(dsrecord.Tables[0].Rows[a]["Value"]) + @"',
                                                 " + Util.GetValueOfInt(dsrecord.Tables[0].Rows[a]["m_product_category_id"]) + @",
                                                " + Util.GetValueOfInt(dsrecord.Tables[0].Rows[a]["C_Uom_id"]) + @",
                                                  " + Util.GetValueOfInt(dsrecord.Tables[0].Rows[a]["m_locator_ID"]) + @",
                                                     " + GlobalVariable.TO_DATE(Util.GetValueOfDateTime(dsrecord.Tables[0].Rows[a]["movementdate"]), true) + @",
                                                  " + Util.GetValueOfInt(dsrecord.Tables[0].Rows[a]["m_product_id"]) + @",
                                                 " + Util.GetValueOfInt(dsrecord.Tables[0].Rows[a]["currentqty"]) + @", 
                                                  " + Util.GetValueOfInt(dsrecord.Tables[0].Rows[a]["m_warehouse_id"]) + @")");
                                        no = DB.ExecuteQuery(_Insert.ToString(), null, null);
                                        dsrecord.Dispose();
                                        break;
                                    }
                                }
                            }

                            else
                            {
                                dsrecord.Dispose();
                            }
                        }
                    }
                }
            }
            query = "select count(*) from VARPT_Temp_Stock";
            int count = Util.GetValueOfInt(DB.ExecuteScalar(query, null, null));
            MovementDate = MovementDate.Value.AddDays(-1);
            //new DateTime(MovementDate.Value.Year, MovementDate.Value.Month, (MovementDate.Value.Day -1));
            if (count > 0)
            {
                query = "update VARPT_Temp_Stock set movementdate=" + GlobalVariable.TO_DATE(MovementDate, true);
                no    = DB.ExecuteQuery(query, null, null);
            }
            if (_ZeroQty == "N")
            {
                query = "update VARPT_Temp_Stock set ZeroQty='Y' where currentqty=0";
                no    = DB.ExecuteQuery(query, null, null);
            }
            else
            {
                query = "update VARPT_Temp_Stock set ZeroQty='" + _ZeroQty + "'";
                no    = DB.ExecuteQuery(query, null, null);
            }
            return("Completed");
        }
Пример #53
0
        public int Insert_New_Record(Int64 parint64CompanyNo, Int64 parint64CurrentUserNo, string parstrMenuId, string parstrOccupationDepartmentDesc)
        {
            DataSet DataSet = new DataSet();

            int           intOccupationDepartmentNo = 1;
            StringBuilder strQry       = new StringBuilder();
            string        strTableName = "";

            if (parstrMenuId == "39")
            {
                strTableName = "DEPARTMENT";
            }
            else
            {
                strTableName = "OCCUPATION";
            }

            strQry.Clear();
            strQry.AppendLine(" SELECT ");
            strQry.AppendLine(" MAX(" + strTableName + "_NO) AS MAX_NO");
            strQry.AppendLine(" FROM InteractPayroll_#CompanyNo#.dbo." + strTableName);
            strQry.AppendLine(" WHERE COMPANY_NO = " + parint64CompanyNo);

            clsDBConnectionObjects.Create_DataTable(strQry.ToString(), DataSet, "Temp", parint64CompanyNo);

            if (DataSet.Tables["Temp"].Rows[0].IsNull("MAX_NO") == true)
            {
                intOccupationDepartmentNo = 1;
            }
            else
            {
                intOccupationDepartmentNo = Convert.ToInt32(DataSet.Tables[0].Rows[0]["MAX_NO"]) + 1;
            }

            DataSet.Dispose();
            DataSet = null;

            strQry.Clear();
            strQry.AppendLine(" INSERT INTO InteractPayroll_#CompanyNo#.dbo." + strTableName);
            strQry.AppendLine("(COMPANY_NO");
            strQry.AppendLine("," + strTableName + "_NO");
            strQry.AppendLine("," + strTableName + "_DESC");
            strQry.AppendLine(",DATETIME_NEW_RECORD");
            strQry.AppendLine(",USER_NO_NEW_RECORD)");
            strQry.AppendLine(" VALUES");
            strQry.AppendLine("(" + parint64CompanyNo);
            strQry.AppendLine("," + intOccupationDepartmentNo);
            strQry.AppendLine("," + clsDBConnectionObjects.Text2DynamicSQL(parstrOccupationDepartmentDesc));
            strQry.AppendLine(",GETDATE()");
            strQry.AppendLine("," + parint64CurrentUserNo + ")");

            clsDBConnectionObjects.Execute_SQLCommand(strQry.ToString(), parint64CompanyNo);

            strQry.Clear();

            strQry.AppendLine(" UPDATE InteractPayroll.dbo.COMPANY_LINK");
            strQry.AppendLine(" SET BACKUP_DB_IND = 1");
            strQry.AppendLine(" WHERE COMPANY_NO = " + parint64CompanyNo);

            clsDBConnectionObjects.Execute_SQLCommand(strQry.ToString(), -1);

            return(intOccupationDepartmentNo);
        }
Пример #54
0
        /// <summary>
        /// 绑定读取数据
        /// </summary>
        private void BindData()
        {
            //定义变量
            string strSql, strKeyWords, strIsRecommend;

            //变量赋值
            strKeyWords    = Request.QueryString["keyword"];
            strIsRecommend = Request.QueryString["IsRecommend"];

            //判断变量
            if (!FunctionClass.CheckStr(strIsRecommend, 1))
            {
                strIsRecommend = "";
            }

            //打开数据库
            DataClass     myData = new DataClass();
            SqlConnection myConn = myData.ConnOpen();

            //sql语句
            strSql = " where IsShow=1";

            if (FunctionClass.CheckStr(strKeyWords, 0))
            {
                strSql += " and (Title like '%" + strKeyWords.Replace("'", "''") + "%' or Memo like '%" + strKeyWords.Replace("'", "''") + "%')";
            }

            if (strIsRecommend != "")
            {
                strSql += " and IsRecommend=" + strIsRecommend;
            }

            //初始化分页变量
            int intPageIndex       = FunctionClass.CurrentPage();
            int intPageSize        = 5;
            int intPageCount       = 0;
            int intPageRecordcount = 0;

            //创建Dataset对象读取数据记录集
            DataSet myDs = myData.GetDataSet("T_Book", strSql, "SID asc,NoteTime desc", intPageIndex, intPageSize,
                                             ref intPageCount, ref intPageRecordcount, myConn);

            DataView myDv = new DataView(myDs.Tables[0], "  ", "", DataViewRowState.CurrentRows);

            for (int i = 0; i < myDv.Count; i++)
            {
                lbList.Text += "<dl><dt>" + myDv[i]["Title"].ToString() + "</dt>"
                               + "<dd>" + FunctionClass.WriteHtml(myDv[i]["Memo"].ToString()) + "</dd></dl>";
            }
            myDv.Dispose();

            //分页
            lbPageBar.Text = FunctionClass.GetPageBar(intPageIndex, intPageRecordcount, intPageCount, 4,
                                                      FunctionClass.GetNewURL("page", "{page}", FunctionClass.PageURL),
                                                      "<img src=\"images/news_11.jpg\" width=\"12\" height=\"12\" />",
                                                      "<img src=\"images/news_12.jpg\" width=\"12\" height=\"12\" />",
                                                      "<img src=\"images/news_14.jpg\" width=\"12\" height=\"12\" />",
                                                      "<img src=\"images/news_15.jpg\" width=\"12\" height=\"12\" />", false, false);
            myDs.Dispose();

            lbCalled.Text        = "加盟问答";
            lbCalled1.Text       = "F A Q";
            hyCalled.Text        = "加盟问答";
            hyCalled.NavigateUrl = "jm_book.aspx";

            lbInfo11.Text = myData.GetInfo(11, myConn);

            //关闭数据库
            myData.ConnClose(myConn);
        }
        private void fnDisplayRegGrid()
        {
            DataSet  ds = new DataSet();
            DataView DV = new DataView();

            hid_AcademicYear.Value     = ddlAcademicYear.SelectedItem.ToString();
            hid_fk_AcademicYr_ID.Value = ddlAcademicYear.SelectedItem.Value;
            hidAcademicYrText.Value    = ddlAcademicYear.SelectedItem.Text;

            try
            {
                //if (rbWithInv.Checked == true)
                //{
                //    hidInv.Value = "1";

                //    if (rbColl.Checked == true)
                //    {
                //        hidElgStatusColl.Value = "0";
                //        ds = Eligibility.clsEligibilityDBAccess.Fetch_Reg_Student_List_RegStu(Classes.clsGetSettings.UniversityID.ToString(), hidInstID.Value, hidFacID.Value, hidCrID.Value, hidMoLrnID.Value, hidPtrnID.Value, hidBrnID.Value, hidDOB.Value, hidLastName.Value, hidFirstName.Value, hidGender.Value, hidElgStatusColl.Value, hid_fk_AcademicYr_ID.Value);
                //        DV.Table = ds.Tables[0];
                //        lblGridName.Text = "List of students whose Eligiblity is marked by "+ lblCollege.Text +".";
                //    }
                //    if (rbUni.Checked == true)
                //    {
                //        hidElgStatusColl.Value = "1";
                //        ds = Eligibility.clsEligibilityDBAccess.Fetch_Reg_Student_List_RegStu(Classes.clsGetSettings.UniversityID.ToString(), hidInstID.Value, hidFacID.Value, hidCrID.Value, hidMoLrnID.Value, hidPtrnID.Value, hidBrnID.Value, hidDOB.Value, hidLastName.Value, hidFirstName.Value, hidGender.Value, hidElgStatusColl.Value, hid_fk_AcademicYr_ID.Value);
                //        DV.Table = ds.Tables[0];
                //        lblGridName.Text = "List of students whose Eligiblity is marked by " + lblUniversity.Text + ".";
                //    }
                //}


                //else if (rbWithoutInv.Checked == true)
                //{
                hidInv.Value = "0";

                if (rbColl.Checked == true)
                {
                    hidElgStatusColl.Value = "0";
                    ds               = Eligibility.clsEligibilityDBAccess.Fetch_Reg_Student_List_RegStu_bypassInv(Classes.clsGetSettings.UniversityID.ToString(), hidInstID.Value, hidFacID.Value, hidCrID.Value, hidMoLrnID.Value, hidPtrnID.Value, hidBrnID.Value, hidDOB.Value, hidLastName.Value, hidFirstName.Value, hidGender.Value, hidElgStatusColl.Value, hid_fk_AcademicYr_ID.Value);
                    DV.Table         = ds.Tables[0];
                    lblGridName.Text = "List of students whose Eligiblity is marked by " + lblCollege.Text + ".";
                }
                if (rbUni.Checked == true)
                {
                    hidElgStatusColl.Value = "1";
                    ds               = Eligibility.clsEligibilityDBAccess.Fetch_Reg_Student_List_RegStu_bypassInv(Classes.clsGetSettings.UniversityID.ToString(), hidInstID.Value, hidFacID.Value, hidCrID.Value, hidMoLrnID.Value, hidPtrnID.Value, hidBrnID.Value, hidDOB.Value, hidLastName.Value, hidFirstName.Value, hidGender.Value, hidElgStatusColl.Value, hid_fk_AcademicYr_ID.Value);
                    DV.Table         = ds.Tables[0];
                    lblGridName.Text = "List of students whose Eligiblity is marked by " + lblUniversity.Text + ".";
                }
                // }


                if (hidFacName.Value.Equals(string.Empty))
                {
                    hidFacName.Value  = ddlFaculty.SelectedItem.Text;
                    hidCrName.Value   = ddlCourse.SelectedItem.Text;
                    hidMOLName.Value  = ddlMoLrn.SelectedItem.Text;
                    hidPattern.Value  = ddlCrPtrn.SelectedItem.Text;
                    hidBrName.Value   = ddlBranch.SelectedItem.Text;
                    hidAcYrName.Value = ddlAcademicYear.SelectedItem.Text;
                }


                // Code Added By Pankaj on 28/10/2010
                hidFacIDToRestore.Value   = ddlFaculty.SelectedValue;
                hidCrIDToRestore.Value    = ddlCourse.SelectedValue;
                hidMoLrnIDToRestore.Value = ddlMoLrn.SelectedValue;
                hidPtrnIDToRestore.Value  = ddlCrPtrn.SelectedValue;
                hidBrnIDToRestore.Value   = ddlBranch.SelectedValue;

                ContentPlaceHolder Cntph1 = (ContentPlaceHolder)Page.Master.FindControl("ContentPlaceHolder1");
                ((Label)Cntph1.FindControl("lblSubHeader")).Text = "  for " + hidInstName.Value;

                if (ddlFaculty.SelectedValue != "0")
                {
                    ((Label)Cntph1.FindControl("lblSubHeader")).Text = ((Label)Cntph1.FindControl("lblSubHeader")).Text + " - " + ddlFaculty.SelectedItem.Text;
                }
                if (ddlCourse.SelectedValue != "0")
                {
                    ((Label)Cntph1.FindControl("lblSubHeader")).Text = ((Label)Cntph1.FindControl("lblSubHeader")).Text + " - " + ddlCourse.SelectedItem.Text;
                }
                if (ddlMoLrn.SelectedValue != "0")
                {
                    ((Label)Cntph1.FindControl("lblSubHeader")).Text = ((Label)Cntph1.FindControl("lblSubHeader")).Text + " - " + ddlMoLrn.SelectedItem.Text;
                }
                if (ddlCrPtrn.SelectedValue != "0")
                {
                    ((Label)Cntph1.FindControl("lblSubHeader")).Text = ((Label)Cntph1.FindControl("lblSubHeader")).Text + " - " + ddlCrPtrn.SelectedItem.Text;
                }
                //if (ddlBranch.SelectedValue != "0")   commented by Pankaj
                if (ddlBranch.SelectedItem.Text != "--- Select ---")
                {
                    ((Label)Cntph1.FindControl("lblSubHeader")).Text = ((Label)Cntph1.FindControl("lblSubHeader")).Text + " - " + ddlBranch.SelectedItem.Text;
                }
                ((Label)Cntph1.FindControl("lblSubHeader")).Text = ((Label)Cntph1.FindControl("lblSubHeader")).Text + " - [Academic Year " + ddlAcademicYear.SelectedItem.Text + "]";



                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (ViewState["SortExpression"] != null)
                    {
                        DV.Sort = ViewState["SortExpression"].ToString() + ViewState["SortOrder"].ToString();
                    }

                    try
                    {
                        dgRegPendingStudents1.DataSource = DV;
                        dgRegPendingStudents1.DataBind();
                    }
                    catch
                    {
                        dgRegPendingStudents1.PageIndex = 0;
                        dgRegPendingStudents1.DataBind();
                    }

                    //
                    dgRegPendingStudents1.Visible = true;
                    tblDGRegPendingStudents.Style.Remove("display");
                    tblDGRegPendingStudents.Style.Add("display", "block");
                    lblGridName.Style.Remove("display");
                    lblGridName.Style.Add("display", "block");
                    divDGNote.Style.Remove("display");
                    divDGNote.Style.Add("display", "block");
                    //divAcademicYr.Style.Add("display", "none");
                    tblSelect.Style.Add("display", "block");
                    //
                }
                else
                {
                    //
                    dgRegPendingStudents1.Visible = false;
                    tblDGRegPendingStudents.Style.Remove("display");
                    tblDGRegPendingStudents.Style.Add("display", "none");
                    lblGridName.Text = "There are no Students satisfying the above search criteria whose Eligibility is kept Pending...";
                    lblGridName.Style.Remove("display");
                    lblGridName.Style.Add("display", "block");
                    divDGNote.Style.Remove("display");
                    divDGNote.Style.Add("display", "none");
                    //
                }

                ds.Clear();
                ds.Dispose();
                ds = null;
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Пример #56
0
 public void Dispose()
 {
     ((IDisposable)database).Dispose();
     _mainTable?.Dispose();
 }
Пример #57
0
        public static void StatusChanged()
        {
            SqlContext.Pipe.Send("StatusChanged");

            SqlCommand     command     = null;
            SqlDataAdapter dataAdapter = null;
            DataSet        ds          = null;

            try
            {
                var triggContext = SqlContext.TriggerContext;

                switch (triggContext.TriggerAction)
                {
                case TriggerAction.Update:

                    SqlContext.Pipe.Send("TriggerAction.Update");

                    /* Retrieve the connection that the trigger is using. */
                    using (var connection = new SqlConnection(@"context connection=true"))
                    {
                        connection.Open();

                        command     = new SqlCommand(@"SELECT * FROM INSERTED;", connection);
                        dataAdapter = new SqlDataAdapter(command);
                        ds          = new DataSet();

                        dataAdapter.Fill(ds);

                        var table = ds.Tables[0];
                        var row   = table.Rows[0];

                        var columns = table.Columns;

                        var statusText = (String)row["StatusText"] ?? "";
                        var memberId   = (Int32)row["MemberID"];

                        SqlContext.Pipe.Send(String.Format("StatusText = {0}", statusText));
                        SqlContext.Pipe.Send(String.Format("MemberID = {0}", memberId));

                        var targetAccount = MemberAccount.GetMemberAccountByMemberID(memberId, connection);

                        if (MemberAccount.IsTwitterReady(targetAccount))
                        {
                            SqlContext.Pipe.Send("Target account is Twitter ready.");
                            TwitterService.UpdateStatus(targetAccount.Username, targetAccount.Password, statusText);
                            SqlContext.Pipe.Send("Twitter status updated successfully.");
                        }
                    }

                    break;
                }
            }
            catch (Exception e)
            {
                SqlContext.Pipe.Send(String.Format("StatusChanged trigger exception: {0}", e.Message));
            }
            finally
            {
                try
                {
                    if (command != null)
                    {
                        command.Dispose();
                    }

                    if (ds != null)
                    {
                        ds.Dispose();
                    }

                    if (dataAdapter != null)
                    {
                        dataAdapter.Dispose();
                    }
                }
                catch { }
            }
        }
        public ActionResult Index(CircleWiseChallanDeliveryReport objcust)
        {
            int CircleCnt = 0, BokCnt = 0;
            Int64 RemainingCnt = 0;
            string DistrictId = "";
            StringBuilder strTableReport = new StringBuilder();
            StringBuilder strReport = new StringBuilder();
            StringBuilder strReport1 = new StringBuilder();
            StringBuilder strReport2 = new StringBuilder();
            StringBuilder strReportSchoolNameHead = new StringBuilder();
            StringBuilder strTotReport = new StringBuilder();
            try { DistrictId = GlobalSettings.oUserData.DistrictID; }
            catch { DistrictId = ""; }
            string usertype = string.Empty;

            try
            {
                usertype = (GlobalSettings.oUserData).UserType;
            }
            catch { }
            try
            {
                if (DistrictId != "")
                {
                    DataSet ds = objDbTrx.GetCircleWiseChallanDelivaryReport(Convert.ToInt64(DistrictId), usertype);
                    if (ds != null)
                    {
                        CircleCnt = ds.Tables[1].Rows.Count;
                        for (int bkCnt = 0; bkCnt < ds.Tables[0].Rows.Count; bkCnt++)
                        {
                            strReport = new StringBuilder();
                            strReport1 = new StringBuilder();
                            strReport2 = new StringBuilder();
                            //rowspan='3'
                            strReport.AppendLine("      <td style='text-align:Left;vertical-align: middle;border-top: 2pt solid black;' > " + ds.Tables[0].Rows[bkCnt]["BOOK_CODE"].ToString() + "     </td>");
                            strReport.AppendLine("      <td style='text-align:Left;vertical-align: middle;border-top: 2pt solid black;' > " + ds.Tables[0].Rows[bkCnt]["CLASS"].ToString() + "         </td>");
                            strReport.AppendLine("      <td style='text-align:Left;vertical-align: middle;border-top: 2pt solid black;' > " + ds.Tables[0].Rows[bkCnt]["BOOK_NAME"].ToString() + "     </td>");
                            strReport.AppendLine("      <td style='text-align:Left;vertical-align: middle;border-top: 2pt solid black;' > " + ds.Tables[0].Rows[bkCnt]["LANGUAGE"].ToString() + "      </td>");
                            strReport.AppendLine("      <td style='text-align:Left;vertical-align: middle;border-top: 2pt solid black;'>Net Requisition Quantity</td>");

                            strReport1.AppendLine("      <td style='text-align:Left;vertical-align: middle;'> " + ds.Tables[0].Rows[bkCnt]["BOOK_CODE"].ToString() + "     </td>");
                            strReport1.AppendLine("      <td style='text-align:Left;vertical-align: middle;'> " + ds.Tables[0].Rows[bkCnt]["CLASS"].ToString() + "         </td>");
                            strReport1.AppendLine("      <td style='text-align:Left;vertical-align: middle;'> " + ds.Tables[0].Rows[bkCnt]["BOOK_NAME"].ToString() + "     </td>");
                            strReport1.AppendLine("      <td style='text-align:Left;vertical-align: middle;'> " + ds.Tables[0].Rows[bkCnt]["LANGUAGE"].ToString() + "      </td>");
                            strReport1.AppendLine("      <td style='text-align:Left;vertical-align: middle;'>Already Shiped Quantity</td>");

                            strReport2.AppendLine("      <td style='text-align:Left;vertical-align: middle;border-bottom: 2pt solid black;'> " + ds.Tables[0].Rows[bkCnt]["BOOK_CODE"].ToString() + "     </td>");
                            strReport2.AppendLine("      <td style='text-align:Left;vertical-align: middle;border-bottom: 2pt solid black;'> " + ds.Tables[0].Rows[bkCnt]["CLASS"].ToString() + "         </td>");
                            strReport2.AppendLine("      <td style='text-align:Left;vertical-align: middle;border-bottom: 2pt solid black;'> " + ds.Tables[0].Rows[bkCnt]["BOOK_NAME"].ToString() + "     </td>");
                            strReport2.AppendLine("      <td style='text-align:Left;vertical-align: middle;border-bottom: 2pt solid black;'> " + ds.Tables[0].Rows[bkCnt]["LANGUAGE"].ToString() + "      </td>");
                            strReport2.AppendLine("      <td style='text-align:Left;vertical-align: middle;border-bottom: 2pt solid black;'>Quantity for Shiping</td>");

                            //PrintSchoolDtl = true;
                            for (int schCnt = 0; schCnt < ds.Tables[1].Rows.Count; schCnt++)
                            {
                                if (bkCnt == 0)
                                {
                                    strReportSchoolNameHead.AppendLine("      <td style='text-align:Left;vertical-align: middle;' > " + ds.Tables[1].Rows[schCnt]["CIRCLE_NAME"].ToString() + "    </td>");
                                }

                                bool found = false;
                                for (int iCnt = 0; iCnt < ds.Tables[2].Rows.Count; iCnt++)
                                {

                                    if (ds.Tables[0].Rows[bkCnt]["BOOK_CODE"].ToString() == ds.Tables[2].Rows[iCnt]["BOOK_CODE"].ToString() && ds.Tables[1].Rows[schCnt]["ID"].ToString() == ds.Tables[2].Rows[iCnt]["ID"].ToString() && ds.Tables[0].Rows[bkCnt]["LANGUAGE"].ToString() == ds.Tables[2].Rows[iCnt]["LANGUAGE"].ToString())
                                    {
                                        found = true;
                                        if (Convert.ToInt64(ds.Tables[2].Rows[iCnt]["NetReqQtyAfterStockDeduction"].ToString()) > 0)
                                        {
                                            strReport.AppendLine("      <td style='text-align:center;vertical-align: middle;' bgcolor='#b3cbff' > " + ds.Tables[2].Rows[iCnt]["NetReqQtyAfterStockDeduction"].ToString() + "      </td>");
                                        }
                                        else
                                        {
                                            strReport.AppendLine("      <td style='text-align:center;vertical-align: middle;' > " + ds.Tables[2].Rows[iCnt]["NetReqQtyAfterStockDeduction"].ToString() + "      </td>");
                                        }
                                        if (Convert.ToInt64(ds.Tables[2].Rows[iCnt]["AlreadyShipped"].ToString()) > 0)
                                        {
                                            strReport1.AppendLine("      <td style='text-align:center;vertical-align: middle;' bgcolor='#99ff99' > " + ds.Tables[2].Rows[iCnt]["AlreadyShipped"].ToString() + "      </td>");
                                        }
                                        else
                                        {
                                            strReport1.AppendLine("      <td style='text-align:center;vertical-align: middle;' > " + ds.Tables[2].Rows[iCnt]["AlreadyShipped"].ToString() + "      </td>");
                                        }
                                        try
                                        {
                                            RemainingCnt = (Convert.ToInt64(ds.Tables[2].Rows[iCnt]["NetReqQtyAfterStockDeduction"].ToString()) - Convert.ToInt64(ds.Tables[2].Rows[iCnt]["AlreadyShipped"].ToString()));
                                            if(RemainingCnt<0){
                                                RemainingCnt=0;
                                            }
                                        }
                                        catch
                                        {
                                            RemainingCnt=0;
                                        }
                                        if (objcust.IsDetailsRequire == true)
                                        {
                                            strReport2.AppendLine("      <td style='text-align:center;vertical-align: middle;' bgcolor='#ffff99' >  Remaining: <b>" + RemainingCnt + "</b> Req: <b>" + ds.Tables[2].Rows[iCnt]["TOTAL"].ToString() + " </b> Stock: <b>" + ds.Tables[2].Rows[iCnt]["STOCK_TOTAL"].ToString() + "</b> </td>");
                                        }
                                        else
                                        {
                                            if (RemainingCnt > 0)
                                            {
                                                strReport2.AppendLine("      <td style='text-align:center;vertical-align: middle;' bgcolor='#ffff99' > " + RemainingCnt + "      </td>");
                                            }
                                            else
                                            {
                                                strReport2.AppendLine("      <td style='text-align:center;vertical-align: middle;' > " + RemainingCnt + "      </td>");
                                            }
                                        }
                                        if (ds.Tables[2].Rows.Count != 1)
                                        {
                                            ds.Tables[2].Rows.RemoveAt(iCnt);
                                        }
                                    }
                                    if (found == true)
                                    {
                                        break;
                                    }
                                }
                                if (found == false)
                                {
                                    strReport.AppendLine("      <td style='text-align:center;vertical-align: middle;' > 0</td>");
                                    strReport1.AppendLine("      <td style='text-align:center;vertical-align: middle;' > 0</td>");
                                    strReport2.AppendLine("      <td style='text-align:center;vertical-align: middle;' > 0</td>");
                                }
                            }
                            strTotReport.AppendLine("<tr>" + strReport.ToString() + "</tr>");
                            strTotReport.AppendLine("<tr>" + strReport1.ToString() + "</tr>");
                            strTotReport.AppendLine("<tr>" + strReport2.ToString() + "</tr>");
                        }
                        ds.Dispose();
                        //strReportSchoolCodeHead.AppendLine("      <td style='text-align:Left;'> &nbsp; </td>");
                        //strReportSchoolNameHead.AppendLine("      <td style='text-align:Left;'> Stock Qty.   </td>");
                        //strTableReport.AppendLine("<table border='1' width='" + (((CircleCnt * 2) + 5) * 50) + "Px' >");
                        strTableReport.AppendLine("<table border='1' >");
                        strTableReport.AppendLine("     <tr><td colspan='" + (CircleCnt + 5) + "'> " + "Challan Delivery  Report of District- <B>" + ds.Tables[1].Rows[0]["DISTRICT"].ToString() + "</b></td></td></tr>");
                        strTableReport.AppendLine("     <tr><td colspan='" + (CircleCnt + 5) + "'> " + "From  <B>" + Convert.ToDateTime(objcust.startDate).ToString("dd-MMM-yyyy") + "</b> To <b>" + Convert.ToDateTime(objcust.endDate).ToString("dd-MMM-yyyy") + "</b></td></td></tr>");
                        strTableReport.AppendLine("     <tr>");
                        strTableReport.AppendLine("         <td style='text-align:Left;'>Book Code</td>");
                        strTableReport.AppendLine("         <td style='text-align:Left;'>Class</td>");
                        strTableReport.AppendLine("         <td style='text-align:Left;'>TITLE OF BOOKS</td>");
                        strTableReport.AppendLine("         <td>Language</td>");
                        strTableReport.AppendLine("         <td>&nbsp;</td>");
                        strTableReport.AppendLine("          " + strReportSchoolNameHead.ToString());
                        strTableReport.AppendLine("     </tr>");
                        strTableReport.AppendLine("          " + strTotReport.ToString());
                        strTableReport.AppendLine("</table>");

                        Response.Clear();
                        Response.Buffer = true;
                        Response.ContentType = "application/vnd.ms-excel";
                        String FileName = "CircleChallanDeliveryRpt" + DateTime.Now.Year.ToString() + "_" + DateTime.Now.ToString("dd-MMM-yyyy") + ".xls";
                        Response.AddHeader("Content-Disposition", "inline;filename=" + FileName);
                        String HTMLDataToExport = strTableReport.ToString();
                        //System.IO.FileInfo fiCSSInfo = new System.IO.FileInfo(Server.MapPath("/resources/css/ReportFormat.css"));
                        //System.Text.StringBuilder sbCSSInfo = new System.Text.StringBuilder();
                        //System.IO.StreamReader srCSSInfo = fiCSSInfo.OpenText();
                        //while (srCSSInfo.Peek() > 0)
                        //{
                        //    sbCSSInfo.Append(srCSSInfo.ReadLine());
                        //}
                        //srCSSInfo.Close();

                        Response.Write("<html><head><head>" +
                        HTMLDataToExport.Replace("<BR>", "<br style='mso-data-placement:same-cell;'>")
                                                       .Replace("<br>", "<br style='mso-data-placement:same-cell;'>")
                                                       .Replace("<BR >", "<br style='mso-data-placement:same-cell;'>")
                                                       .Replace("<BR />", "<br style='mso-data-placement:same-cell;'>")
                                                       .Replace("<br />", "<br style='mso-data-placement:same-cell;'>")
                                                       .Replace("<Br />", "<br style='mso-data-placement:same-cell;'>")
                                                       .Replace("<Br>", "<br style='mso-data-placement:same-cell;'>")
                                                       .Replace("<br >", "<br style='mso-data-placement:same-cell;'>") + "</html>");
                        Response.End();
                    }

                }
            }
            catch (Exception ex)
            {
                objDbTrx.SaveSystemErrorLog(ex, Request.UserHostAddress);
            }
            return View(get_dropdown());
        }