Exemple #1
0
    // - - - - - - - - - - - - - - - - - - - - - - - - -
    //	Запуск команды на Sql-сервере
    static bool    StartSqlCmd(string CmdText)
    {
        if (CmdText == null)
        {
            return(false);
        }
        if (CmdText.Trim() == "")
        {
            return(false);
        }
        CConsole.ShowBox("", "Выполнение команды на сервере", "");
        Connection      = new   CConnection(ConnectionString);
        Command         = new   CCommand(Connection);
        Command.Timeout = 599;
        bool Result = Command.Execute(CmdText);

        Command.Close();
        Connection.Close();
        CConsole.Clear();
        CCommon.Print(CAbc.EMPTY, "Для продолжения нажмите Enter.");
        CConsole.ClearKeyboard();
        CConsole.Flash();
        CConsole.ReadChar();
        return(Result);
    }
Exemple #2
0
        public static DataSet GetData(SqlCommand cmd, int pageIndex)
        {
            string strConnString = CConnection.GetConnectionString();

            using (SqlConnection con = new SqlConnection(strConnString))
            {
                using (SqlDataAdapter sda = new SqlDataAdapter())
                {
                    cmd.Connection    = con;
                    sda.SelectCommand = cmd;
                    using (DataSet ds = new DataSet())
                    {
                        sda.Fill(ds, "JobCardMaster");
                        DataTable dt = new DataTable("Pager");
                        dt.Columns.Add("PageIndex");
                        dt.Columns.Add("PageSize");
                        dt.Columns.Add("RecordCount");
                        dt.Rows.Add();
                        dt.Rows[0]["PageIndex"]   = pageIndex;
                        dt.Rows[0]["PageSize"]    = PageSize;
                        dt.Rows[0]["RecordCount"] = cmd.Parameters["@RecordCount"].Value;
                        ds.Tables.Add(dt);
                        return(ds);
                    }
                }
            }
        }
Exemple #3
0
 public SysFunction()
 {
     //
     // TODO: Add constructor logic here
     //
     StrCCon = CConnection.GetConnectionString();
 }
Exemple #4
0
    private void SMS_DataBind()
    {
        CConnection conn = new CConnection();

        sql = "select * from [teacher]";
        DataSet ds = conn.dataset(sql);

        sms_T.DataSource = ds;
        sms_T.DataBind();
        ds.Clear();
        ds.Dispose();


        int    number;
        char   code;
        string checkCode = String.Empty;

        System.Random random = new Random();

        //for (int i = 0; i < 5; i++)
        //{
        number = 2;

        //if (number % 2 == 0)
        code = (char)('0' + (char)(number % 10));
        //else
        //    code = (char)('A' + (char)(number % 26));

        checkCode += code.ToString();
        //}

        Label2.Text = checkCode;
    }
 public OutputInvoice_Form(CConnection connection)
 {
     InitializeComponent();
     _connection    = connection;
     outputProducts = new List <OutputProduct>();
     _queries       = new OutputInvoiceQueries(_connection);
 }
        private void deleteButton_Click(object sender, EventArgs e)
        {
            if (PracownicyGrid.SelectedRows.Count > 0)
            {
                CConnection cc_connection = new CConnection();

                DialogResult dr_result = MessageBox.Show("Are you sure you want to delete " + PracownicyGrid.SelectedRows.Count + " row(s) from the table and database permanently?", "Delete selected row(s)?", MessageBoxButtons.YesNo);

                if (dr_result == DialogResult.Yes)
                {
                    foreach (DataGridViewCell dgvc_selectedCell in PracownicyGrid.SelectedCells)
                    {
                        if (dgvc_selectedCell.Selected)
                        {
                            string s_query = "DELETE FROM pracownicy WHERE PRACOWNICY_ID = " + dgvc_selectedCell.Value + ";";
                            try { PracownicyGrid.Rows.RemoveAt(dgvc_selectedCell.RowIndex); }
                            catch (Exception) { MessageBox.Show("Make sure you select only existing rows."); break; }

                            MySqlCommand cmd = new MySqlCommand(s_query, cc_connection.MySqlConnection);

                            cc_connection.vOpenConnection();
                            try { cmd.ExecuteNonQuery(); }
                            catch (Exception) { return; }
                            cc_connection.vCloseConection();
                        } //if (dgvc_selectedCell.Selected)
                    }     //foreach (DataGridViewCell dgvc_selectedCell in PracownicyGrid.SelectedCells)
                }
                dt_dataTable.Clear();
            }//if (PracownicyGrid.SelectedRows.Count > 0)
        }
Exemple #7
0
        static void Main(string[] args)
        {
            Connection = new CConnection("127.0.0.1", 44444);
            Connection.StartConnectingToServer();

            Process.GetCurrentProcess().WaitForExit();
        }
Exemple #8
0
        private string GetAccounttitle(string code)
        {
            try
            {
                string CCon  = CConnection.GetConnStringForAccount();
                string value = "";

                SqlDataAdapter dta = new SqlDataAdapter("Select rtrim(A.DetailDesc) as AccountTitle from GDetail  A where A.CompCode = '" + Session["DealerCode"].ToString() + "' and  A.contacccode +'-'+  A.SubCode +'-'+  A.subsubcode +'-'+  A.loccode +'-'+  A.DetailCode = '" + code + "'", CCon);

                DataTable dt = new DataTable();
                dta.Fill(dt);

                if (dt.Rows.Count > 0 && dt != null)
                {
                    value = dt.Rows[0]["AccountTitle"].ToString();
                }


                return(value);
            }
            catch (Exception ex)
            {
                sysFunc.UserMsg(lblMessage, Color.Red, ex.Message);
                return("");
            }
        }
        private void PullAll(CConnection connection, MySqlCommand command)
        {
            if (dt_dataTable != null)
            {
                dt_dataTable     = null;
                dt_dataTableCopy = null;
            }

            connection.vOpenConnection();

            try
            {
                MySqlDataAdapter adapter = new MySqlDataAdapter();
                adapter.SelectCommand = command;
                dt_dataTable          = new DataTable();
                adapter.Fill(dt_dataTable);
                BindingSource bindingSource = new BindingSource();

                bindingSource.DataSource  = dt_dataTable;
                PracownicyGrid.DataSource = bindingSource;
                adapter.Update(dt_dataTable);
                dt_dataTableCopy = dt_dataTable.Copy();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            connection.vCloseConection();
        }
        private void ConnectNodesWithRoadNetwork(Carpooler Pooler, List <RNode> Nodes)
        {
            Nodes = Nodes.Where(x => x != null).ToList();
            CNode src = null, dst = null;

            for (int i = 0; i < Nodes.Count - 1; ++i)
            {
                src = RoadNetwork.GetNode(Nodes[i].Point);
                dst = RoadNetwork.GetNode(Nodes[i + 1].Point);

                if (i == 0)
                {
                    Pooler.SetSource(src);
                }

                Dictionary <string, string> tags = this.RoadNetwork.GetConnectionTags(src, dst);

                int srcArrivalTime = Pooler.GetLastArrivalTime();
                int travelTime     = (int)RoadNetwork.AreConnected(Nodes[i], Nodes[i + 1]).GetTravelTime(string.Empty, Pooler.GetLastArrivalTime(), TravelMode.Car);
                int dstArrivalTime = srcArrivalTime + travelTime;

                CConnection C = RoadNetwork.AddConnection(src, dst, srcArrivalTime, dstArrivalTime, ref Pooler, tags);

                Pooler.AddConnection(ref C);

                Pooler.AddNextArrivalTime(dstArrivalTime);
            }
        }
Exemple #11
0
    //public bool ExecuteSP(string SP_Name, SqlParameter[] param, ref SqlDataReader dr)
    //{
    //    bool flag;

    //    try
    //    {
    //        GetConnection();
    //        dr = SqlHelper.ExecuteReader(GlobalVar.mCon, SP_Name, param);
    //        if (dr.HasRows) flag = true; else flag = false;
    //    }
    //    catch (Exception ex) { throw ex; }
    //    return flag;


    //}

    public DataSet FillDataSet(string SP_Name, SqlParameter[] param)
    {
        DataSet ds = new DataSet();

        ds = SqlHelper.ExecuteDataset(CConnection.GetConnectionString(), CommandType.StoredProcedure, SP_Name, param);
        return(ds);
    }
Exemple #12
0
 public DataTable GetDatas(string SQL, string database)
 {
     try
     {
         //StrCCon = CConnection.GetDMISConnectionString();
         //if (database == "DMIS")
         //{
         //    StrCCon = CConnection.GetDMISConnectionString();
         //}
         if (database == "FAMSConnectionString")
         {
             StrCCon = General.GetFAMConString();
         }
         else
         {
             StrCCon = CConnection.GetConnectionString();
         }
         SqlDataAdapter dta = new SqlDataAdapter(SQL, StrCCon);
         DataTable      dt  = new DataTable();
         dta.Fill(dt);
         StrCCon = CConnection.GetConnectionString();
         return(dt);
     }
     catch (Exception e)
     {
         // msg = e.Message;
         //GlobalVar.mErrorMessage = " Cretical connection Error cant continue ,please contact with concern person \n" + e.Message;
         return(null);
     }
 }
Exemple #13
0
        public bool FormsVerification(string LoginName, string CompanyCode, string ApplicationCode, ref DataTable dt)
        {
            try
            {
                List <FormVerification> lst = new List <FormVerification>();
                //var Serializer = new JavaScriptSerializer();
                SqlParameter[] sqlParam =
                {
                    new SqlParameter("@LoginName",       LoginName),
                    new SqlParameter("@CompCode",        CompanyCode),
                    new SqlParameter("@ApplicationCode", ApplicationCode)
                };
                dt = DataAccess.getDataTable("SP_FormsVerification", sqlParam, CConnection.GetSecurityConnectionString());

                if (dt != null && dt.Rows.Count > 0)
                {
                    lst = EnumerableExtension.ToList <FormVerification>(dt);
                    if (lst.Count > 0)
                    {
                        HttpContext.Current.Session["UserRights"] = lst;
                        SecurityDT = dt;
                    }

                    // FormsActionVerification(LoginName, CompanyCode, ApplicationCode);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(false);
        }
Exemple #14
0
        public static string GetSaleInvoiceDetail(string TransNo, string ChasisNo, string DealerCode)
        {
            string json = "";
            List <SelectListItem> item = new List <SelectListItem>();

            var Serializer = new JavaScriptSerializer();
            List <VehicleSaleMasterVM> lst = new List <VehicleSaleMasterVM>();

            try
            {
                //var Serializer = new JavaScriptSerializer();
                SqlParameter[] sqlParam =
                {
                    new SqlParameter("@DealerCode", DealerCode),
                    new SqlParameter("@TransCode",  TransNo),
                    new SqlParameter("@ChasisNo",   ChasisNo)
                };
                dt = DataAccess.getDataTable("SP_Get_SaleInvoiceDetail", sqlParam, CConnection.GetConnectionString());

                if (dt.Rows.Count > 0)
                {
                    lst = EnumerableExtension.ToList <VehicleSaleMasterVM>(dt);
                }
                json = Serializer.Serialize(lst);
            }
            catch (Exception ex)
            {
                //throw;
            }
            return(json);
        }
Exemple #15
0
        private void initializeDDLs(DropDownList ddl)
        {
            try
            {
                string CCon = CConnection.GetConnStringForAccount();

                SqlDataReader dr = SqlHelper.ExecuteReader(CCon, CommandType.Text, "Select A.contacccode +'-'+  A.SubCode +'-'+  A.subsubcode +'-'+  A.loccode +'-'+  A.DetailCode as AccountCode , A.contacccode +'-'+   A.SubCode +'-'+ A.subsubcode +'-'+ A.loccode +'-'+  A.DetailCode + ' | ' + rtrim(A.DetailDesc) as DetailDesc from GDetail  A where CompCode = '" + Session["DealerCode"].ToString() + "'");

                if (dr.HasRows)
                {
                    ListItem item = new ListItem();
                    item.Text  = "Select";
                    item.Value = "0";

                    //AddInAllDDL(item);

                    ddl.Items.Add(item);
                    while (dr.Read())
                    {
                        StringWriter myWriter = new StringWriter();
                        HttpUtility.HtmlDecode(dr["DetailDesc"].ToString().Replace(" ", "&nbsp;"), myWriter);//ddlEmp.Items.Add(myWriter.ToString());
                        item       = new ListItem();
                        item.Text  = myWriter.ToString();
                        item.Value = dr["AccountCode"].ToString();
                        ddl.Items.Add(item);
                    }
                    dr.Close();
                }
            }
            catch (Exception ex)
            {
                lblMessage.Visible = true;
                // lblMessage.Text = ex.Message;
            }
        }
Exemple #16
0
 public bool CodeExists(string strTableNames, string strColumnCode, string strColumeValue, string strDealerCode, ref DataSet ds)
 {
     try
     {
         //Create query to check in all tables one by one
         //foreach ( sTableName in strTableNames) {
         string sQuery = "SELECT * FROM " + strTableNames + " WHERE " + strColumnCode + " = '" + strColumeValue + "' AND DealerCode = '" + strDealerCode + "'";
         StrCCon = CConnection.GetConnectionString();
         ds      = new DataSet();
         ds      = SqlHelper.ExecuteDataset(this.StrCCon, CommandType.Text, sQuery);
         if (ds.Tables[0].Rows.Count > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         //clsLogger.WriteLog(e.Message, e.Source);
         throw ex;
     }
 }
Exemple #17
0
        public static void Unload()
        {
            CConnection con = Connection;

            Connection = null;

            con?.Disconnect();
        }
 private void LoadAll_Click(object sender, EventArgs e)
 {
     using (CConnection cc_connection = new CConnection())
     {
         string       s_query = "SELECT PRACOWNICY_ID as ID, NAME as Name, SURNAME as Surname, CITY as City, SEX as Sex FROM pracownicy";
         MySqlCommand command = new MySqlCommand(s_query, cc_connection.MySqlConnection);
         PullAll(cc_connection, command);
     }//using (CConnection cc_connection = new CConnection())
 }
Exemple #19
0
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    //	Вычитка истории вполнения пунктов открытия/закрытия дня
    static bool    SaveHistory(int Mode, int Choice)
    {
        Connection = new   CConnection(ConnectionString);
        Command    = new   CCommand(Connection);
        bool Result = Command.Execute(" exec  dbo.Mega_Day_Close;11  @DayDate=" + DayDate.ToString() + " , @FlagCode= " + Choice.ToString() + " , @Mode= " + Mode.ToString());

        Command.Close();
        Connection.Close();
        return(Result);
    }
Exemple #20
0
        public void testPheromonHandling()
        {
            CConnection connection = new CConnection(TEST_POINT_1, TEST_POINT_2, TEST_EXPLICIT_DISTANCE, TEST_INITIAL_PHEROMON);

            Assert.IsTrue(connection.getPheromone() == TEST_INITIAL_PHEROMON);

            connection.addPheromone(TEST_ADDITIONAL_PHEROMON);
            Assert.IsTrue(connection.getPheromone() == (TEST_INITIAL_PHEROMON + TEST_ADDITIONAL_PHEROMON));

            connection.addPheromone(TEST_SUBSTRACT_PHEROMON);
            Assert.IsTrue(connection.getPheromone() == (TEST_INITIAL_PHEROMON + TEST_ADDITIONAL_PHEROMON + TEST_SUBSTRACT_PHEROMON));
        }
Exemple #21
0
        public static CFastCyclicNetwork Convert(FastCyclicNetwork fcn)
        {
            var cfcn            = new CFastCyclicNetwork();
            var numberOfNeurons = fcn._neuronActivationFnArray.Length;

            // Copy connections
            cfcn.Connections = new List <CConnection>(fcn._connectionArray.Length);
            foreach (var c in fcn._connectionArray)
            {
                var cc = new CConnection
                {
                    ToNeuronId   = c._tgtNeuronIdx,
                    FromNeuronId = c._srcNeuronIdx,
                    Weight       = c._weight
                };
                cfcn.Connections.Add(cc);
            }

            // Copy activation functions
            cfcn.ActivationFunctions = new List <string>(numberOfNeurons);
            foreach (var s in fcn._neuronActivationFnArray)
            {
                if (s == null)
                {
                    cfcn.ActivationFunctions.Add("");
                }
                else
                {
                    cfcn.ActivationFunctions.Add(s.FunctionId);
                }
            }

            // Copy auxiliary arguments
            cfcn.NeuronAuxArgs = new List <List <double> >(numberOfNeurons);
            foreach (var aux in fcn._neuronAuxArgsArray)
            {
                if (aux == null)
                {
                    cfcn.NeuronAuxArgs.Add(new List <double>());
                }
                else
                {
                    cfcn.NeuronAuxArgs.Add(new List <double>(aux));
                }
            }
            cfcn.NeuronCount            = fcn._neuronCount;
            cfcn.InputNeuronCount       = fcn._inputNeuronCount;
            cfcn.OutputNeuronCount      = fcn._outputNeuronCount;
            cfcn.TimestepsPerActivation = fcn._timestepsPerActivation;

            return(cfcn);
        }
Exemple #22
0
//FOLD00

    public void    Close()
    {
        if (Conn1 != null)
        {
            Conn1.Close();
            Conn1 = null;
        }
        if (Conn2 != null)
        {
            Conn2.Close();
            Conn2 = null;
        }
    }
Exemple #23
0
        /// <summary>
        /// Tested den Datenbestand einer Verbindung
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="expectedPoint1"></param>
        /// <param name="expectedPoint2"></param>
        /// <param name="expectedDistance"></param>
        /// <param name="expectedPheromon"></param>
        protected void testConnectionData(CConnection connection, CTSPPoint expectedPoint1, CTSPPoint expectedPoint2, float expectedDistance, float expectedPheromon)
        {
            CTSPPoint testPoint1;
            CTSPPoint testPoint2;

            connection.getPoints(out testPoint1, out testPoint2);

            Assert.AreSame(testPoint1, expectedPoint1);
            Assert.AreSame(testPoint2, expectedPoint2);

            Assert.IsTrue(connection.getDistance() == expectedDistance);
            Assert.IsTrue(connection.getPheromone() == expectedPheromon);
        }
Exemple #24
0
        public CResult DataReaderQueryRequest(string sSql)
        {
            oSqlConnection     = new SqlConnection();
            m_oCConnectionToDB = new CConnection();
            oSqlConnection     = m_oCConnectionToDB.GetDBConnection();

            SqlCommand    sqlComm        = new SqlCommand(sSql, oSqlConnection);
            SqlDataReader oSqlDataReader = sqlComm.ExecuteReader();

            oCResult.Data = oSqlDataReader;

            return(oCResult);
        }
Exemple #25
0
 public CAppSettings(CConnection Cnct)
 {
     Connection = Cnct;
     Topics     = new   string[TOTAL_GROUP];
     Purposes   = new   string[TOTAL_GROUP];
     TopicMenus = new   string[TOTAL_GROUP];
     for (Current = 0; Current < TOTAL_GROUP; Current++)
     {
         Topics[Current]     = "";
         TopicMenus[Current] = "";
         Purposes[Current]   = "";
     }
 }
        public CConnection AddConnection(CNode src, CNode dst, int srcArrivalTime, int dstArrivalTime, ref Carpools.Carpooler Pooler, Dictionary <string, string> tags)
        {
            __MaxArcID = Connections.Count + __NumCCDeleted + 1;

            CConnection C = new CConnection(__MaxArcID, src, dst, srcArrivalTime, dstArrivalTime, Pooler, tags);

            src.Connections.Add(C);
            Connections.Add(__MaxArcID, C);
            CConnections.Add(__MaxArcID, C);
            Pooler.networkIdCCList.Add(__MaxArcID);
            ++(__MaxArcID);
            return(C);
        }
        public FrmController()
        {
            InitializeComponent();

            Connection = new CConnection(Program.Host, Program.Port);
            Connection.OnConnectionAuthorized          += Connection_OnConnectionAuthorized;
            Connection.OnConnectionAuthorizationFailed += Connection_OnConnectionAuthorizationFailed;
            Connection.OnUpdateKey             += Connection_OnUpdateKey;
            Connection.OnUpdateClient          += Connection_OnUpdateClient;
            Connection.OnRemoveClient          += Connection_OnRemoveClient;
            Connection.OnSessionPacketReceived += Connection_OnSessionPacketReceived;

            SessionManager = new CSession_Manager(Connection);
        }
Exemple #28
0
        //string CCon = ConfigurationManager.AppSettings["ConnectionString"].ToString();
        protected void Page_Load(object sender, EventArgs e)
        {
            CrystalReportViewer1.DisplayGroupTree = false;
            RD       = new ReportDocument();
            ReportID = Request.QueryString["ReportID"];
            if (ReportID == "PartItemLedger")
            {
                string StrToDateFrom = "", StrDateTo = "";
                RD    = new ReportDocument();
                dsrpt = new DataSet1();
                // PartItemLedger.sp_ItemStockLedger_select.Load(ds.CreateDataReader());
                DataSet ds = new DataSet();
                //DataSet ds1 = new DataSet();
                StrToDateFrom = Request.QueryString["FromDate"];
                StrDateTo     = Request.QueryString["ToDate"];
                SqlParameter[] param =
                {
                    new SqlParameter("@DealerCode",   SqlDbType.Char, 5),           //0
                    new SqlParameter("@FromPartCode", SqlDbType.VarChar, 50),       //0
                    new SqlParameter("@ToPartCode",   SqlDbType.VarChar, 50),       //0
                    new SqlParameter("@OpeningDate",  SqlDbType.VarChar, 10),       //0
                    new SqlParameter("@ToDate",       SqlDbType.VarChar, 10),       //0
                };
                param[0].Value = Session["DealerCode"].ToString();
                param[1].Value = Request.QueryString["FromCode"].ToString();
                param[2].Value = Request.QueryString["ToCode"].ToString();
                param[3].Value = Convert.ToDateTime(StrToDateFrom).ToString("yyyy-MM-dd");
                param[4].Value = Convert.ToDateTime(StrDateTo).ToString("yyyy-MM-dd");
                ObjSysFunc.ExecuteSP_NonQuery("sp_PartItemLedger", param);
                ds = SqlHelper.ExecuteDataset(CConnection.GetConnectionString(), CommandType.Text, "sp_tempItemStockLedger_Select '" + Session["DealerCode"].ToString() + "'");
                //dsrpt.sp_tempItemStockLedger_Select.Load(ds.CreateDataReader());

                RD.Load(base.Server.MapPath("rptItemStockLedger.rpt"));
                //RD.Load(base.Server.MapPath("rptLedger.rpt"));
                RD.DataDefinition.FormulaFields["DealerName"].Text    = "'" + Session["DealerDesc"].ToString() + "'";
                RD.DataDefinition.FormulaFields["DealerAddress"].Text = "'" + Session["DealerAddress"].ToString() + "'";
                RD.DataDefinition.FormulaFields["DealerPhone"].Text   = "'" + Session["DealerPhone"].ToString() + "'";
                RD.DataDefinition.FormulaFields["DealerEmail"].Text   = "'" + Session["DealerEmail"].ToString() + "'";
                RD.DataDefinition.FormulaFields["UserID"].Text        = "'" + Session["UserName"].ToString() + "'";
                RD.DataDefinition.FormulaFields["FromCode"].Text      = "\"" + Convert.ToDateTime(Request.QueryString["FromDate"].ToString()).ToString("dd/MM/yyyy") + "\"";
                RD.DataDefinition.FormulaFields["ToCode"].Text        = "\"" + Convert.ToDateTime(Request.QueryString["ToDate"].ToString()).ToString("dd/MM/yyyy") + "\"";
                RD.DataDefinition.FormulaFields["NTN"].Text           = "'N.T.N # " + Session["DealerNTN"].ToString() + "'";
                RD.DataDefinition.FormulaFields["SalesTaxNo"].Text    = "'Sales Tax No.  " + Session["DealerSaleTaxNo"].ToString() + " '";
                RD.DataDefinition.FormulaFields["Terminal"].Text      = "'" + Request.ServerVariables["REMOTE_ADDR"].ToString() + "'";
                RD.DataDefinition.FormulaFields["ReportTitle"].Text   = "\"" + "ITEM STOCK LEDGER REPORT" + "\"";
                RD.DataDefinition.FormulaFields["Pic"].Text           = "'C:\\Users\\u_ahm\\OneDrive\\Documents\\Visual Studio 2010\\Projects\\WebApplication1\\WebApplication1\\" + Session["Logo"] + "'";
                //  RD.SetDataSource(dsrpt.sp_tempItemStockLedger_Select.DataSet);
            }
            CrystalReportViewer1.ReportSource = RD;
        }
        private void enterButton_Click(object sender, EventArgs e)
        {
            if (dt_dataTable.Rows.Count > 0)
            {
                int i_count = dt_dataTable.Rows.Count;

                using (CConnection cc_connection = new CConnection())
                {
                    foreach (DataRow dr_row in dt_dataTable.Rows)
                    {
                        bool b_isComplete = true;
                        for (short ii = 0; ii < dt_dataTable.Columns.Count; ii++)
                        {
                            if (dr_row[ii].ToString() == "" || dr_row[ii] == null)
                            {
                                b_isComplete = false;
                                i_count--;
                                break;
                            }
                        }//for (short ii = 0; ii < dt_dataTable.Columns.Count; ii++)

                        if (b_isComplete)
                        {
                            string       s_query = "INSERT INTO pracownicy (NAME, SURNAME, CITY, SEX) VALUES (\"" + dr_row[0].ToString() + "\",\"" + dr_row[1].ToString() + "\",\"" + dr_row[2].ToString() + "\"," + dr_row[3].ToString() + ");";
                            MySqlCommand command = new MySqlCommand(s_query, cc_connection.MySqlConnection);

                            cc_connection.vOpenConnection();
                            command.ExecuteNonQuery();
                            cc_connection.vCloseConection();
                        } //if (b_isComplete)
                    }     //foreach (DataRow dr_row in dt_dataTable.Rows)
                }         //using (CConnection cc_connection = new CConnection())

                try
                {
                    dt_dataTable.Rows.Clear();
                }
                catch (InvalidConstraintException ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                MessageBox.Show(i_count + " row(s) added!");
            }//if (dt_dataTable.Rows.Count > 0)
            else
            {
                MessageBox.Show("There is no records to enter into the database.");
            }
        }
Exemple #30
0
    public void UpdateJV(string CompanyCode, string delNo)
    {
        // string pcName = System.Net.Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables["REMOTE_HOST"]).HostName.ToString();
        string connstring = CConnection.GetFAMSConnectionString();

        using (SqlConnection conn = new SqlConnection(connstring))
        {
            using (SqlCommand cmd = new SqlCommand("Sp_update", conn))
            {
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                conn.Open();
                cmd.Parameters.AddWithValue("@CompCode", CompanyCode);
                cmd.Parameters.AddWithValue("@VouchNo", delNo);
                cmd.ExecuteNonQuery();
            }
        }
    }